我正在尝试按照here列出的指导,以便从嵌入我应用中的ustream播放视频。提供的答案here表示它应该在4.4中适用于我但在我的测试Droid Max运行4.4.4时没有播放任何内容
我已经查看了在线发布的几个答案,但所有这些答案都使用了已弃用的代码或不再有效。我已启用硬件加速并在java中使用以下代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.webcontent);
myWebView.setWebChromeClient(new WebChromeClient()); // Set Chrome Client
myWebView.setWebViewClient(new WebViewClient()); //Set Webview Client
myWebView.getSettings().setJavaScriptEnabled(true); // enable javascript
myWebView.loadUrl("file:///android_asset/Welcome.html");
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
}
答案 0 :(得分:0)
希望这对你有用
WebView wb;
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact);
wb=(WebView)findViewById(R.id.webView1);
wb.getSettings().setJavaScriptEnabled(true);
wb.getSettings().setLoadWithOverviewMode(true);
wb.getSettings().setUseWideViewPort(true);
wb.getSettings().setBuiltInZoomControls(true);
wb.getSettings().setPluginState(WebSettings.PluginState.ON);
// wb.getSettings().setPluginsEnabled(true);
wb.setWebViewClient(new HelloWebViewClient());
wb.loadUrl("https://www.youtube.com/results?search_query=playlist");
}
}