SwiftUI VideoPlayer (Video Controls) in iOS14

Is there a way to disable the default video controls (play/pause/scrubber/etc) on the new SwiftUI VideoPlayer in iOS14, so I could create a custom one?
Post not yet marked as solved Up vote post of ed2s Down vote post of ed2s
7.6k views

Replies

You can use disabled modifier:

Code Block `
VideoPlayer(player: player)
.disabled(true)
`
  • This worked for me. No 3 second delay. Thanks!

Add a Comment
I tried the .disabled modifier, but I still see the controls appear for the 1st three seconds before disappearing.

Did you ever find a solution for this?

I found this article https://www.createwithswift.com/custom-video-player-with-avkit-and-swiftui-supporting-picture-in-picture/

it explains how to create a custom player.

This code resolved it for me, but it will change the behavior of all AVPlayerViewControllers in the app.

extension AVPlayerViewController {
    override open func viewDidLoad() {
        super.viewDidLoad()
        self.showsPlaybackControls = false
    }
}

If you want to only affect a particular instance, you may want to subclass AVPlayerViewController and use UIViewRepresentable to wrap it for SwiftUI.