jQuery jPlayer - How to stop all players before playing a new one?

瘦欲@ 提交于 2019-12-10 14:22:39

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!