次のコードを実行しています。ビデオは正常に再生されますが、終了後は黒い画面になり、元のビューに戻ることはありません。黒い画面をタップすると、「読み込んでいます.....」というメッセージが表示されます。何が間違っているのか誰か説明してください。ありがとう
- (IBAction)video:(UIBarButtonItem *)sender
{
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"IMG_0973" ofType:@"MOV"]];
moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDonePressed:) name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
moviePlayer.controlStyle=MPMovieControlStyleDefault;
//moviePlayer.shouldAutoplay=NO;
[moviePlayer play];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
}
- (void) moviePlayBackDonePressed:(NSNotification*)notification
{
[moviePlayer stop];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)])
{
[moviePlayer.view removeFromSuperview];
}
moviePlayer=nil;
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
[moviePlayer stop];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)])
{
[moviePlayer.view removeFromSuperview];
}
}