如何禁用 AVPlayer 视频的自动旋转?

How to disable autorotation on AVPlayer Video?

我有一个 ViewController 和一个 AVPlayer,但即使我在 info.plist 和委托 [=14= 中将纵向设置为唯一支持的方向,视频也会自动旋转] 函数。

我已经搜索文档没有成功。

这是一些代码:

var videoPlayer = AVPlayerViewController()
var player = AVPlayer.init(url: URL.init(fileURLWithPath: urlString))
videoPlayer?.player = player
videoPlayer?.view.frame = self.view.frame
videoPlayer?.showsPlaybackControls = false

self.present(videoPlayer!, animated: false, completion: {action in
 self.player?.play()
})

这可以通过从 supportedInterfaceOrientations 继承 AVPlayerViewController 和 return UIInterfaceOrientationMask.portrait 来完成,这是代码。

class PlayerVideoViewController: AVPlayerViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
    return .portrait
}}

感谢 Rhythmic Fistman 的回答。