Done Button Event Mpmovieplayercontroller

Done button event MPMoviePlayerController

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
}
}

Done button action of MPMoviePlayerViewController

You can use MPMoviePlayerPlaybackDidFinishNotification .

MPMoviePlayerController Audio show Done Button

i found a solution by my self.

Using the MPMoviePlayerViewController class, instead of MPMoviePlayerController solved the problem:

NSString *path = @"http://yourstreamingurl.com/stream.m3u";

MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:path]];

mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self presentModalViewController:mpviewController animated:YES];
[[mpviewController moviePlayer] play];

MPMoviePlayer done button issue

You can do that by adding a notification handler on MPMoviePlayerDidExitFullscreenNotification as that notification gets sent once the user taps on the DONE Button.

Somewhere in your initializer

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayerDidExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];

Now implement that handler:

- (void)MPMoviePlayerDidExitFullscreen:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerDidExitFullscreenNotification
object:nil];

[moviePlayerController stop];
[moviePlayerController.view removeFromSuperview];
}

MPMoviePlayerController Audio show Done Button

i found a solution by my self.

Using the MPMoviePlayerViewController class, instead of MPMoviePlayerController solved the problem:

NSString *path = @"http://yourstreamingurl.com/stream.m3u";

MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:path]];

mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self presentModalViewController:mpviewController animated:YES];
[[mpviewController moviePlayer] play];


Related Topics



Leave a reply



Submit