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メソッドでmoviePlayerを停止できます

于 2012-09-19T07:13:11.773 に答える