Android webview全屏视频

时间:2017-03-18 10:18:53

标签: javascript android webview android-videoview

我正在主持一个包含视频的网站,当我运行视频并点击全屏播放器按钮时,白色填充所有屏幕,但视频声音仍在播放

MainActivity.class

    mWebview = (WebView) findViewById(R.id.web);
    mWebview.setWebViewClient(new MyWebViewClient());
    mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript
    mWebview.getSettings().setDomStorageEnabled(true);
    mWebview.loadUrl("http://www.my-site.com/");
    mWebview.setWebChromeClient(new WebChromeClient() {

        public void onShowCustomView (View view, WebChromeClient.CustomViewCallback callback) {
            //do stuff
        }

        public void onHideCustomView () {
            //do stuff
        }

    });

MyWebViewClient.class

public class MyWebViewClient extends WebViewClient {
    public boolean shuldOverrideKeyEvent(WebView view, KeyEvent event) {

        return true;

    }


    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        try {
            String s = Uri.parse(url).getHost();
            if((s.contains("rulanerder"))|| (s.contains("disqus"))){
                view.stopLoading();
                view.goBack();
                return true; }
                     }

            // reject anything other

        } catch (Exception e) {
            Log.d("Error", "shouldOverrideUrlLoading");
        }
        return false;
    }
}

怎么能修好呢?

0 个答案:

没有答案