javascript - Add function if song/track ended? -
i'm using jplayer plugin want add event function if last song/track + playlist ended.
as can see in docs event fired when playlist ended.
var playlength = myplaylist.playlist.length var currentsong = 0; $("#jpid").jplayer( { ready: function() { // $.jplayer.event.ready event $(this).jplayer("setmedia", { // set media m4v: "m4v/presentation.m4v" }).jplayer("play"); // attempt auto play media }, ended: function() { // $.jplayer.event.ended event currentsong++; if(currentsong==playlength) ------> show html }, supplied: "m4v" );
as don't know if myplaylist.current object or , index can check playlist finish using own counter
your code need this
var currentsong = 0; $("#music").bind($.jplayer.event.ended,function(event){ currentsong++; if(myplaylist.playlist.length == currentsong) { $('.show').html('ended'); } });
Comments
Post a Comment