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

में गीत की अवधि कैसे प्राप्त करें यहां मैं गीत की अवधि प्राप्त करने का प्रयास करता हूं। लेकिन यह "अपरिभाषित" कहता है। इसके अलावा मैंने उपरोक्त फ़ंक्शन को कॉल करने के बाद निम्न का उपयोग करने का प्रयास किया।जेपीलेयर

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