HTML 5 Autoplay Google Chrome Android Not Playing

Francisco picture Francisco · Oct 23, 2013 · Viewed 17.4k times · Source

I'm trying to play automatically a video when the user open the page on browser. On my laptop autoplay works on all browsers, but on android it doesn´t work on Google Chrome and in Iphone it doesn't works in safari. I already did a search and google chrome in android doesn't support html5 video tag so i used some javascript but it doesn't work too. Why? What should i do? Here's my code

<video id="video" autoplay autobuffer controls="controls" allowFullScreen >
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm" webView.mediaPlaybackRequiresUserAction = NO;>
<source src="video.theora.ogv" type="video/ogg">
<source src="video.flv" type="video/flv">
<source src="video.vob" type="video/vob">
<source src="video.mov" type="video/mov">
</video>    
<script type="text/javascript">
var video = document.getElementById('video');                           video.addEventListener('video',function(){
video.play();
});

                                video.addEventListener("domready", function(){                                              video.play();
});

                                video.addEventListener("ended", function(){ 
window.location = "http://www.google.com"
});
</script>

Answer

manoj picture manoj · Jan 20, 2017

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 and muted are set, and playback of muted videos can be initiated progamatically with play(). Previously, playback on mobile had to be initiated by a user gesture, regardless of the muted state.

<video autoplay muted>
  <source src="video.webm" type="video/webm" />
  <source src="video.mp4" type="video/mp4" />
</video>