在视频开始播放和 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];
}