I use android webview in my app for display video from youtube it\'s work well.
But i want it\'s auto play.
This is my activity i append \"?autoplay=
Check out this question. There are a couple of suggestions that may work for you, however the person who asked that question didn't say if it worked for them or not.
Most of what I'm reading is saying that most mobile platforms block autoplay to avoid poor user experience.
You can try this javascript code below:
var myvideo = document.getElementsByTagName('video')[0]; myvideo.play();
For Android 4.2.2+ try adding this in your native code:
WebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
Also check out this page. Which adds the code below to autoplay the video:
webview.setWebViewClient(new WebViewClient() {
// autoplay when finished loading via javascript injection
public void onPageFinished(WebView view, String url) { webview.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()"); }
});
webview.setWebChromeClient(new WebChromeClient());
webview.loadUrl("http://html5demos.com/video");
}