-4

I have video background on my web page, I want to stop this video for 3-4 sec and then continue (loop). How can I do this?

I have this code:

<video autoplay muted loop id="myVideo">
     <source src="video/Great_Coffee.mp4" type="video/mp4"> Your browser does not support HTML5 video.
</video>   
Reza Saadati
  • 5,018
  • 4
  • 27
  • 64
Danny
  • 31
  • 1
  • 7
  • 3
    Possible duplicate of [HTML5 – Zak Jul 18 '18 at 22:57

1 Answers1

0

Here is an example how you could do it with JavaScript:

const video = document.getElementById('myVideo');
video.currentTime = 5; // Video will jump to 5th second
video.pause();
setInterval(() => {
 video.play();
}, 3000);
<video id="myVideo" autoplay loop>
  <source src="https://www.w3schools.com/jsref/movie.mp4" type="video/mp4">
  <source src="https://www.w3schools.com/jsref/movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>
Reza Saadati
  • 5,018
  • 4
  • 27
  • 64
  • and what about if i want to be video stoped at another picture a mean in the middle on video – Danny Jul 18 '18 at 23:17
  • @Danny I have updated my answer. You could use `video.currentTime = 5;` to start the video after 5 seconds. You may see the picture of the 5th second when the video is paused. – Reza Saadati Jul 18 '18 at 23:24