Hi, I replaced MPMoviePlayerController with AVPlayerViewController since MPMoviePlayerController is deprecated. I'm nearly there, but have one question. My movie start as a view within a view. When playing fullscreen I want it to jump back to NO fullscreen when finished playing. But I don't know how. 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 it used to work with this code:
- (void) playerPlaybackDidFinish:(NSNotification*)notification{
// movie finished playing
[moviePlayerController setFullscreen:NO];
}
With what code do I need to replace it??
-(void)itemDidFinishPlaying:(NSNotification *) notification {
// Will be called when AVPlayer finishes playing playerItem
???????????}
Thanks, Meg