In my project, I used MPMoviePlayerController
to stream video from http-url. He plays in full screen. When a video plays, if you click Finish, the video stops and it disappears, but the problem is that: if you click to close the video screen, the video screen will disappear, but it still plays, the video sound continues to play .
I tried to detect a full-screen exit notification and manually stop the video, but that did not work. My moviePlayerDidExitFullScreen
method moviePlayerDidExitFullScreen
not been called.
To control this, if I get the notifications correctly, I tried to get another notification: MPMoviePlayerPlaybackStateDidChangeNotification
, and it works. It calls the method when the video starts.
I searched a lot of Apple forums and documentation, but I could not find enough information.
Here is my code to open full screen video and detect full screen output:
- (void)openFullVideo { NSString* path = @"http://trtvizyon.mysys.com/test/leyla_ile_mecnun.mp4"; NSURL *fileURL = [NSURL URLWithString:path]; MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidExitFullScreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil]; player.controlStyle = MPMovieControlStyleDefault; player.movieSourceType = MPMovieSourceTypeStreaming; [self.view addSubview:player.view]; [player setFullscreen:YES animated:YES]; [player play]; } - (void) moviePlayerDidExitFullScreen:(id)sender { NSLog(@"moviePlayerDidExitFullScreen"); }
source share