My app plays 8 videos (using AVPlayer) by tapping 8 buttons. When a video has finished playing the player is closed using the following code:
-(void)playerItemDidReachEnd:(NSNotification *) notification {
[self dismissViewControllerAnimated:YES completion:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
And inside the buttons action:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:_currentItem];
I also have a "Play All" button where all 8 videos are played consecutively using AVQueuePlayer. When they have finished playing the player is closed using this code:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:eightVideoItem];
Overall it works fine, but if you play one of the 8 videos and close it manually before it has finished playing, and then tap "Play All" the player is closed after the first video (but the sound of the following videos keeps playing). It's like it calls the previous videos playerItemDidReachEnd!?