Android Crosswalk play video tag full screen problem solved

1. Process the interception point by configuring the full-screen event of XWalkView

 

webView.setUIClient(new InjectedXWalkUIClient(webView, mJsCallJava, listener));

public class InjectedXWalkUIClient extends XWalkUIClient {
......
@Override
    public void onFullscreenToggled(XWalkView view, boolean enterFullscreen) {
        super.onFullscreenToggled(view, enterFullscreen);
        Log.e(TAG, "onFullscreenToggled: "+enterFullscreen);
// registered callback listener interface
        if (this.listener != null) {
            this.listener.onFullscreenToggled(view,enterFullscreen);
        }
    }
......
}

 

 

2. Process in listener's onFullscreenToggled, core code

 

this.isFullScreen = enterFullscreen;
if (enterFullscreen) {
    // Set whether the title bar is visible
    this.common_top_layout.setVisibility(GONE);
    // landscape
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    // full screen settings
    WindowManager.LayoutParams attrs = getWindow().getAttributes();
    attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    this.getWindow().setAttributes(attrs);
} else {
    // Set the title bar to be visible
    this.common_top_layout.setVisibility(View.VISIBLE);
    // vertical screen
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    // cancel full screen
    WindowManager.LayoutParams attrs = getWindow().getAttributes();
    attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
    this.getWindow().setAttributes(attrs);
}

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326195283&siteId=291194637