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

ここでは、曲の長さを取得しようとしています。しかし、それは "未定義"と言います。これ以外は、上記の関数を呼び出した後、以下のようにしてみました。JPlayerで曲の長さを取得する方法

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

その後、継続時間は0になりました。

答えて

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"); 
    }); 
} 
関連する問題