How to stop multiple youtube videos from playing simultaneously


I cant find a way to stop my videos from playing simultaneously if someone has to click more than one.

I need to know if there is a way when one video is playing and another is selected the first video should stop or pause.



Hi Nave,

You'll have to explain a bit more about what you are using to display and play the videos. Are you creating a Mobile App? A Reactive Web App? Traditional? What framework are you using, OutSystems UI? What kind of controls?


I have using web app,I have more than 3 videos in my screen ,One video is playing and another video is selected the first video should stop or pause. 

So I have used this query, But When I fetch the video using youtube url its not working, please suggest, I need to work both ways like uploaded video and pass the url

SyntaxEditor Code Snippet

$(document).ready(function() {
 var videos = document.querySelectorAll('video');

function pauseAll(elem){
    for(var i=0; i<videos.length; i++)
        //Is this the one we want to play?
        if(videos[i] == elem) continue;
        //Have we already played it && is it already paused?
        if(videos[i].played.length > 0 && !videos[i].paused){
        // Then pause it now
for(var i=0; i<videos.length; i++)
   videos[i].addEventListener('play', function(){pauseAll(this)}, true);

Well, this is all JavaScript, so not directly OutSystems-related. Unfortunately, my JavaScript knowledge is limited, so I can't answer you.