Play infinitely looping video on-load in HTML5


The <video> tag specifies video. Currently, there are 3 supported video formats for the <video> element that are MP4, WebM, and Ogg. Autoplay is used to start the video when the video and page loads.

The loop attribute is a boolean attribute. When present, it specifies that the video will start over again, every time it is finished.

The loop attribute should do it.

<video width="600" height="500" autoplay loop>
   <source src="movie.mp4" type="video/mp4" />
   <source src="movie.ogg" type="video/ogg" />
   Your browser does not support the video element.
</video>

If you have a problem with the loop attribute, listen to the videoEnd event. After that call the play() method when it fires.

Updated on: 30-Jul-2019

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements