案例:html/html5 案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html> 
2
<html> 
3
<body> 
4
5
<button onclick="enableAutoplay()" type="button">启用自动播放</button>
6
<button onclick="disableAutoplay()" type="button">禁用自动播放</button>
7
<button onclick="checkAutoplay()" type="button">检查自动播放状态</button>
8
<br>
9
<video id="video1" controls="controls">
10
  <source src="/example/html5/mov_bbb.mp4" type="video/mp4">
11
  <source src="/example/html5/mov_bbb.ogg" type="video/ogg">
12
  Your browser does not support HTML5 video.
13
</video>
14
15
<script>
16
myVid=document.getElementById("video1");
17
function enableAutoplay()
18
  { 
19
  myVid.autoplay=true;
20
  myVid.load();
21
  } 
22
function disableAutoplay()
23
  { 
24
  myVid.autoplay=false;
25
  myVid.load();
26
  } 
27
function checkAutoplay()
28
  { 
29
  alert(myVid.autoplay);
30
  } 
31
</script> 
32
33
<p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>
34
35
</body> 
36
</html>
37