html5 video播放/暂停开关

<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf8">
<head>
<title>html5 video播放/暂停开关</title>
</head>
<body>
<div style="text-align:center">
<button onclick="playPause()">播放/暂停</button>
<br />
<video id="video1" width="420">
<source src="http://www.runoob.com/try/demo_source/mov_bbb.mp4" type="video/mp4">
</video>

</div>

<script type="text/javascript">
var myVideo = document.getElementById("video1");
function playPause()
{
if(myVideo.paused)
myVideo.play();
else
myVideo.pause();
//myVideo.stop();
}

</script>
</body>
</html>

posted @ 2017-04-18 14:41  天--安静  阅读(35923)  评论(0编辑  收藏  举报