I have the following code:
<video controls autoplay>
<source src="video/myVideo.mp4" type="video/mp4">
<source src="video/myVideo.webm" type="video/webm">
<source src="video/myVideo.ogv" type="video/ogg"> </video>
The video:
- displays well in both Chrome and Firefox
- In Firefox it plays as expected
- In Chrome it displays but not "autostarts". This is the problem.
- If I click on it (in Chrome) it plays ok
Tried
<video controls autoplay>...</video>
<video controls autoplay="1">...</video>
<video controls autoplay="autoplay">...</video>
Nothing worked in Chrome
Then I also tried changing the codec, as recommended in https://en.wikipedia.org/wiki/HTML5_video, but it also did not work:
<source src="movie.webm" type='video/webm; codecs="vp8.0, vorbis"'>
<source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"'>
<source src="movie.mp4" type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'>
So now I am at a dead end. Thanks for any pointers! Much appreciated.
</video>
):<script> document.getElementById('myvideo').play(); </script>
(don't forget to addid="myvideo"
to<video>
) – Sasindu Mendis Jan 13 '16 at 11:07play()
will be blocked by Chrome with a message in the console. – Pim Schaaf Jun 9 '18 at 5:47autoplay
attribute the video must have: a longer duration of 7 seconds, audio must be enabled, the tab must be active and the video must have a minimum size of 200x140px – gmarsi May 15 '19 at 21:14