Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

jplayer

I need to stop all other instances of jPlayer before playing a new one when i click play.

Thanks for you help.

like image 485
Mr_Nizzle Avatar asked May 04 '10 13:05

Mr_Nizzle


2 Answers

SOLVED

just assigned onclick function to the play trigger and the functions does:


function stopall(){
    $(".jplyrselectr").jPlayer("stop");
}

like image 151
Mr_Nizzle Avatar answered Jan 01 '23 08:01

Mr_Nizzle


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"
});
like image 24
jackocnr Avatar answered Jan 01 '23 10:01

jackocnr