我已更新到iOS 12,并且AV Player VC关闭按钮不再起作用。屏幕从不关闭,而是暂停视频。此操作在以前的iOS版本上运行正常。
有什么特殊原因吗?
编辑:添加了代码
guard let movieURL = URL(string: urlStr) else { return }
moviePlayer = AVPlayer(url: movieURL)
self.moviePLayerViewController.player = moviePlayer
moviePLayerViewController.view.frame = vwMainContainer.bounds
moviePLayerViewController.modalTransitionStyle = .crossDissolve
moviePLayerViewController.modalPresentationStyle = .overCurrentContext
present(moviePLayerViewController, animated: true) {
self.moviePlayer?.play()
}
答案 0 :(得分:2)
您在那里没有显示任何代码
只需尝试以下方法,对我来说就很好了
//MARK: Play Video At Index Path
func playVideoWith(_ videoURL: URL) {
let player = AVPlayer(url: videoURL)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
playerViewController.view.frame = self.view.frame
self.present(playerViewController, animated: true) {
playerViewController.player?.play()
}
}
注意-请显示代码因此,我们可以看到错误在哪里,只需尝试一下上面的代码,让我知道它对您有帮助吗?
答案 1 :(得分:1)
现在已解决,我刚刚删除了模式表示样式,然后再次工作。如果有人知道请回答,我不确定为什么会出现问题。
guard let movieURL = URL(string: urlStr) else { return }
moviePlayer = AVPlayer(url: movieURL)
self.moviePLayerViewController.player = moviePlayer
moviePLayerViewController.view.frame = vwMainContainer.bounds
present(moviePLayerViewController, animated: true) {
self.moviePlayer?.play()
}