3

マイビデオは私の再生ボタンをクリックすると動作し、私のビューの変更のコードがわかります。私のビデオが再生された後で、何がうまくいかないのかわからないだけで、ビューを変更することができないようです。ビデオの再生が完了したら、ビューを変更するためのアイデアはありますか?ビデオを再生した後にビューを変更します

私のコードでは、ビュー

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

View2 *view2 = [[View2 alloc] initWithNibName:@"View2" bundle:nil]; 
View2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
[self presentModalViewController:view2 animated:YES]; } 

EDITを変更するには、ムービー

-(IBAction)playMovie:(id)sender { 
NSString *movieUrl = [[NSBundle mainBundle] pathForResource:@"Movie_1666" ofType:@"m4v"]; 
playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:movieUrl]]; 
//Smoothe Transition 
//[self presentMoviePlayerViewControllerAnimated:playerController]; 
//Instant Transistion 
[self presentModalViewController:playerController animated:NO]; 
playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile; 
playerController.moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 
playerController.moviePlayer.controlStyle = MPMovieControlStyleNone; 
[playerController.moviePlayer play]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerController]; } 

マイ方法を再生する: 私の通知オブジェクトが間違っていたと私playbackFinished方法 をトリガされませんでした。この変更はそれを修正します。

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

私はまた、映画のプレーが終了したら、私のplaybackFinished方法

MPMoviePlayerViewController *playerController; 

答えて

1

で使用するために、それはグローバル作るアニメーションなしplayerControllerビューを閉じ、私のヘッダファイルでこれを置きます。また、メインスレッドにView2を表示しているかどうかを確認してください。

編集: はマジックが起こるようにする方法は非常にわからない

[playerController dismissModalViewControllerAnimated:NO]; 
+0

playerControllerを閉じます。私はplayerControllerを却下する方法がわからないので、私はそれを解放することはできません。また、View2をメインスレッドにどのように表示するのですか? – Sam

+0

私は、playerControllerを閉じるコードで自分の答えを更新しました。 – Ilanchezhian

+0

Lancさん、ありがとうございました。 – Sam

関連する問題