を放出することができない私は、グローバル変数を作成しました)videoType {はMPMoviePlayerController
ViewVideoSubview.alpha = 0;
NSString *url = [[NSBundle mainBundle]
pathForResource:videoName
ofType:videoType];
player =
[[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
player.shouldAutoplay =YES;
[ViewVideoSubview addSubview:player.view];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
}
及びビデオplayiを終了したときそれ自体では、以下の呼び出しメソッドが呼び出されます。
- (void) movieFinishedCallback:(NSNotification*) aNotification {
[player.view removeFromSuperview]; //d1
MPMoviePlayerController *playerParam = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:playerParam];
[player release];
}
これまでのところすべて素晴らしいです。問題は、押されたときに別のView Controllerをロードする必要があるボタンがあることです。私はそのビューコントローラをロードすることができますが、ビデオはまだバックグラウンドで再生されます。なぜ私はプレーヤーを解放するときにエラーが発生しないのですか?私の一時的な解決策は、ビデオを停止し、ビデオがバックグラウンドで再生されないように他のView Controllerをロードすることです。
私が考えていたもう一つの解決策は、movieFinishedCallbackメソッドで解放されるように、ビデオが再生を終了する1秒前に再生することです。ビデオをその時点まで「早送り」する方法がわからない。私はobjective-cが新しく、aNotificationパラメータが何か分からない場合は、適切なパラメータでそのメソッドを呼び出すだけです。