title: iOS: How to use MPMoviePlayerController
body: <p>I've created a blank project (iOS) and put this in my viewDidLoad:</p>
  
  <pre><code>NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];
  MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
  [self presentMoviePlayerViewControllerAnimated:playerController];
  [playerController.moviePlayer play];
  </code></pre>
  
  <p>When the app starts all I get is a <strong>white screen with error messages in the log</strong>:</p>
  
  <pre><code> &lt;Error&gt;: CGContextSaveGState: invalid context 0x0
   &lt;Error&gt;: CGContextClipToRect: invalid context 0x0
   &lt;Error&gt;: CGContextTranslateCTM: invalid context 0x0
   &lt;Error&gt;: CGContextDrawShading: invalid context 0x0
   &lt;Error&gt;: CGContextRestoreGState: invalid context 0x0
  Warning: Attempt to present &lt;MPMoviePlayerViewController: 0x821e3b0&gt; on &lt;ViewController: 0x863aa40&gt; whose view is not in the window hierarchy!
  </code></pre>
  
  <p>...and a bunch of lines regarding disabling autoplay.
  I especially don't understand the line about the view not being part of the hierarchy since it's a blank "Single View Application" iOS project and the code is in ViewController.m. It IS in the view hierarchy.</p>
  
  <p>I know for a fact that the movie file itself is not the problem because I got it from Apple's sample code on MPMoviePlayer. And although I (seemingly) tried everything written in the sample, I just couldn't get the player to work.</p>
  
  <p>Here is another try, this time with MPMoviePlayerController (not MPMoviePlayerViewController):</p>
  
  <pre><code>MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
  [player setContentURL:url];
  [player setMovieSourceType:MPMovieSourceTypeFile];
  
  [[player view] setFrame:self.view.bounds];
  [player view].backgroundColor = [UIColor greenColor];
  
  player.scalingMode = MPMovieScalingModeNone;
  player.controlStyle = MPMovieControlModeDefault;
  player.backgroundView.backgroundColor = [UIColor whiteColor];
  player.repeatMode = MPMovieRepeatModeNone;
  
  [self.view addSubview: [player view]];
  [player play];
  </code></pre>
  
  <p>Similar result, with white screen and errors.
  Please help....</p>