Android youtube in web view

I have Webviewto display some html data in my application. I am using the following code.

WebView featureview = (WebView) findViewById(R.id.featureview);
WebSettings webSettings = featureview.getSettings(); 
webSettings.setJavaScriptEnabled(true); 
featureview.loadData(featureDescription, "text/html", "utf-8");

Some of the html data has embedded video from youtube using type code <iframe height='390' frameborder='0' width='640' allowfullscreen='' src='http://www.youtube.com/embed/8xgkw67o0Gc' title='YouTube video player'></iframe>. But he gives a black screen. what is the problem in the code? Here, I like to add that I installed a flash player, and I'm trying to use it on an Android 2.2 device.

+5
source share
2 answers

Try:

webView.getSettings().setPluginsEnabled(true);

Or the not obsolete equivalent:

webview.getSettings().setPluginState(WebSettings.PluginState.ON);
+1
source

Enable javascript

 myWebView = (WebView) findViewById(R.id.webview); 
 WebSettings webSettings = myWebView.getSettings(); 
 webSettings.setJavaScriptEnabled(true); 
 myWebView.loadUrl("http://www.youtube.com"); 

see links

http://www.anddev.org/novice-tutorials-f8/play-youtube-videos-with-youtube-app-from-webview-t50422.html

0
source

All Articles