tvOS中的AVPlayerItemDidPlayToEndTimeNotification问题

时间:2016-09-29 04:50:23

标签: swift2 avplayer tvos avplayerviewcontroller

我正在开发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==============")
}

0 个答案:

没有答案