我有ViewController
AVPlayer
,但即使我已将肖像设置为info.plist
和委托supportedInterfaceOrientationsFor
功能中唯一支持的方向,视频也会自动旋转
我没有成功搜索文档。
以下是一些代码:
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()
})
答案 0 :(得分:0)
这可以通过继承AVPlayerViewController
并从UIInterfaceOrientationMask.portrait
返回supportedInterfaceOrientations
来完成,这里是代码。
class PlayerVideoViewController: AVPlayerViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
return .portrait
}}
感谢Rhythmic Fistman的回答。