MPMoviePlayerViewController没有出现

时间:2011-01-24 17:21:43

标签: ipad ios media-player mpmovieplayer

我正在尝试为标题/启动画面加载一部小电影。但是,当我打电话presentMoviePlayerViewControllerAnimated时,没有任何反应。我已经确认正在执行代码块,但用户无法察觉。

我的目标是iPad,因此假定为3.2。

任何帮助都将不胜感激。

- (void)viewDidLoad {
  [super viewDidLoad];

  NSString *path = [[NSBundle mainBundle] pathForResource:@"Intro" ofType:@"m4v" inDirectory:nil];
  NSURL *fileURL = [NSURL fileURLWithPath:path];
  MPMoviePlayerViewController *playerView = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
  [[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(playbackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerView.moviePlayer];
  [self presentMoviePlayerViewControllerAnimated:playerView];
  [playerView release];
}

- (void)playbackDidFinish:(NSNotification*)aNotification {
  MPMoviePlayerController *player = [aNotification object];
  [[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:player];
  [player stop];
  [self dismissMoviePlayerViewControllerAnimated];
}

1 个答案:

答案 0 :(得分:1)

你应该放线  [playerView发布]; 后 这条线 [self dismissMoviePlayerViewControllerAnimated];