我正在开发一个 iOS 应用程序,我想在用户按下按钮时播放视频。我已经开发了这个,用户按下按钮并播放视频,但是当视频结束时,视频的视图仍然存在,并且它被冻结在视频的最后一帧。
我在谷歌搜索,我发现了这个问题:
我已经使用了那里编写的代码,但我还没有修复它。这是我的代码:
-(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;
}