MPMoviePlayerController (theMovie など) を初めて作成するときに、initialPlaybackTime を正常に設定できます。しかし、theMoive がリリースされ、新しい MPMoviePlayerController を再作成すると、その intialPlaybackTime が正しく設定されず、実際にはムービーは常に最初から再生されます。コードは次のとおりです。
-(void)initAndPlayMovie:(NSURL *)movieURL
{
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
// create a notification for moviePlaybackFinish
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
theMovie.initialPlaybackTime = 15;
[theMovie setScalingMode:MPMovieScalingModeAspectFill];
[theMovie play];}
-(void) moviePlayBackDidFinish:(NSNotification*)notification
{
MPMoviePlayerController * theMovie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
[theMovie release];
[self initAndPlayMovie:[self getMovieURL]];
}
上記のコードでは、viewcontroller が initAndPlayMovie を読み込んで実行すると、ムービーは 15 秒から再生を開始しますが、再生が終了するか "Done" が押されると、新しい theMovie が作成され、0 秒から再生が開始されます。MPMoviePlayerController の initialPlaybackTime プロパティで何が起こったのか知っている人はいますか?
そして、上記のコードがあるviewControllerをリロードするたびに(親viewcontrollerからpresentModalViewController)、ムービーは任意の再生時間から開始できます。ビューコントローラーのロードとリリース後の再作成との間の MPMoviePlayerController 登録方法の違いは何ですか。