jQuery jPlayer – 如何在播放新播放器之前阻止所有播放器?
当我点击播放时,我需要在播放新的jPlayer之前停止所有其他jPlayer实例。
谢谢你的帮助。
解决了
刚刚为播放触发器分配了onclickfunction,这些function可以:
function stopall(){ $(".jplyrselectr").jPlayer("stop"); }
给你的所有玩家一个类(我认为默认是class =“jp-jplayer”),然后在你的初始化选项中包含以下“play”事件处理程序:
$("#jplayer1").jPlayer({ ready: function() { $(this).jPlayer("setMedia", { mp3: "mp3/track1.mp3" }); }, play: function() { $(".jp-jplayer").not(this).jPlayer("stop"); }, swfPath: "js", wmode: "window" });
也许$("#jpId1, #jpId2, #jpId3").stop();
您可以使用此方法:
$.jPlayer.pause(); // Pause all instances of jPlayer on the page
参考: Jplayer发展指南
或者,您可以将其放在onclick或click事件函数处理程序中
$('[id^="jquery_jplayer"]').jPlayer("pause");
$('#jPlayer_ID').jPlayer("pauseOthers");