美文网首页Android开发Android技术知识Android开发
webview全屏播放视频之后加载弹框失败

webview全屏播放视频之后加载弹框失败

作者: ccccccal | 来源:发表于2018-06-20 16:32 被阅读11次

    webview播放视频之后,js弹框弹出失败,实际屏幕是暗色的,说明弹框已经弹出,怀疑是x5内核自己实现的全屏出现冲突,所以改为自己实现全屏播放处理

    播放视频建议使用腾讯x5内核

     /**
         * 视频全屏参数
         */
        protected static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        private Context mContext;
        private WebView mWebView;
        private LoadingDialog mLoadingDialog;
        private boolean mShowLoading = true;
        private IWebView.OnErrorListener mOnErrorListener;
        private OnPageListener mOnPageListener;
        private View customView;
        private FrameLayout fullscreenContainer;
        private IX5WebChromeClient.CustomViewCallback mCustomViewCallback;
        private FrameLayout mRoot;
    
    添加监听
     wv.setWebChromeClient(new WebChromeClient() {
     
                 //消失全屏时自己处理
                @Override
                public void onHideCustomView() {
    
                    KLog.d(Constant.TTAG, "处理全屏");
                    if (customView == null) {
                        return;
                    }
                    KLog.d(Constant.TTAG, "处理全屏");
                    FrameLayout decor = (FrameLayout) ((Activity) mContext).getWindow().getDecorView();
    
                    if (fullscreenContainer != null) {
                        fullscreenContainer.removeAllViews();
                        decor.removeView(fullscreenContainer);
                    }
                    fullscreenContainer = null;
                    customView = null;
                    mCustomViewCallback.onCustomViewHidden();
                    wv.setVisibility(View.VISIBLE);
                }
    
                //点击全屏时自己处理
                @Override
                public void onShowCustomView(View view, IX5WebChromeClient.CustomViewCallback customViewCallback) {
    
                    KLog.d(Constant.TTAG, "处理全屏");
    
                    if (customView != null) {
                        customViewCallback.onCustomViewHidden();
                        return;
                    }
    
                    FrameLayout decor = (FrameLayout) ((Activity) mContext).getWindow().getDecorView();
                    fullscreenContainer = new FullscreenHolder(mContext);
                    fullscreenContainer.addView(view, COVER_SCREEN_PARAMS);
                    decor.addView(fullscreenContainer, COVER_SCREEN_PARAMS);
                    customView = view;
                    mCustomViewCallback = customViewCallback;
                }
            });
    

    相关文章

      网友评论

      本文标题:webview全屏播放视频之后加载弹框失败

      本文链接:https://www.haomeiwen.com/subject/miyxyftx.html