0

我正在使用 jplayer 在网页上播放音频,当页面加载时,检查器和播放器加载正常,但绑定功能不起作用。如果我稍后从控制台调用它,那么它工作正常。

$(document).ready(function(){
    myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
        { mp3: flatplaylist[0] },
        { supplied: "mp3", }
    );
    $("#jplayer_inspector").jPlayerInspector({jPlayer:$("#jquery_jplayer_1")});
    //does not work from here, but will work if I put this in the console.
    $(myCirclePlayer.audio).bind('ended',function (){ playNextFile(); }); 
});
4

1 回答 1

3

这是我的最终代码,效果很好。

var PlayerID = "#jquery_jplayer_1";
$(window).ready(function(){
    myCirclePlayer = new CirclePlayer(PlayerID,{mp3: 'audio/'+mypl.playlist[0]},{supplied: "mp3",});
    $("#jplayer_inspector").jPlayerInspector({jPlayer:$("#jquery_jplayer_1")});
    $(PlayerID).bind($.jPlayer.event.ended, function (){ playNextFile(); });
});
于 2013-02-14T19:34:04.127 回答