在视频开始播放和touchesEnded之前,ViewController更改并且视频开始在后台的另一个ViewController中播放..我该如何解决这个问题?我想要的是,如果viewController更改,则停止播放..
- (void)viewDidLoad
{
[super viewDidLoad];
movpath = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"m4v"];
mpviewController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:movpath]];
MPMoviePlayerController *mp = [mpviewController moviePlayer];
[mp prepareToPlay];
[mp setFullscreen:YES animated:YES];
mp.controlStyle = MPMovieControlStyleNone;
[[mpviewController moviePlayer] play];
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
[self performSegueWithIdentifier:@"mainView" sender:self];
[[mpviewController moviePlayer] stop];
[mpviewController.view removeFromSuperview];
}
答案 0 :(得分:0)
您可以在 - (void)viewDidDisappear方法
中停止您的moviePlayer