各位大虾们,请不吝赐教!
页面中有2个普通按钮a,b。还有一个video标签,能成功播放出视频。。
我想要的效果是,点击a按钮,视频开始播放,点击b按钮,视频播放停止!!!
------解决方案--------------------
参见
<!DOCTYPE html>
<html>
<head>
<title>Simple JavaScript Controller</title>
<script type="text/javascript">
function playPause() {
var myVideo = document.getElementsByTagName('video')[0];
if (myVideo.paused)
myVideo.play();
else
myVideo.pause();
}
function makeBig() {
var myVideo = document.getElementsByTagName('video')[0];
myVideo.height = (myVideo.videoHeight * 2 ) ;
}
function makeNormal() {
var myVideo = document.getElementsByTagName('video')[0];
myVideo.height = (myVideo.videoHeight) ;
}
</script>
</head>
<body>
<div class="video-player" align="center">
<video src="myMovie.m4v" poster="poster.jpg" ></video>
<br>
<a href="javascript:playPause();">Play/Pause</a> <br>
<a href="javascript:makeBig();">2x Size</a>
------解决方案--------------------
<a href="javascript:makeNormal();">1x Size</a> <br>
</div>
</body>
</html>
------解决方案--------------------
var myVideo = document.getElementsByTagName('video')[0];
可以换成
document.getElementById('videoId');
<video src="myMovie.m4v" poster="poster.jpg" id="videoId"></video>
------解决方案--------------------
额。来晚了。。。
停止的话...
myVideo.currentTime = 0;
myVideo.pause();
------解决方案--------------------