Playing HTML5 video on fullscreen in android webview

后端 未结 8 2205
迷失自我
迷失自我 2020-11-22 10:23

Well, I\'ve been searching few days already, how to display HTML5 video in full-screen mode on android WebView.

I managed to play HTML5 videos on my webview. Problem

8条回答
  •  旧时难觅i
    2020-11-22 10:42

    This is great. But if you want your website links to open in the app itself, add this code in your ExampleActivity.java:

    webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (Uri.parse(url).getHost().endsWith("yourwebsite.com")) {
                    return false;
                }
    
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                view.getContext().startActivity(intent);
                return true;
            }
        });
    

提交回复
热议问题