如何在用户开始视频然后自动播放后启动html5视频暂停? [英] How do I Start html5 video paused then after user begins video then autoplay?
本文介绍了如何在用户开始视频然后自动播放后启动html5视频暂停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个html5视频播放列表。当页面首次加载时我希望视频暂停,因此用户可以选择开始自动播放序列。
代码:
I''ve created a html5 video playlist. When the page first loads I want the video to be paused, so the user has the choice to begin the autoplay sequence.
Code:
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
var videoPlayer= document.getElementById('video');
videoPlayer.addEventListener('ended', function(){
this.pause();
this.src = "http://www.mp4point.com/downloads/8feeca1a540b.mp4";
}, false);
}//
</script>
</head>
<body>
<video id="video" src="http://media.w3.org/2010/05/sintel/trailer.mp4" autoplay autobuffer controls />
</body>
</html>
< br $>
Jsfiddle: http://jsfiddle.net/3uRq6/7/
推荐答案
您应该从body标签中删除autoplay,以便在加载过程中不播放。
You should remove "autoplay" from body tag to not play during load.
这篇关于如何在用户开始视频然后自动播放后启动html5视频暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文