WebView setMediaPlaybackRequiresUserGesture(false) not working
<p>I am trying to make youtube videos autoplay in my webview. After going through many other pages, I figured these settings are necessary to make it work:</p>

<pre><code>    webView.setWebChromeClient(new WebChromeClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
</code></pre>

<p>Also, I have placed the following javascript code in the on pageFinished method:</p>

<pre><code>     webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (view.getProgress() == 100) {
                webView.loadUrl("javascript:document.getElementsByTagName('video')[0].play();"
                );
            }
        }
    });
</code></pre>

<p>Since the setMediaPlaybackRequiresUserGesture method was only introduced since API 17, I checked my test device specs and it is API 22 and android 5. Still this does not work. However, the Javascript code to start the video works only after the video has been played and paused at least once. Any Fixes? If this functionality can not be achieved using webview any alternate solutions are appreciated. </p>