IOS Using MPMoviePlayerViewController in Full Screen (iPad)

I have one application for viewing with 5 buttons, and when one of the buttons is pressed, the player slides over the original view and starts playing the video in full screen mode (as it should be).

Everything works fine except for clicking on the Fullscreen / Minimize icon (two diagonal arrows pointing to each other next to the playback controls). When you click this button, the original view with five buttons will move over the video player. The problem is that the video is still playing under the original view. I would really like to exclude the Fullscreen / Minimize icon, but I can say that this is not possible. So ... I think I could use an observer to listen when the Fullscreen / Minimize icon is clicked, and I can do what I need. I just can't find anything solid in how to do this. Any help / direction would be appreciated.

Here is my current code ...

-(IBAction)playvideo {

 NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Megamind" ofType:@"mov"]];
 MPMoviePlayerViewController * playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];

 [self presentMoviePlayerViewControllerAnimated:(MPMoviePlayerViewController *)playerController];

 playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
 [playerController.moviePlayer play];
 [playerController release];
 playerController=nil;
}

- (void)moviePlayerWillExitFullscreen:(NSNotification *)theNotification {

 MPMoviePlayerController *playerController = [theNotification object];
 [[NSNotificationCenter defaultCenter] addObserver:self
            selector:@selector(moviePlayerWillExitFullscreen:)
             name:MPMoviePlayerWillExitFullscreenNotification
              object:nil];

 [playerController stop];
 [self dismissMoviePlayerViewControllerAnimated];
}
+3
4

.

[self presentMoviePlayerViewControllerAnimated:(MPMoviePlayerViewController *)playerController];

currentModalViewController.

Movieplayer Modally. , :

movieplayer.controlStyle = MPMovieControlStyleFullScreen

.

, , . , , .

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

. , ..

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

-(void) movieExitFullScreen:(NSNotification *) . , .:)

+2

MPMoviePlayer:

[[NSNotificationCenter defaultCenter] addObserver:self
            selector:@selector(moviePlayerWillExitFullscreen:)
             name:MPMoviePlayerWillExitFullscreenNotification
              object:nil];
+1

, , .

MPMoviePlayerController *playerController = [theNotification object]; 
[[NSNotificationCenter defaultCenter] addObserver:self
        selector:@selector(moviePlayerWillExitFullscreen:)
         name:MPMoviePlayerWillExitFullscreenNotification
          object:nil];

playVideo()

[[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:name:MPMoviePlayerWillExitFullscreenNotificationn
                                                  object:nil];

moviePlayerWillExitFullscreen.

+1

, , , . , . ... MPMoviePlayerWillExitFullscreenNotification . MPMoviePlayerDidExitFullscreenNotification. MPMoviePlayerPlaybackDidFinishNotification. , , MPMoviePlayerPlaybackDidFinishNotification , Fullscreen/Embed.

-(IBAction)playvideo {

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Megamind" ofType:@"mov"]];
MPMoviePlayerViewController * playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

[self presentMoviePlayerViewControllerAnimated:(MPMoviePlayerViewController *)playerController];

playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playerController.moviePlayer play];
[playerController release];
playerController=nil;
NSLog(@"playvideo");
}

- (void)movieFinishedPlayback:(NSNotification*)notification {

            MPMoviePlayerController *playerController = [notification object];
            [playerController pause];
            [self dismissMoviePlayerViewControllerAnimated];

}
0

Source: https://habr.com/ru/post/1771577/


All Articles