Make this code better

video section

i want when i play a video the others video stops automatic

video.js
var myVideo1 = document.getElementById("video1").onclick = function() { playPause1() }; var myVideo2 = document.getElementById("video2").onclick = function() { playPause2() }; var myVideo3 = document.getElementById("video3").onclick = function() { playPause3() }; function playPause1() { if (myVideo1.paused) myVideo1.play(); else myVideo1.pause(); myVideo2.pause(); myVideo3.pause(); } function playPause2() { if (myVideo2.paused) myVideo2.play(); else myVideo2.pause(); myVideo1.pause(); myVideo3.pause(); } function playPause3() { if (myVideo3.paused) myVideo3.play(); else myVideo3.pause(); myVideo2.pause(); myVideo1.pause(); }
video.html
<section> <div id="pro1"></div> <div class="work-page"> <div class="introduction"> <h3>FILM MAKING</h3></div> <div class="project-contents"> <section class="row"> <div class="col-lg-4"> <div class="wrapper"> <video id="video1" class="video" controls controlsList="nodownload nofullscreen"> <source src="RackCladBuilding1.mp4" type="video/mp4" /> </video> </div> </div> <div class="col-lg-4"> <div class="wrapper"> <video id="video2" class="video" controls controlsList="nodownload nofullscreen"> <source src="RackCladBuilding2.mp4" type="video/mp4" /> </video> </div> </div> <div class="col-lg-4"> <div class="wrapper"> <video id="video3" class="video" controls controlsList="nodownload nofullscreen"> <source src="dubai.mp4" type="video/mp4" /> </video> </div> </div> </section> </div> </div> </section>

Reactions 0 reactions

No reactions yet, be the first: comment or tweak the code

Comment on this code:

Please Login or Register to leave a comment.