title: Emulating splash video in iOS application
body: <p>OK, there are very few options to emulate the splash video in iOS. All we can do is wait till application is fully loaded and then create Media Player and load video in it.</p>
  
  <p>I implemented it with following code:</p>
  
  <pre><code>-(void) moviePlayBackDidFinish:(NSNotification*)notification
  {
      NSLog(@"Intro video stopped");
      [mMoviePlayer release];
  }
  
  - (void)applicationDidFinishLaunching:(UIApplication *)application {
      NSURL* mMovieURL;
      NSBundle *bundle = [NSBundle mainBundle];
      if(bundle != nil)
      {
          NSString *moviePath = [bundle pathForResource:@"intro" ofType:@"mp4"];
          if (moviePath)
          {
              mMovieURL = [NSURL fileURLWithPath:moviePath];
              [mMovieURL retain];
          }
      }
  
      mMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mMovieURL];
      [mMovieURL release];
  
      [[NSNotificationCenter defaultCenter] addObserver:self 
                                               selector:@selector(moviePlayBackDidFinish:) 
                                                   name:MPMoviePlayerPlaybackDidFinishNotification 
                                                 object:mMoviePlayer];
  
      mMoviePlayer.controlStyle = MPMovieControlStyleNone;
      [mMoviePlayer.backgroundView addSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Splash/background.png"]] autorelease]];
      mMoviePlayer.scalingMode = MPMovieScalingModeFill;
  
      [window addSubview:mMoviePlayer.view];
      [mMoviePlayer setFullscreen:YES animated:NO];
  
      [window makeKeyAndVisible];
      [mMoviePlayer play];
  
  &lt;... other stuff ...&gt;
  
  }
  </code></pre>
  
  <p>My video is only 1 MB. But this code do something different then I'd like to see:</p>
  
  <ol>
  <li>First of all user can see a static splash screen for a few seconds;</li>
  <li>Then a black screen appears for 1 or 2 seconds. I think this is happening because the media player is loaded.</li>
  <li>Video start playing.</li>
  <li>Main interface loads.</li>
  </ol>
  
  <p>As you understand I don't like the pause with black screen - it looks ugly.</p>
  
  <p>As far as I can see in my Console log the problem is that mediaplayer is waiting till the main view controller is fully loaded.</p>
  
  <p>Few words about main view: i'm writing an application for iPad and the main view consists of several subviews with multiple images. Every image and every subview in main view loads some data from Internet Web service via ASIHTTPRequest lib.</p>
  
  <p>I think that Media Player is waiting for all initial connections to finish and only then it's starting the video...</p>
  
  <p>How can I force the video to play before main view is loaded? Or maybe I can delay the loading of main XIB?</p>