菜鸟教程 tryhtml5_av_prop_autoplay 在线代码实例

运行 保存 全屏 右侧展示 实时查看
主题:

 <button onclick="enableAutoplay()" type="button">Enable autoplay</button>
<button onclick="disableAutoplay()" type="button">Disable autoplay</button>
<button onclick="checkAutoplay()" type="button">Check autoplay status</button>
<br> 
<video id="video1" controls="controls">
  <source src="/statics/demosource/mov_bbb.mp4" type="video/mp4">
  <source src="/statics/demosource/mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<script>
myVid=document.getElementById("video1");
function enableAutoplay()
  { 
  myVid.autoplay=true;
  myVid.load();
  } 
function disableAutoplay()
  { 
  myVid.autoplay=false;
  myVid.load();
  } 
function checkAutoplay()
  { 
  alert(myVid.autoplay);
  } 
</script> 

<p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>