AVPlayerViewController will exit full screen mode

Hi, I replaced MPMoviePlayerController with AVPlayerViewController, since MPMoviePlayerController is deprecated. I'm almost there, but I have one question. My film begins as a presentation in a presentation. When you play in full screen mode, I want it to return to NO in full screen mode when I finish the game. But I do not know how to do this. Here is my code:

- (void)viewDidLoad {

// grab a local URL to our video
NSURL *videoURL = [[NSBundle mainBundle]URLForResource:@"movie" withExtension:@"m4v"];

// create an AVPlayer
AVPlayer *player = [AVPlayer playerWithURL:videoURL];

// create a player view controller
self.controller = [[AVPlayerViewController alloc]init];
controller.player = player;
[player play];


// show the view controller
[self addChildViewController:controller];
[self.view addSubview:controller.view];
controller.view.frame = CGRectMake(0,25, 750, 422);

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:player];
}

With MPMoviePlayer, he worked with this code:

    - (void) playerPlaybackDidFinish:(NSNotification*)notification{
// movie finished playing
[moviePlayerController setFullscreen:NO];
}

What code do I need to replace?

-(void)itemDidFinishPlaying:(NSNotification *) notification {
// Will be called when AVPlayer finishes playing playerItem
 ???????????}

Thanks Meg

+4
source share

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


All Articles