Pergunta

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

Thanks for you help.

Foi útil?

Solução

SOLVED

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


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

Outras dicas

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");
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top