我正在开发tvOS平台上的应用程序。并面临AVPlayerItemDidPlayToEndTimeNotification
的奇怪问题。当我播放视频并断开与互联网连接的连接时,通知在视频结束前调用。我不明白,怎么会发生。
override func viewDidLoad() {
super.viewDidLoad()
self.playVideo(videoUrl as String)
}
func playVideo(videoURL:String) {
let asset = AVAsset(URL: NSURL(string: videoURL)!) as AVAsset
let playerItem = AVPlayerItem(asset: asset)
let playerObj = AVPlayer(playerItem: playerItem)
self.player = playerObj
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MyPlayerViewController.playerItemDidReachEnd(_:)), name: AVPlayerItemDidPlayToEndTimeNotification, object: playerObj.currentItem)
playerObj.play()
}
func playerItemDidReachEnd(infoNoti:NSNotificationCenter){
print("==============Hi it is problem==============")
}