3

First, please consider apologies if the question is trivial. I tried to search but did not find a satisfactory answer.

I am trying to get the autoplay of html5 video working in android browsers. I read in other posts that autoplay for html5 videos is disabled in Android. However I am able to get it working for firefox and opera. I used javascript play(). But this does not work in the chrome and default android browser.

In chrome unless you touch(= click) the 'play' button the video will not play. So can this 'touch' or 'mouse click' event be virtually triggered on 'window load' so that autoplay works.

If yes can you please show the implementation of it?

Thanks.

Raghavendra N
  • 1,359
  • 1
  • 18
  • 36
  • possible duplicate of [How to autoplay HTML5 mp4 video on Android?](http://stackoverflow.com/questions/9075520/how-to-autoplay-html5-mp4-video-on-android) – CodingIntrigue Sep 04 '14 at 11:24
  • I've got the video autoplay in android. But i want it specifically for chrome browser in android. – Raghavendra N Sep 04 '14 at 11:58

2 Answers2

3

In their infinite wisdom, Google has decided not to enable autoplay on Chrome for Android if the video is not muted. Their reasoning is apparently because it is resource/bandwith costly and "users" did not like it.

In other words: It will work on Chrome desktop versions and such, but when you have not added the keyword "muted" to the tag, it will not autoplay on an Android device.

<video id="player" class="player" controls autoplay muted>

Isn't that swell?

Read more here: https://developers.google.com/web/updates/2016/07/autoplay

Fedor Alexander Steeman
  • 1,561
  • 3
  • 23
  • 47
1

Could you not do something like this:

function playOnLoad() {
    var v = document.getElementsByTagName("video")[0];
    v.play();
}

<body onload="playOnLoad();">
...
</body>

Got the code from here: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video#Controlling_media_playback

NMunro
  • 890
  • 5
  • 20
  • This works on all browsers except chrome in android. – Raghavendra N Sep 04 '14 at 11:44
  • Does it work with other browsers in general on Android or is it specifically the Chrome browser for android that disallows this? Just looking for clarification that it's an Android or Chrome for Android that's the issue. – NMunro Sep 04 '14 at 11:47
  • It is working on all other browsers in android. But not in chrome. It is the issue with chrome. My Android version: 4.1.1. – Raghavendra N Sep 04 '14 at 11:53
  • Can you have other events happen on the body 'onLoad' event? I'm at work and I use a nexus device so it's always the latest... – NMunro Sep 04 '14 at 13:02