Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

jwAdvancedSetup


THe following question was posted last year:

How to stop any other player on page from playing when playing a video
klainez — Mar 31, 2015

The answer so far is:

The JW6 event syntax would be as follows:

<script>
jwplayer("player1").setup({
file: 'xyz.mp4',
autostart: false,
width: '100%',
aspectratio: '16:9',
stretching: 'exactfit'
});
jwplayer("player1").onBeforePlay(function(){
pauseAllOthers("player1");
});

// Pause All Others
function pauseAllOthers(currentId){
...
}
</script>

I'd actually pause all the other players *before* the current one begins playing.
James


I still don't know how to get this accomplished. I have searched the web to no avail.
Could you please provide a complete answer with complete code. There are parts missing and I am not a programmer.

Thank you.
Henry

1 Community Answers

James Herrieven

User  
0 rated :

So, it would be something like this:

<script>
var playerInstance = jwplayer("player1");
playerInstance.setup({
file: 'xyz.mp4',
autostart: false,
width: '100%',
aspectratio: '16:9',
stretching: 'exactfit'
});
playerInstance.onBeforePlay(function(){
pauseAllOthers(playerInstance.id);
});

// Pause All Others
function pauseAllOthers(currentId){
var jwcount = 0;
while(jwplayer(jwcount) &&( jwplayer(jwcount).container|| jwplayer(jwcount).getContainer())&& jwplayer(jwcount).getState()){
var jwp = jwplayer(jwcount);
if(jwp && jwp.id != currentId){
jwp.pause(true);
}
jwcount++;
}
}
</script>

If you provide your specific code (maybe via email), I'll update it for your particular setup.

James Herrieven
===================================================
Powered by Haiku
http://powered-by-haiku.co.uk/
---------------------------------------------------
Tatami for Online Video
http://dev.powered-by-haiku.co.uk/solutions/tatami/
---------------------------------------------------
skype: JamesHerrieven
email: james[at]haiku[dot]co[dot]uk
===================================================

This question has received the maximum number of answers.