5
function intilizePlayer(){ 
    $("#jquery_jplayer_1").jPlayer({
        ready: function (event) {
            $(this).jPlayer("setMedia", {
                oga:song
            });
            songDuration = $(this).jPlayer.status.duration;
        },
        ended: function (event) {
                $(this).jPlayer("play");
        },
        swfPath: "swf",
        supplied: "oga"
    }).bind($.jPlayer.event.play, function() {
        $(this).jPlayer("pauseOthers");
    });
}

Here i try to get the duration of the song. But it says "undefined". Other than this i tried to use the following, after calling the above function.

var duration = $("#jquery_jplayer_1").data("jPlayer").status.duration;

Then the duration became 0. How to get the real duration?

Alex Jasmin
  • 39,094
  • 7
  • 77
  • 67
dinesh707
  • 12,106
  • 22
  • 84
  • 134

1 Answers1

7
function intilizePlayer(){ 
    $("#jquery_jplayer_1").jPlayer({
        ready: function (event) {
            $(this).jPlayer("setMedia", {
                oga:song
            });
        },
        ended: function (event) {
                $(this).jPlayer("play");
        },
        loadeddata: function(event){ // calls after setting the song duration
            songDuration = event.jPlayer.status.duration;
        },
        swfPath: "swf",
        supplied: "oga"
    }).bind($.jPlayer.event.play, function() {
        $(this).jPlayer("pauseOthers");
    });
}
dinesh707
  • 12,106
  • 22
  • 84
  • 134