HTML5 <Video> “Loop” with a gap or delay of few seconds

前端 未结 1 1090
梦毁少年i
梦毁少年i 2020-12-11 04:24

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

相关标签:
1条回答
  • 2020-12-11 04:57

    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

    0 讨论(0)
提交回复
热议问题