问题
I need to stop all other instances of jPlayer before playing a new one when i click play.
Thanks for you help.
回答1:
SOLVED
just assigned onclick function to the play trigger and the functions does:
function stopall(){
$(".jplyrselectr").jPlayer("stop");
}
回答2:
Give all of your players a class (I think default is class="jp-jplayer"), then include the following "play" event handler in your initialisation options:
$("#jplayer1").jPlayer({
ready: function() {
$(this).jPlayer("setMedia", {
mp3: "mp3/track1.mp3"
});
},
play: function() {
$(".jp-jplayer").not(this).jPlayer("stop");
},
swfPath: "js",
wmode: "window"
});
回答3:
maybe $("#jpId1, #jpId2, #jpId3").stop();
回答4:
You can use this method:
$.jPlayer.pause(); // Pause all instances of jPlayer on the page
Reference: Jplayer develpment guide
Or alternatively you can put this in the onclick or the click event function handler
$('[id^="jquery_jplayer"]').jPlayer("pause");
回答5:
$('#jPlayer_ID').jPlayer("pauseOthers");
来源:https://stackoverflow.com/questions/2765533/jquery-jplayer-how-to-stop-all-players-before-playing-a-new-one