I am trying to enable AirPlay with mine AVPlayerViewController. In the document:
https://developer.apple.com/reference/avkit/avplayerviewcontroller
It indicates
AVPlayerViewController automatically supports AirPlay, but you need to do some project configuration and audio session before it can be enabled in your application.
On the tab, CapabilitiesI turned on the background for audio, AirPlay and Picture in Picture. I created AVPlayerViewControlleras follows:
let moviePlayerViewController: AVPlayerViewController = AVPlayerViewController()
let moviePlayer = AVPlayer(url: videoUrl!)
moviePlayer.allowsExternalPlayback = true
moviePlayer.usesExternalPlaybackWhileExternalScreenIsActive = true
moviePlayerViewController.player = moviePlayer
self.present(moviePlayerViewController, animated: false, completion: {
    moviePlayerViewController.player?.play()
})
I thought two lines
moviePlayer.allowsExternalPlayback = true
moviePlayer.usesExternalPlaybackWhileExternalScreenIsActive = true
Add AirPlay support, but I'm wrong. I read that AirPlay can be used by adding MPVolumeView, but for a custom video controller, not the built-in one. Any help would be greatly appreciated.