2011-08-11 3 views
0

申し訳ありません質問タイトル。それを呼び出す方法を知らなかった。 私の問題をHeres。私はiPadアプリでビデオを読み込んでいます。それはライトボックスの一種で開かれています。 ビデオが正しく再生されます。 私が背景に触れると、ビデオが終了したときと同じようにビデオが閉じて解放されるはずです(moviePlaybackComplete) そして、私はそれをどうやって行うのか分かりません。これまでのところ私のコードを書いています:moviePlaybackCompleteメソッドの強制トリガー

- (IBAction)playVideo:(id)sender 
{ 
    UIButton *playButton = (UIButton *) sender; 

    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"mymovie" ofType:@"mp4"]; 
    NSURL *fileURL = [NSURL fileURLWithPath:filepath]; 
    moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlaybackComplete:) 
               name:MPMoviePlayerPlaybackDidFinishNotification 
               object:moviePlayerController]; 

    [moviePlayerController.view setFrame:CGRectMake(playButton.frame.origin.x, 
                playButton.frame.origin.y, 
                640, 
                360)]; 

    [self.view addSubview:moviePlayerController.view]; 

    [moviePlayerController play]; 
} 

- (void)moviePlaybackComplete:(NSNotification *)notification 
{ 
    MPMoviePlayerController *moviePlayerController = [notification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                name:MPMoviePlayerPlaybackDidFinishNotification 
                object:moviePlayerController]; 

    [moviePlayerController.view removeFromSuperview]; 
    [moviePlayerController release]; 
} 

- (IBAction)hideVideo:(id)sender 
{ 
    if(fadeView.hidden == NO){ 
     [UIView beginAnimations:nil context:nil]; 
     [UIView setAnimationDuration:0.75]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDidStopSelector:@selector(finishedVideoFading)]; 
     fadeView.alpha = 0; 
     [UIView commitAnimations]; 

     [moviePlayerController stop]; 
     [moviePlayerController.view removeFromSuperview]; 
     [moviePlayerController release]; 
    } 
} 

答えて

0

"ライトボックス"はビューコントローラですか?はいの場合は、ビデオが終了してビューを閉じます。

[[self navigationController] popViewControllerAnimated: YES]; 
関連する問題