欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-05-16 12:58:49
...

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);
}