2011-07-29 54 views
5

我已經使用Webview在我的應用中顯示一些html數據。我正在使用下面的代碼。webview中的Android youtube

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

一些HTML數據的已使用類似<iframe height='390' frameborder='0' width='640' allowfullscreen='' src='http://www.youtube.com/embed/8xgkw67o0Gc' title='YouTube video player'></iframe>代碼嵌入視頻來自YouTube。但它給黑屏。代碼中有什麼問題?在這裏,我想補充我已經安裝了Flash播放器,並且正在嘗試使用Android 2.2設備。

+0

您是否設法解決它? –

+0

我也想知道你是否已經解決了這個問題,以及如何解決這個問題? –

+0

查看我的答案在這裏http://stackoverflow.com/a/24592012/2371425 – Sakiboy

回答

0

啓用JavaScript

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

看到這個鏈接

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

+0

我不想打開任何YouTube網址,我只是想打開一個嵌入在HTML內容的播放。但是我已經添加了setJavaScriptEnabled,但它給出了相同的結果。 –

+0

http://stackoverflow.com/a/24592012/2371425看到這個答案 – Sakiboy

1

嘗試:

webView.getSettings().setPluginsEnabled(true); 

或非棄用相當於:

webview.getSettings().setPluginState(WebSettings.PluginState.ON); 
+0

這對我有效。 @ dev-android應該試試這個,如果它解決了問題,就接受它。 –

+0

@Alexlex這不起作用。 –

+0

這在大多數情況下不起作用。看看我的答案在這裏:http://stackoverflow.com/a/24592012/2371425 – Sakiboy

相關問題