i am not able to autoplay my video please help in this. my sdk version
android:minSdkVersion="14"
android:targetSdkVersion="19" />
i tried to put java script as specifed in code:
public void onPageFinished(WebView view, String url) { webView.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()"); }
});
i also try to append autoplay in URL but not working
//webView.loadUrl("http://youtube.com/embed/oY2OxMpCUVY?autoplay=1");
my web settings `
customViewContainer = (FrameLayout)rootView.findViewById(R.id.customViewContainer);
webView = (WebView) rootView.findViewById(R.id.HelpView_Video);
final GlobleClass globalVariable = (GlobleClass) GlobleClass.getContext();
mWebViewClient = new HelpWebViewClient();
webView.setWebViewClient(mWebViewClient);
mWebChromeClient = new myWebChromeClient();
webView.setWebChromeClient(mWebChromeClient);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(PluginState.ON);
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(); })()"); }
});
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
// webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
// }
webView.getSettings().setAppCacheEnabled(true);
//webView.getSettings().setBuiltInZoomControls(true);
// webView.getSettings().setSaveFormData(true);
//webView.loadUrl("http://youtube.com/embed/oY2OxMpCUVY?autoplay=1");
webView.loadUrl(globalVariable.getHelpVideoUrl());
`
https://www.youtube.com/embed/oY2OxMpCUVY?autoplay=1
add www to url. – Shackelford