I'm developing an iOS app and I want to play a video when the user pushes a button. I have developed this, the user pushes the button and the video is played, but when the video finishes, the view of the video remains, and it is frozen in the last frame of the video.
I have searching in Google, and I have found this question:
iOS 6, Xcode 4.5 video not exiting when done playing
I have used the code written there but I haven't fixed it. This is my code:
-(IBAction)reproducirVideo:(id)sender
{
NSURL *url5 = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"instrucciones" ofType:@"mp4"]];
_moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url5];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:YES];
}
-(void) moviePlayBackDidFinish:(NSNotification *)aNotification{
[_moviePlayer.view removeFromSuperview];
_moviePlayer = nil;
}
- (void)moviePlayerWillExitFullscreen:(NSNotification*) aNotification {
[_moviePlayer stop];
[_moviePlayer.view removeFromSuperview];
_moviePlayer = nil;
}