Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
143
rated 0 times [  145] [ 2]  / answers: 1 / hits: 16110  / 9 Years ago, mon, august 17, 2015, 12:00:00

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>


Please refer the link to see the Video tag code > http://jsfiddle.net/nrf5fbh8/1/



Please suggest!






Updated my code, my video tag DO NOT have controls.



Thanks!


More From » jquery

 Answers
-2

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);
}


Updated Fiddle


[#65386] Friday, August 14, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
louiemarvinm

Total Points: 473
Total Questions: 103
Total Answers: 94

Location: Samoa
Member since Mon, Nov 8, 2021
3 Years ago
;