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.如何获得实际持续时间?
答案 0 :(得分: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");
});
}