尝试使用UIContainerView
嵌入AVPlayerViewController
时AVPlayer
中的视频似乎永远无法播放视频或变焦。
有没有人能够做到这一点?你能提供一个这方面的样本项目吗?
class FirstViewController: UIViewController {
var player: AVPlayer?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
print(#function)
self.player?.play()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Do any additional setup before displaying the view
print(#function)
self.player?.play()
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
print(#function)
if let playerCntrl = segue.destinationViewController as? AVPlayerViewController {
let url = NSURL(string: "https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8")
playerCntrl.player = url.flatMap({ AVPlayer(URL: $0) })
self.player = playerCntrl.player
}
}
}