Question

I'm attempting to load a small movie for a Title/Splash screen. However, when I call presentMoviePlayerViewControllerAnimated nothing happens. I have confirmed that the block of code is being executed, but there is nothing perceptible to the user.

I am targeting the iPad, so 3.2 is assumed.

Any help would be appreciated.

- (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];
}
Was it helpful?

Solution

you should place the line [playerView release]; after this line [self dismissMoviePlayerViewControllerAnimated];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top