2

In my project I need to autoplay a HTML5 video in the browser when the page is loaded. I have tried a several javascript solutions but none of them work.

I read that the android browser blocks autoplay to prevent downloading a lot of data. Can be this blocking feature be turned off in browser/chrome/operation system settings?

I cannot find any working solution for how to enable autoplay. I have searched plenty of stackoverflow posts and many other sites ...

I am using android 4.1.1.

  • 2
    To close voters: this question seems legit. Though it's the dev asking, the question itself is not about development, but about browser/system settings, and thus of interest to "normal users" as well (as long as Peter is not asking about doing this from his app in a programatical way, of course). – Izzy Dec 17 '13 at 9:31
4

Bad news it seems. Bug report on Google code

The most relevant post is this:

Yes. It is as design. "autoplay" is disabled for Chrome for Android

It seems that Android 4+ changed the requirements for the play() method to require user interaction.

Article on this issue

It's worth nothing that many comments refer to getting it to work with a hack/workaround, only to find it works on some devices and not others. Stack Overflow question on the coding side. In this example the answer mentions:

sample code that works on HTC and Samsung, but not Galaxy Nexus 4.1 (requires user interaction to play)

This seems to suggest, even with a workaround you have no guarantee it will actually work on a particular device / version of Android.

Apple have imposed the same restriction in Safari and iOS in general.

3

This can be turned on/off in Chrome using flags. This is on the user end though and cannot be change in the browser from a website or app.

You can also do this in your own app using the api for webview or websettings and make "getMediaPlaybackRequiresUserGesture(false)" it is by default set to "(true)"

http://developer.android.com/reference/android/webkit/WebSettings.html

In chrome you must go to chrome://flags then go down about 3 screens to

Disable gesture requirement for media playback. Android

Disable user gesture requirement for playing media elements. Activating this will allow autoplay to work.

disable-gesture-requirement-for-media-playback

Enable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.