How to stop multiple youtube videos from playing simultaneously

Hi

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.


Thanks,

Jothi

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?

Hi,

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++)
    {
        alert(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
          videos[i].pause();
        }
    }
  }
 
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.

Kilian Hekhuis wrote:

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


Hi Kilian,

           How to control Youtube video play, pause, stop manually or pro-grammatically?


regards,

Naveen

Hi Naveen,

You could consider to use the IFrame YouTube player API.

The https://www.outsystems.com/forge/component-overview/8604/youtubereactive component I worked on does use this API. You can look at how it uses that YouTube API.

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Naveen,

You could consider to use the IFrame YouTube player API.

The https://www.outsystems.com/forge/component-overview/8604/youtubereactive component I worked on does use this API. You can look at how it uses that YouTube API.

Regards,

Daniel


Hi Daniel,

           Thanks for the response, will check.


regards,

Naveen