全屏问题,可以参考 http://bbs.csdn.net/topics/390839259,点击
webView = (WebView) findViewById(R.id.webView); videoview = (FrameLayout) findViewById(R.id.video_view); chromeClient = new WebChromeClient() { // 播放网络视频时全屏会被调用的方法 @Override public 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; } } @Override public void onReceivedTitle(WebView view, String title) { // TODO Auto-generated method stub super.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 */ @Override public 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,真的很难用,浏览器缓存就是一个头疼的问题