I need to stop all other instances of jPlayer before playing a new one when i click play.
Th开发者_如何学Canks for you help.
SOLVED
just assigned onclick function to the play trigger and the functions does:
function stopall(){
$(".jplyrselectr").jPlayer("stop");
}
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"
});
maybe $("#jpId1, #jpId2, #jpId3").stop();
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");
$('#jPlayer_ID').jPlayer("pauseOthers");
精彩评论