Reputation: 10341
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?
Upvotes: 15
Views: 10538
Reputation: 1
iframe works for me. But, I found out, when using Android Emulator on Windows for you tube video, the internet on Emulator will stop working after a while and I need to restart the emulator to get internet access. This has never happened on a Android Phone.
So, just check it on your browser to make sure there is internet connection.
Upvotes: 0
Reputation: 1639
You have to put this in your manifest
<application android:hardwareAccelerated="true" ...>
Upvotes: 4
Reputation: 2014
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());
Upvotes: 2
Reputation: 1238
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.
Upvotes: 1