All pastes #2094570 Raw Edit

Code

public text v1 · immutable
#2094570 ·published 2011-11-23 07:33 UTC
rendered paste body
- (IBAction) videoAction:(id)sender
{
  if (myMovie)
    return ;
  
  NSString* a_path = [[NSBundle mainBundle] pathForResource:@"kevin-kell-introduction" ofType: @"mp4"];
  
  if (a_path==nil)
    return ;
  
  NSURL* a_url = [NSURL fileURLWithPath:a_path];
  
  if (a_url==nil)
    return ;
  
  Class moviePlayerViewControllerClass = (NSClassFromString(@"MPMoviePlayerViewController"));
  newStyleVideoPlayer = moviePlayerViewControllerClass && [MPMoviePlayerViewController instancesRespondToSelector: @selector(presentMoviePlayerViewControllerAnimated:)];
  if (newStyleVideoPlayer)
  {
    //We're running in iOS 3.2 or later, so use the new MPMoviePlayerViewController class.
    
    MPMoviePlayerViewController* movie_controller = [[[MPMoviePlayerViewController alloc] initWithContentURL:a_url] autorelease];
    
    if (movie_controller) {
      self.myMovie = movie_controller;
      
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playBackFinished:) name:@"MPMoviePlayerPlaybackDidFinishNotification" object:nil];
      
      MPMoviePlayerController* theMoviewPlayer = movie_controller.moviePlayer;
      theMoviewPlayer.controlStyle = MPMovieControlStyleNone;
      //theMoviewPlayer.fullscreen = TRUE;
      
      [[UIApplication sharedApplication] setStatusBarHidden: TRUE withAnimation: UIStatusBarAnimationNone];
      [self presentMoviePlayerViewControllerAnimated: (MPMoviePlayerViewController*)self.myMovie];
    }
  }
}