0

I currently have the following listener for my AVPlayer

NotificationCenter.default.addObserver(self, selector: #selector(self.didFinishPlaying), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: video.currentItem)

I am wondering how to add a listener for when the AVPlayer is stopped prematurely, as when I user is watching at full scene and hits the done in the top corner.

Blue
  • 1,408
  • 4
  • 17
  • 36

1 Answers1

0
  1. Register your listener as an observer in Notification Center, for a custom notification name e.g. Notification.Name("UserStoppedAvPlayer"), register a selector for this notification such as func userDidStopAvPlayer().

  2. When your user taps the done button, within the selector/method thats triggered, where you stop the AvPlayer you should then post a notification to Notification Center with the custom name you registered on the listner.

  3. Your listener will then fire the selector you registered and you should do your logic in there.

torinpitchers
  • 1,282
  • 7
  • 13