Hide controls in AVPlayerViewController — only at start

前端 未结 4 1169
孤街浪徒
孤街浪徒 2020-12-25 11:59

If you set AVPlayerViewController.showsPlaybackControls to false, the controls will not show at all. Even if you tap the screen.

I want the controls to start out hid

4条回答
  •  爱一瞬间的悲伤
    2020-12-25 12:37

    A simple way to do it in Swift 3 is to set myController.showsPlaybackControls = false, and to overlay the whole player view with a button or gesture recognizer. I embed it into another view in another controller on a storyboard to make this simple and to not override the player controller. The trick then is to hide the button after being clicked once, because the player controller will thereafter track taps to show/hide the controls.

    @IBAction func enableControls(button:UIButton)
    {
        controller?.showsPlaybackControls = true
        button.isHidden = true //The button is only needed once, then the player takes over.
    }
    

提交回复
热议问题