2012-11-02 7 views
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"); 
    }); 
} 

Qui cerco di ottenere la durata della canzone. Ma dice "indefinito". Oltre a questo ho provato a usare il seguente, dopo aver chiamato la funzione di cui sopra.Come ottenere la durata della canzone in JPlayer

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

Quindi la durata è diventata 0. Come ottenere la durata reale?

risposta

6
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"); 
    }); 
}