0

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

}
4

1 回答 1

0

你可以在 -(void)viewDidDisappear 方法中停止你的电影播放器

于 2012-09-19T07:13:11.773 回答