2012-09-19 45 views
0

在視頻開始播放和touchesEnded之前,ViewController的變化和視頻開始在後臺的不同ViewController中播放..我該如何解決這個問題?我想,如果改變的viewController,然後停止播放..在後臺運行的MPMoviePlayerController iOS

- (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

http://stackoverflow.com/questions/13023241/continue-播放電影在mpmovieplayerviewcontroller-in-background/21752593#21752593試試這個link.thanks –

回答

0

您可以停止你moviePlayer - (無效)viewDidDisappear方法