Search code examples
jqueryhtmljplayer

jplayer get current position played


I'd like to get current number of played movie in jplayer.

For example in playlist I got 3 movies, and when lets say second is played then something is happeing.

All I found so far from documentation is:

var myPlaylist = new jPlayerPlaylist({
    jPlayer: "#jquery_jplayer_1",
    cssSelectorAncestor: "#jp_container_1"
}, [
{
    title: "Big Buck Bunny Trailer",
    artist: "Blender Foundation",
    free: true,
    m4v: "http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v"
},
{
    title: "Finding Nemo Teaser",
    artist: "Pixar",
    m4v: "http://www.jplayer.org/video/m4v/Finding_Nemo_Teaser.m4v"
},
{
    title: "Incredibles Teaser",
    artist: "Pixar",
    m4v: "http://www.jplayer.org/video/m4v/Incredibles_Teaser.m4v"
}
], {
    swfPath: "js",
    supplied: "m4v",
    smoothPlayBar: true,
    keyEnabled: true
}

); And then

if(myPlaylist.play()=="0"){
    console.log("do something")
}   

or

if(myPlaylist.play(0)){
    console.log("do something")
}  

It doesnt work at all. If anyone could help me , that'd be great :)


Solution

  • I found your question here

    jPlayer 2.2.0: display track title in separate div on page load

    $("#jquery_jplayer_1").bind($.jPlayer.event.play, function(event) {
                        var current = myPlaylist.current,
                                playlist = myPlaylist.playlist;
                        $.each(playlist, function(index, obj) {
    
                            if (index == current) {
                                    console.log(current)
    
                            }
                        });
                    });