On my iPhone i'm playing video/audio files in fullscreen mode. When the video/audio file reached its end then the following method is triggered:
- (void) movieFinishedCallback:(NSNotification*) aNotification { MPMoviePlayerController *player = [aNotification object]; [player stop]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; [player autorelease]; [moviePlayer.view removeFromSuperview]; NSLog(@"stopped?"); }
That works fine! But the problem is when i press on the "Done" button when the video/audio file is still playing. Then this method doesn't get triggered...
Anyone any idea how to catch the event when the "Done" button is pressed? Because right now media player stays in the view. Its not disappearing.
It worked for me on iPad when I listen to MPMoviePlayerWillExitFullscreenNotification
.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doneButtonClick:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
And selector method:
-(void)doneButtonClick:(NSNotification*)aNotification{ NSNumber *reason = [notification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]; if ([reason intValue] == MPMovieFinishReasonUserExited) { // Your done button action here } }
check for a enum inside notification userInfo dictionary
NSNumber *reason = [notification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]; if ([reason intValue] == MPMovieFinishReasonUserExited) { // done button clicked! }
Selected answer has since integrated my response. Please refer above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With