HTML 参考手册
HTML 音频/视频 DOM mediaGroup 属性
为两段视频设置媒体组合
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <button onclick="setMedGroup()" type="button">为两段视频设置媒体组合</button> <button onclick="getMedGroup()" type="button">获取视频的媒体组合</button> <br> <video id="video1" controls="controls"> <source src="/examples/mov_bbb.mp4" type="video/mp4"> <source src="/examples/mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> <video id="video2" controls="controls"> <source src="/examples/mov_bbb.mp4" type="video/mp4"> <source src="/examples/mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 HTML5 video 标签。 </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> <p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p> </body> </html>
运行结果:
点击运行 »