I think a work around for this issue can be adding
if #available(iOS 16.0, *) {
avPlayerViewController.setValue(false, forKey: "canHidePlaybackControls")
}
and removing it after one second.
So the code will look like something like this:
let avPlayer: AVPlayer = AVPlayer(url: newURL)
avPlayerViewController = AVPlayerViewController()
if let avPlayerViewController = avPlayerViewController {
avPlayerViewController.delegate = self
avPlayerViewController.player = avPlayer
if #available(iOS 16.0, *) {
avPlayerViewController.setValue(false, forKey: "canHidePlaybackControls")
}
addChild(avPlayerViewController)
view.addSubview(avPlayerViewController.view)
}
if #available(iOS 16.0, *) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
self.avPlayerViewController?.setValue(true, forKey: "canHidePlaybackControls")
})
}