play videos on several different pages by clicking on one button

466 Views Asked by At

I'm a designer and I do projects where I try to code, let's say I DIY in front end! But right now I want to do something where I'm completely stuck.

I would like to have several screens (multiple devices) containing videos, they would all launch at the same time when clicking on a button on a specific page. I heard about nodejs to maybe create several pages each containing a video, and on clicking a button on the index page all the other pages launch the video at the same time. I tried to dive into nodejs but I'm extremely clueless, I'd like to know if you think it's possible to do it like that? And if so, if you maybe have any resources?

I hope I'm clear, thanks a lot in advance!

1

There are 1 best solutions below

6
Leo Ramadani On

You can achieve this with pure html and javascript, I'm not sure that's what you asking but...here is an example:

            document.getElementById("clickme").addEventListener("click",function(){
                document.getElementById("vid1").play();
            document.getElementById("vid2").play();
            document.getElementById("vid3").play();

            })
      <video width="400" controls id="vid1">
        <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
      </video>
      
      <video width="400" controls id="vid2">
        <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
      </video>
      
      <video width="400" controls id="vid3">
        <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
      </video>

      <button id="clickme">click me</button>