English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The mediaGroup attribute of the video DOM reflects the mediaGroup HTML attribute, which indicates the name of the element group it belongs to. A group of media elements shares a common controller.
HTML Audio/Video DOM Reference Manual
Setting2Media group of a video:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/video mediaGroup attribute usage-Basic Tutorial(oldtoolbag.com)</title> </head> <body> <button onclick="setMedGroup()" type="button">Set media group for two videos</button> <button onclick="getMedGroup()" type="button">Get the media group of the video</button> <br> <video id="video1" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> <video id="video2" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> myVid1=document.getElementById("video1"); myVid2=document.getElementById("video2"); function setMedGroup() { myVid1.mediaGroup="test"; myVid2.mediaGroup="test"; } function getMedGroup() { alert("Video 1 media group: + myVid1.mediaGroup + ". Video 2 media group: + myVid2.mediaGroup); } </script> </body> </html>Test and see ‹/›
mediaGroup attribute sets or returns audio/the name of the media group to which the video belongs.
The media group allows2or more audio/The video element remains synchronized.
IEFirefoxOperaChromeSafari
All mainstream browsers support the mediaGroup attribute.
Set mediaGroup attribute:
audio|video.mediaGroup="group"
Return mediaGroup attribute:
audio|video.mediaGroup
Value | Description |
---|---|
group | Specifies the audio/media mix of videos. |
Return value: | String value indicating the audio/media mix of videos. |
---|