Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome does not autoplay HTML5 video on mobile

I have problems to get a video to play on my Android mobile in the latest version of Chrome. In other browsers like the Puffin browser the video is playing. For test purposes I tried all common formats:

mp4
<br />
<video autoplay="autoplay" loop="loop" onended="this.play()"><source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4" /></video>
<br />
webm
<br />
<video autoplay="autoplay" loop="loop" onended="this.play()"><source src="http://clips.vorwaerts-gmbh.de/VfE.webm" type="video/webm" /></video>
<br />
ogg
<br />
<video autoplay="autoplay" loop="loop" onended="this.play()"><source src="http://clips.vorwaerts-gmbh.de/VfE.ogv" type="video/ogg" /></video>

https://codepen.io/anon/pen/ozpVNP

QR Code for CodePen

Preview on mobile

According to Mozilla the first video, that is H.264 + AAC in MP4 should play. I also take this article in account and tried to play the videos by JavaScript additionally as well as tried to remove the type attribute on the first video tag without success.

How can I get it work in Chrome on Mobile?

like image 453
Martin Braun Avatar asked Oct 06 '16 09:10

Martin Braun


People also ask

How do I autoplay a video in HTML mobile?

As for Mobile Chrome (Android): 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().

Does HTML5 video work on mobile?

What Is the HTML5 Video Tag? The `<video>` element is simply a tag used to embed video content in an HTML document. As of 2022 it is excellently supported across all modern browsers (both mobile and desktop), except for Opera Mini.

Why do mobile phones usually ignore auto play on video elements HTML?

Autoplay Policies for Mobile Devices Most mobile browsers will disable auto-playing videos in order to preserve bandwidth & battery and to prevent performance issues. Mobile visitors will still be able to view the video through the embedded player's Play button.

Can you autoplay videos on mobile?

Mobile device settings can block autoplay Most mobile devices, including Apple iPhones, Apple iPads and many Android and Microsoft devices do not support the video autoplay feature so your video will not play automatically if a visitor is on one of these devices.


2 Answers

<video autoplay loop autobuffer muted playsinline>
     <source src="video/video-hat.mp4" type="video/mp4">
</video>
like image 174

The problem is that Google want that users initiate by themselves any media, so If you debug your device chrome browser, you will get the warning "Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture." So that means you need to attach the video initialization, for example, with a click event

like image 36
Jaco Avatar answered Oct 20 '22 15:10

Jaco