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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -