问题
Further to my previous post about when/where to dynamically add items to a playlist, it appears that the jPlayer ready event handler function is not available when the Playlist add-on is used, as can be seen by a simple example:
$(function () {
var MyPlayList = new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_1",
cssSelectorAncestor: "#jp_container_1"
}, [], {
smoothPlayBar: true,
supplied: "mp3"
});
$("#jquery_jplayer_1").jPlayer({
ready: function () {
alert('here');
}
});
Whether this is because the event is not raised or because the jPlayer object is 'wrapped' by the PlayList is not clear, but either way it seems like a fairly fundamental restriction if this is indeed the case and there is no other way of achieving the same.
回答1:
You could try this :
$("#jplayer_id").bind($.jPlayer.event.loadeddata, function(event) {
// do stuff
});
回答2:
Actually, $.jPlayer.event.ready it is more appropriate.
$("#jplayer_id").bind($.jPlayer.event.ready, function(event) {
// do stuff
});
来源:https://stackoverflow.com/questions/19444278/jplayer-ready-event-with-playlist-addon