51
Views
6
Comments
How to stop multiple youtube videos from playing simultaneously
Question

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

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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?

UserImage.jpg
Nave Jothi

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);
})
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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

UserImage.jpg
Naveen Raj

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

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

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

UserImage.jpg
Naveen Raj

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.