Android Crosswalk播放video标签全屏问题解决

阅读更多

1,通过配置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);
// 注册的回调监听接口
        if (this.listener != null) {
            this.listener.onFullscreenToggled(view,enterFullscreen);
        }
    }
......
}

 

 

2,在listener的onFullscreenToggled中进行处理,核心代码

 

this.isFullScreen = enterFullscreen;
if (enterFullscreen) {
    // 设置标题栏是否可见
    this.common_top_layout.setVisibility(GONE);
    // 横屏
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    // 全屏设置
    WindowManager.LayoutParams attrs = getWindow().getAttributes();
    attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    this.getWindow().setAttributes(attrs);
} else {
    // 设置标题栏可见
    this.common_top_layout.setVisibility(View.VISIBLE);
    // 竖屏
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    // 取消全屏
    WindowManager.LayoutParams attrs = getWindow().getAttributes();
    attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
    this.getWindow().setAttributes(attrs);
}

 

 

你可能感兴趣的:(安卓,全屏,video标签,H5视频播放)