Post marked as Apple Recommended
Click to stop watching this thread.
You have stopped watching this post. Click to start watching again.
contentPostList.repliesapple-recommended.tooltip
Replied In
Video player options not visible on iOS 16
The recommendation does not work for me. I have embedded the AVPlayerViewController in a UIViewController, also the beginAppearanceTransition is called, but no video controls are shown. They are shown when the video is tabbed, but not initially. I don't want to add the workaround suggested by nbeanm but I have not found any other solution yet.
Here is my code:
func addPlayer(mediaURL: URL) {
let playerController = AVPlayerViewController()
playerController.showsTimecodes = true
playerController.player = AVPlayer(url: mediaURL)
playerController.beginAppearanceTransition(true, animated: false)
self.addChild(playerController)
view.addSubview(playerController.view)
// Setup the layout. I have created my own layout helper for setting up layout constraints.
// It should be obvious, that the player uses all the space of it's parent view.
// My layout helper can be found here: https://github.com/openbakery/PinLayout/
playerController.view.layout.pin(.top, .bottom, .leading, .trailing)
playerController.didMove(toParent: self)
self.actualPreviewController = playerController
playerController.endAppearanceTransition()
}