title: iOS: Playing a video on application launch
body: <p>I am new to Xcode so I've been trying to follow along to tutorials but haven't come across any that explain what I'm trying to achieve. I just want to play a video automatically when you open an application. I have it somewhat working in that the audio plays, but I cannot see any video. Am I missing something? I am getting this Warning in my output window:</p>
  
  <blockquote>
    <p>Warning: Attempt to present MPMoviePlayerViewController: 0x831d7a0 on ViewController: 0x9d10540 whose view is not in the window hierarchy!</p>
  </blockquote>
  
  <p>In my <code>ViewController.h</code>:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;MediaPlayer/MediaPlayer.h&gt;
  
  @interface ViewController : UIViewController
  
  @end
  </code></pre>
  
  <p><code>ViewController.m</code>:</p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      NSURL *url =[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Placeholder" ofType:@"mp4"]];
      MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
      [self presentMoviePlayerViewControllerAnimated:playercontroller];
      playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
      [playercontroller.moviePlayer play];
      playercontroller = nil;
  
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  @end
  </code></pre>