HTML5<视频> "环路"差距或延迟几秒钟 [英] HTML5 <Video> "Loop" with a gap or delay of few seconds
问题描述
我正在使用HTML 5视频标签在我的页面上显示带有循环功能或属性的视频。
I am using the HTML 5 "Video" tag to show the video on my page with the "Loop" feature or attribute.
我们有什么方法可以使用循环属性在视频之间添加延迟或差距?
Is there any way we can add a delay or gap between video using the "Loop" attribute??
<video id="myVideo" autoplay loop src="http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4">
请参阅链接以查看视频代码> http://jsfiddle.net/nrf5fbh8/1/
Please refer the link to see the Video tag code > "http://jsfiddle.net/nrf5fbh8/1/"
请建议!
更新了我的代码,我的视频代码没有控件。
谢谢!
推荐答案
扩展我的评论,基本上不是使用循环属性,您可以设置一个监听器,并在监听器中放置一个函数,以便在视频结束后的指定时间(以毫秒为单位)后重放视频。 JS看起来像这样:
Expanding on my comment above, basically instead of using the loop attribute you can set up a listener and place a function within the listener to replay the video after a specified amount of time(in milliseconds) once the video has ended. The JS would look like this:
document.getElementById('myVideo').addEventListener('ended',myHandler,false);
function myHandler(e) {
console.log('ended');
setTimeout(function(){
document.getElementById('myVideo').play();
}, 5000);
}
这篇关于HTML5<视频> "环路"差距或延迟几秒钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!