Chrome does not allow autoplay if the video is not muted. So to autoplay video you need to set both autoplay and muted attribute.
Hold the pointer to the right of Auto-Play, then click the pop-up menu and choose an option: Allow All Auto-Play: Lets videos on this website play automatically. Stop Media with Sound: Blocks autoplay for videos that contain audio, but allows other videos to play.
Step 1 - Open the Google Chrome browser. Step 3 - Click the Autoplay policy drop-down and select "No user gesture is required." This will make it so that you don't need to intereact with the page in order for the video or audio to start playing automatically. Step 4 - Restart the browser.
The best fix I could get was adding this code just after the </video>
<script>
document.getElementById('vid').play();
</script>
...not pretty but somehow works.
UPDATE
Recently many browsers can only autoplay the videos with sound off, so you'll need to add muted
attribute to the video tag too
<video autoplay muted>
...
</video>
After using jQuery play()
or DOM maniupulation as suggested by the other answers, it was not still working (Video wasn't autoplaying) in the Chrome for Android (Version 56.0).
As per this post in developers.google.com, From Chrome 53, the autoplay option is respected by the browser, if the video is muted.
So using autoplay muted
attributes in video tag enables the video to be autoplayed in Chrome browsers from version 53.
Excerpt from the above link:
Muted autoplay for video is supported by Chrome for Android as of version 53. Playback will start automatically for a video element once it comes into view if both
autoplay
andmuted
are set[...]<video autoplay muted> <source src="video.webm" type="video/webm" /> <source src="video.mp4" type="video/mp4" /> </video>
- Muted autoplay is supported by Safari on iOS 10 and later.
- Autoplay, whether muted or not, is already supported on Android by Firefox and UC Browser: they do not block any kind of autoplay.
Google just changed their policy for autoplay videos, it has to be
muted
You can check here
so just add muted
<video height="256" loop="true" autoplay="autoplay" controls="controls" id="vid" muted>
<source type="video/mp4" src="video_file.mp4"></source>
<source type="video/ogg" src="video_file.ogg"></source>
</video>
It happens that Safari and Chrome on Desktop do not like DOM manipulation around the video tag. They will not fire the play order when the autoplay attribute is set even if the canplaythrough event has fired when the DOM around the video tag has changed after initial page load. Basically I had the same issue until I deleted a .wrap() jQuery around the video tag and after that it autoplayed as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With