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了,如何得到真正的时长呢?
最佳答案
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");
});
}
关于jquery - 如何在JPlayer中获取歌曲的时长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13191271/