Multiple Videos | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Multiple Videos

let's say I have two or more videos on my page with HTML video tag, I found out that when I clicked both, both of them play... and I want a situation whereby only one video will play at a time, when one is clicked the other will stop... How can I use JavaScript for this? please help thanks

9th Sep 2018, 8:36 PM
Adewale Olaoye
Adewale Olaoye - avatar
4 Answers
+ 3
Video dom has play() and pause() methods.
9th Sep 2018, 9:44 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
In additional to Toni Isotalo's answer: Have a look at this source👍: https://www.w3schools.com/tags/ref_av_dom.asp
9th Sep 2018, 10:01 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
0
thank you guys this helps but I've not gotten what I want... I want a situation that when I play one video, let's say out of 5 videos, only that one will play and if another video, say video4 is been clicked, video 1 will automatically pause without the user touching it...
9th Sep 2018, 10:22 PM
Adewale Olaoye
Adewale Olaoye - avatar
0
gotcha!!! Now i get it, Thanks guys
9th Sep 2018, 11:26 PM
Adewale Olaoye
Adewale Olaoye - avatar