WebView and HTML5 <video>

后端 未结 13 1927
面向向阳花
面向向阳花 2020-11-22 05:59

I\'m piecing together a cheapo app that amongst other things \"frames\" some of our websites... Pretty simple with the WebViewClient. until I hit the video.

13条回答
  •  半阙折子戏
    2020-11-22 06:15

    I used html5webview to solve this problem.Download and put it into your project then you can code just like this.

    private HTML5WebView mWebView;
    String url = "SOMEURL";
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mWebView = new HTML5WebView(this);
        if (savedInstanceState != null) {
                mWebView.restoreState(savedInstanceState);
        } else {
                mWebView.loadUrl(url);
        }
        setContentView(mWebView.getLayout());
    }
    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mWebView.saveState(outState);
    }
    

    To make the video rotatable, put android:configChanges="orientation" code into your Activity for example (Androidmanifest.xml)

    
    

    and override the onConfigurationChanged method.

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
    }
    

提交回复
热议问题