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?
You can use disabled modifier:

Code Block `
VideoPlayer(player: player)
.disabled(true)
`
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.

If you need a similar solution that will not globally change the behavior, you can use the SwiftUIIntrospect library.

import SwiftUIIntrospect

struct SomeVideoPlayer: View {
    /// ...
    var body: some View {
        VideoPlayer(player: player)
            .introspect(.videoPlayer, on: .iOS(.v18)) { vc in
                vc.showsPlaybackControls = false
                vc.allowsPictureInPicturePlayback = false
                vc.allowsVideoFrameAnalysis = false
            }
    }
}
SwiftUI VideoPlayer (Video Controls) in iOS14
 
 
Q