ZFPlayer player calls addPlayerViewToSmallFloatView to open a small window playback style error and cannot close the processing

ZFPLayer is a powerful open source video player. When the list playback slides beyond the scope of the current video, addPlayerViewToSmallFloatView is called to open the small window playback (similar to picture-in-picture, but without its powerful and friendly interaction). The layout is wrong and the close button in the upper right corner is also disabled. It cannot be closed, and the confusing reference picture is as follows:

1. Analysis of the causes of style confusion:
self.currentPlayerManager.view.autoresizingMask responds dynamically based on the parent view, and the current video playback object is changed in methods such as addPlayerViewToSmallFloatView and addPlayerViewToContainerView. (self.currentPlayerManager.view) were added to self.smallFloatView, self.containerView and other views without removing the previous addition
Solution:
Add (i.e. Remove [self.currentPlayerManager.view removeFromSuperview] before calling: addSubview:self.currentPlayerManager.view)

2. Closing the upper right corner of the small window playback is invalid
Solution: Implement the floatControlView.closeClickCallback callback method of the ZFPlayerControlView object, and call self.playManager.stop() in the method to close it

private lazy var controlView:ZFPlayerControlView = {
        let _cv = ZFPlayerControlView.init()
        
        //全屏模式
        _cv.fullScreenMode = .landscape
        _cv.landScapeControlView.fullScreenMode = .landscape
        
        //显示控制层
        _cv.prepareShowControlView = true
        
        //不隐藏控制视图
        _cv.portraitControlView.isHidden = false
        
        //显示加载视图
        _cv.prepareShowLoading = true
        
        //退出全屏被点击(全屏返回按钮被点击)
        _cv.backBtnClickCallback = {[weak self] in
            guard let self = self else { return }
            self.data?.isAutorotate = false
            self.data?.faceOrientation = .portrait
            
            self.player.rotate(to: .portrait, animated: false) {
                print("已返回小屏")
            }
            
            //退出全屏
            self.player.enterFullScreen(false, animated: false)
            
            //恢复原始状态
            if self.player.isSmallFloatViewShow || self.isSmallView {
                self.player.addPlayerViewToSmallFloatView()
            }
            else{
                self.player.addPlayerView(toContainerView: self.contentView)
            }
        }
        
        /// 小窗播放关闭事件
        _cv.floatControlView.closeClickCallback = {[weak self] in
            guard let self = self else { return }
            self.player.stopCurrentPlayingView()
            self.playManager.stop()
        }
        
        return _cv
    }()

The final effect after processing is as follows:

Guess you like

Origin blog.csdn.net/yimiyuangguang/article/details/124349066