I have a page with a few YouTube video embed codes. When a user clicks "> play" on one video every other video on the page needs to pause otherwise their audio overlaps the new one just played.
What's the most efficient way of implementing this?
I have a page with a few YouTube video embed codes. When a user clicks "> play" on one video every other video on the page needs to pause otherwise their audio overlaps the new one just played.
What's the most efficient way of implementing this?
Alright here is a solution I came up with following some code from a few others.
In your .js file add the following:
Then in your html file, embed your youtube like so. Make sure you have enablejsapi=1 is at the end of the url to the YouTube file: