0

I am developing a app on tvOS platform. And facing a strange problem with AVPlayerItemDidPlayToEndTimeNotification. When i am playing the video and disconnect from the internet connection, the Notification called before the video end. i am not understand, how is it happen.

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==============")
}
Sankalap Yaduraj Singh
  • 1,167
  • 2
  • 14
  • 32

0 Answers0