简单教程
提交运行
代码编辑器:
<button onclick="setMedGroup()" type="button">为两段视频设置媒体组合</button> <button onclick="getMedGroup()" type="button">获取视频的媒体组合</button> <br> <video id="video1" controls="controls"> <source src="/static/i/html/html_video_1.mp4" type="video/mp4"> <source src="/static/i/html/html_video_1.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> <video id="video2" controls="controls"> <source src="/static/i/html/html_video_1.mp4" type="video/mp4"> <source src="/static/i/html/html_video_1.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> <footer>简单教程,简单编程<br/>Copyright © 简单教程 www.twle.cn</footer>
运行结果: