標籤:
全屏問題,可以參考 http://bbs.csdn.net/topics/390839259,點擊
webView = (WebView) findViewById(R.id.webView);videoview = (FrameLayout) findViewById(R.id.video_view);chromeClient = new WebChromeClient() {// 播放網路視頻時全屏會被調用的方法@Overridepublic void onShowCustomView(View view, CustomViewCallback callback) {if (islandport) {return;}setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);// if (myCallback != null) {// myCallback.onCustomViewHidden();// myCallback = null;// return;// }webView.setVisibility(View.GONE);if (myView != null) {callback.onCustomViewHidden();return;}videoview.addView(view);myView = view;myCallback = callback;videoview.setVisibility(View.VISIBLE);}private View myView = null;private CustomViewCallback myCallback = null;public void onHideCustomView() {if (myView == null) {return;} else {// if (myCallback != null) {// myCallback.onCustomViewHidden();// myCallback = null;// }setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);myView.setVisibility(View.GONE);videoview.removeView(myView);videoview.setVisibility(View.GONE);webView.setVisibility(View.VISIBLE);myCallback.onCustomViewHidden();myView = null;}}@Overridepublic void onReceivedTitle(WebView view, String title) {// TODO Auto-generated method stubsuper.onReceivedTitle(view, title);if (showtitle) {setTitle(title);}}};WebSettings setting = webView.getSettings();setting.setBuiltInZoomControls(false);setting.setUseWideViewPort(true);setting.setLoadWithOverviewMode(true);setting.setCacheMode(WebSettings.LOAD_NO_CACHE);setting.setPluginState(PluginState.ON_DEMAND);// setting.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); //支援內容重新布局setting.setJavaScriptEnabled(true);setting.setJavaScriptCanOpenWindowsAutomatically(true);
注意旋轉螢幕
android:configChanges="orientation|keyboardHidden|screenSize"
/** * 當橫豎屏切換時會調用該方法 * * @author */@Overridepublic void onConfigurationChanged(Configuration newConfig) {super.onConfigurationChanged(newConfig);if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {islandport = true;} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {islandport = false;}}
而關閉聲音,現在可以參考這裡http://blog.csdn.net/cuizm/article/details/42342505
添加cookies http://blog.csdn.net/encienqi/article/details/7912733
不建議使用cookie,真的很難用,瀏覽器緩衝就是一個頭疼的問題
Android webview 退出時關閉聲音 4.視頻全屏 添加cookie