BMPlayer icon indicating copy to clipboard operation
BMPlayer copied to clipboard

Overlay disappears after video is done and it doesn't appear again on tap

Open repixels opened this issue 8 years ago • 4 comments

BMPlayer version 0.9.1

Installed with

  • Cocoapods

Issue Description

[ After the video reaches the end, the overlay animation is played and then the overlay disappears and it's never activated even if you press on the player. This causes a blocking scenario.]

Other Comment

[I've forked your repo and added the following to prevent the overlay from disappearing after the player finishes]

open func controlViewAnimation(isShow: Bool) {
        
        if self.playerLastState != .playedToTheEnd
        {
            let alpha: CGFloat = isShow ? 1.0 : 0.0
            self.isMaskShowing = isShow
            
            UIApplication.shared.setStatusBarHidden(!isShow, with: .fade)
            
            UIView.animate(withDuration: 0.3, animations: {
                self.topMaskView.alpha    = alpha
                self.bottomMaskView.alpha = alpha
                self.mainMaskView.backgroundColor = UIColor ( red: 0.0, green: 0.0, blue: 0.0, alpha: isShow ? 0.4 : 0.0)
                
                if isShow {
                    if self.isFullscreen { self.chooseDefitionView.alpha = 1.0 }
                } else {
                    self.replayButton.isHidden = true
                    self.chooseDefitionView.snp.updateConstraints { (make) in
                        make.height.equalTo(35)
                    }
                    self.chooseDefitionView.alpha = 0.0
                }
                self.layoutIfNeeded()
            }) { (_) in
                if isShow {
                    self.autoFadeOutControlViewWithAnimation()
                }
            }
        }
    }

repixels avatar Nov 17 '17 13:11 repixels

@BrikerMan it would be great , if you write the sample code for replay the video. Because we can see lots of issues/requests right here regarding this. link 1 link 2 link 3 link 4


This is my code to add replay functionality. Whenever video ends, black screen appear before the next play. From the user point of view , it was very annoying.
import BMPlayer
class BMPlayerCustomControlView: BMPlayerControlView {
    open override func playerStateDidChange(state: BMPlayerState) {
        switch state {
        case .playedToTheEnd:
            player?.setVideo(resource: (player?.currentResource)!)
        default:
            super.playerStateDidChange(state: state)
            break
        }
    }  
}

My thought, Write the method for replay in framework itself, instead of asking each and every one to handle in their own code.

mukilarasan101 avatar Nov 19 '17 13:11 mukilarasan101

@repixels Thank you ! the problem is gone

Momeks avatar Dec 27 '17 17:12 Momeks

@mukilarasan101 will do, I will try my best to fix this and other issues this week.

BrikerMan avatar Jan 02 '18 01:01 BrikerMan

Loop playback can be achieved in the following way

import BMPlayer
class BMPlayerCustomControlView: BMPlayerControlView {
    override func playerStateDidChange(state: BMPlayerState) {
        if state != .playedToTheEnd {
            super.playerStateDidChange(state: state)
        }else {
            let replay = UIButton()
            replay.tag = ButtonType.replay.rawValue
            delegate?.controlView(controlView: self, didPressButton: replay)
        }
    }
}

jeromexiong avatar Dec 18 '20 03:12 jeromexiong