I tried the following:
WebView wv = (WebView) findViewById(R.id.webView1);
String playVideo= "<html><body><iframe width='200' height='143' src='http://www.youtube.com/embed/JW5meKfy3fY' frameborder='0' allowfullscreen></iframe></body></html>";
wv.getSettings().setPluginsEnabled(true);
wv.getSettings().setAllowFileAccess(true);
wv.getSettings().setPluginState(PluginState.ON);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadData(playVideo, "text/html", "utf-8");
I only see thumbnail and then when I click on it the frame turns to black and does not load the video. I'm targeting API 15 and I have internet permission. How could I run the html5 youtube iframe video in Android webview?
You have to put this in your manifest
<application android:hardwareAccelerated="true" ...>
On Android 3.0++, you must activate Hardware acceleration if your android:targetSdkVersion is lower than 11. And, you must add this line:
wv.setWebChromeClient(new WebChromeClient());
You are running on 2.3(GingerBread) or 4.0(ice Cream)?
If you are running on Ice Cream, you need to enable hardware acceleration.
If you are running on GingerBread, please refer to: WebView and HTML5 <video>
Hope this helpgul.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With