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

Ở đây tôi cố gắng thu được thời lượng của bài hát. Nhưng nó nói "không xác định". Khác hơn này tôi đã cố gắng sử dụng sau đây, sau khi gọi chức năng trên.Cách nhận thời lượng của bài hát trong JPlayer

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

Sau đó, thời gian trở thành 0. Cách nhận thời lượng thực?

Trả lời

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"); 
    }); 
} 
Các vấn đề liên quan