YouTube iframe embeds cannot autoplay on Android

I’m using a webView in my Android app to load YouTube iframe player and auto play videos. It works fine on Samsung Galaxy S2 & S3, but when runs on Samsung Galaxy S4, it always results in gray screen when trying to auto play.

On Galaxy S4, it works fine without autoplay, needs user action(click) to start playing
(Nothing happened if adding “autoplay:1” in playerVars).

  • Android Microsoft Office Library (.doc, .docx, .xls, .ppt, etc.)
  • Getting error: “bad read of inttemp!” when training a new font in Tesseract 2
  • Getting imageview size for Bitmap creation
  • LoaderManager with multiple loaders: how to get the right cursorloader
  • Android - updating notification progress bar, properly
  • Android: Cancel Async Task
  • I tried to call player.playVideo() in onPlayerReady(), it resulted in this gray screen:

    enter image description here

    The LogCat also shows a weird error message:

    E/IMGSRV(17004): :0: GetPTLAFormat: Invalid format

    when failed to autoplay. I don’t know what this message is about; I’ve googled it and found nothing.

    Here’s the Android code of WebView:

    WebView wv = (WebView) findViewById(;
    WebSettings websettings = wv.getSettings();
    wv.setWebViewClient(new WebViewClient());
    wv.setWebChromeClient(new WebChromeClient());
    wv.setPadding(0, 0, 0, 0);

    Is this a known issue or if there’s any solution to autoplay the video? Thanks!

  • how to get the source of ImageView in order to change it?
  • How to Undeprecate Facebook Code
  • Can't Play video in android uploded from iphone
  • Android In-App Billing error You need to sign into your google account
  • Android adb devices unauthorized
  • Android soft Keyboard not open in webView`
  • 3 Solutions collect form web for “YouTube iframe embeds cannot autoplay on Android”

    I think disabling autoplay is becoming a “standard”.

    By the way, you could try this


    As the link is dead, I found it in

    How to “autoplay” HTML5 video on Android
    Written by Mathias Desloges in Labs on 19/05/11

    Have you ever try to play with the new HTML5 video tag on an Android device?
    We have and here is an stange issue which we faced.
    Let’s set up the context, we want our video starts playing just after the page load complete.
    According to the HTML5 specification, we should use the “autoplay” attribute, but it has no effect in Android. So we tried with a little script tha call the play function after the page has loaded:

    function callback () { document.querySelector('video').play(); } 
    window.addEventListener("load", callback, false);

    This reproduces well the behavior of the “autoplay” attribute on a
    classic desktop browser, but on an Android browser it fails.
    tried to attach the previously defined “callback()” function to a
    click event on a arbitrary node, and the video starts playing well “on
    click” (normal behavior). And while continue working on the page html
    code, we found the solution!

    Don’t ask me why, but after adding the “poster” attribute it works!

    I believe this is a symptom of the OS manufacturers becoming more restrictive in not letting videos autoplay due to bandwidth concerns. This has been an issue on iOS for some time where any JavaScript call to play() will fail unless the user has performed some action like a click first.
    That is likely what is going on in your case.

    As answered here I believe it’s not just restricting auto-play but any auto events. For me it was a page transition in jquerymobile which was triggered when Cordova had loaded. I switched it to being triggered by a click even and this solved the problem.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.