0
我讀了幾個關於我的問題的任務,但我不知道該怎麼走。 我有youtube視頻嵌入webview。 當我點擊,我有聲音,但沒有視頻。 我想補充:android應用程序:在webview上播放youtube視頻嵌入
content.setWebChromeClient(new WebChromeClient() {});
但它不起作用!
這是我的WebView:
content = new WebView(this);
content.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT,
Gravity.CENTER
));
content.setHorizontalScrollBarEnabled(false);
content.setVerticalScrollBarEnabled(false);
content.getSettings().setJavaScriptEnabled(true);
content.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
content.getSettings().setBuiltInZoomControls(false);
content.getSettings().setSupportZoom(true);
content.getSettings().setUseWideViewPort(true);
content.getSettings().setPluginsEnabled(true);
content.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
content.getSettings().setSavePassword(true);
content.getSettings().setSaveFormData(true);
content.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
content.setWebChromeClient(new WebChromeClient() {
});
content.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
close();
}
@Override
public void onPageFinished(WebView view, String url) {
view.setVisibility(View.VISIBLE);
showLayout();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri overrideUrl = null;
Uri currentUrl = Uri.parse(url);
if (data.getFormat().equals(Format.IMAGE)) {
...
}
if (overrideUrl != null) {
Intent browser = new Intent(Intent.ACTION_VIEW);
browser.setData(overrideUrl);
startActivity(browser);
return false;
}
view.loadUrl(url);
return true;
}
});
layout.addView(content);
content.loadData(data.getHtml(), "text/html", "UTF-8");
我不能,因爲我與API級別4 – floflo41
和工作?問題是什麼 ? 我想你使用的是Android 4.0+以上的設備來測試你的應用程序,在此基礎上,你需要使用硬件加速啓用。 在您的清單中,設置 「 」 並將您的構建projet設置爲android api 16 –
Pauland
因爲我有這個當我構建m項目時: Android資源錯誤:找不到包含'android'屬性'hardwareAccelerated'的資源標識符 – floflo41