我要在两个屏幕上播放相同的视频并保持寻找时间。所以我在这些屏幕中重用AVPlayer
实例。第一次AVPlayer
工作正常,但每当它被重用时,玩家的帧从左上角开始动画,以适应目标视图开始播放。
等, https://www.dropbox.com/s/8ieb4bnb0rsn9ig/ezgif.com-gif-maker.gif?dl=0
代码看起来像,
if myObj._playerResult != nil {
_player = myObj._playerResult //reuse player instance
} else {
// First create an AVPlayerItem
let playerItem : AVPlayerItem = AVPlayerItem(URL: NSURL(string:sVideoUrl as String))
_player = AVPlayer(playerItem: playerItem)
}
playerController = AVPlayerViewController()
playerController?.showsPlaybackControls = false
playerController?.player = _player
playerController!.view.frame = targetView.bounds
targetView.addSubview(playerController!.view)
_player?.play()