Javascript examples for DOM HTML Element:Video
The mediaGroup property sets or gets the media group the video is a part of.
A media group synchronizes 2 or more <video> elements.
Set the mediaGroup property with the following Values
Value | Description |
---|---|
group | Sets the media group of the video |
A String, representing the media group of the video
The following code shows how to Set the media group for 2 videos:
<!DOCTYPE html> <html> <body> <video id="myVideo1" width="320" height="240" controls> <source src="your.mp4" type="video/mp4"> <source src="your.ogg" type="video/ogg"> Your browser does not support the video tag. </video>//from w ww . java 2 s . c o m <video id="myVideo2" width="320" height="240" controls> <source src="your.mp4" type="video/mp4"> <source src="your.ogg" type="video/ogg"> Your browser does not support the video tag. </video><br> <button onclick="setMedGroup()" type="button">Set media group for videos</button> <button onclick="getMedGroup()" type="button">Get media group for videos</button> <script> var x = document.getElementById("myVideo1"); var y = document.getElementById("myVideo2"); function setMedGroup() { x.mediaGroup = "test"; y.mediaGroup = "test"; } function getMedGroup() { console.log("Video 1 media group: " + x.mediaGroup + ". Video 2 media group: " + y.mediaGroup); } </script> </body> </html>