0

I have a copy of a mp4 video which I want to show on my website and I want to know how is it possible with javascript to autoplay and loop for ever the video. I want to make it compatible with all browsers. I want to load the video on load of the page with js

Thank you.

manolaros
  • 11
  • 1
  • 5
  • 3
    Possible duplicate of [Play infinitely looping video on-load in HTML5](https://stackoverflow.com/questions/10377453/play-infinitely-looping-video-on-load-in-html5) – Steven Stark Mar 07 '19 at 20:37

2 Answers2

0
<video autoplay loop>
  <source src="movie.mp4" type="video/mp4" />
  <source src="movie.ogg" type="video/ogg" />
</video>

You mean this?

cb64
  • 825
  • 8
  • 16
0

You’ll need to mute the video (adding the muted attribute on the <video> tag) as videos with sound don’t autoplay in all browsers. Then also add the attributes autoplay and playsinline. Also you can use the videoEnd event and call play() to ensure it loops.

jpescada
  • 11
  • 3