我有一个网格视图,其中有一些链接可以重定向到vimeo视频。 我的问题是,无论何时首次安装应用程序,我都可以打开任何一个视频,但是当我回到gridview并在gridview中打开另一个链接时,我无法播放视频。它显示带有媒体控件的空白屏幕。 (注意:所有视频都在本机浏览器中完美运行)
webView=(WebView)findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
//webView.getSettings().setUserAgentString("Android Mozilla/5.0 AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
try {
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
if (ai != null) {
}
// System.out.println("flash player installed");
} catch (NameNotFoundException e) {
// System.out.println("flash player not installed");
}
if (Build.VERSION.SDK_INT < 8) {
webView.getSettings().setPluginsEnabled(true);
} else {
webView.getSettings().setPluginState(PluginState.ON);
// System.out.println("flash player enabled");
}
webView.setWebChromeClient(new WebChromeClient(){});
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains("vimeo.com")){
webView.loadUrl(url+"?player_id=player&title=0&byline=0&portrait=0&autoplay=1&api=1");
// System.out.println("override url is:::"+url);
}
}
webView.loadUrl(link);
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
webView.clearCache(true);
webView.clearHistory();
webView.clearView();
webView.goBack();
return true;
}
else{
webView.clearCache(true);
webView.clearHistory();
webView.clearView();
}
return super.onKeyDown(keyCode, event);
}