I'm refitting old moviePlayer code to the AVPlayer. I had a part when a user selected a movie from a list of choices the movie player would appear showing the clip along with a "done" button that would take the person back to the tableview.
I've gotten the movie to play but I am having trouble figuring out how to have a "back/done" buttont to dismiss the Player. Here is what I have so far:
-(void)playMovie: (NSString *) fileName
{
NSLog(@"in playMovie second");
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: fileName ofType:@"mp4"]];
AVPlayer *player = [AVPlayer playerWithURL:url];
AVPlayerViewController *avMovie = [[AVPlayerViewController alloc]init];
//AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
avMovie.view.frame = self.view.bounds;
avMovie.player = player;
//playerLayer.frame = self.view.bounds;
//[playerLayer setVideoGravity:AVLayerVideoGravityResizeAspect];
//[self.view.layer addSublayer:playerLayer];
[player play];
//show view controller
[self addChildViewController:avMovie];
[self.view addSubview:avMovie.view];
}