Reputation: 2032
Struggling to achieve Youtube Video Auto play within android WebView, I have seen several threads and forums listing following suggestion which DO NOT WORK.
I have tried the following, with no luck:
settings.setMediaPlaybackRequiresUserGesture(false);
Adding javascript snip like this:
webView.setWebViewClient(new MyWebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (view.getProgress() == 100) {
webView.loadUrl("javascript:document.getElementsByTagName('video')[0].play();"
);
}
}
});
3 . Adding &autoplay=1
to URL
I am tested for all the above methods in API 18 and none of the above methods worked. This being a very important Feature for my App, please provide a working solution for this.
Upvotes: 1
Views: 910