Video Coding

Home❯Coding Introduction❯Multiple Videos but only one playing at a time

One Video at a time - Simple

People often put more than one video on a page.  Sometimes they put a lot - and it works OK-ish. Visitors can click on each one and pretty soon have them all playing at once. That may be OK as far as the visual element is concerned but the overlapping audio tracks sound awful.

It would be better if when you clicked the "play" button on a video, it stopped any others from playing. We added some Javascript to make that happen. Try exploring the four videos below.
 
Only allow one video to play
Allow many videos to play
 

Loading ...
 
(It's not the only way to do this and we have an example that makes the active video larger and  and one that may be better for larger numbers of videos on one page)

The main code for this page:is further down but here's some notes on how it works:


Last modified: 11 October 2025, 5:08pm