title: MPMoviePlayerController not playing any video content [due to ARC and memory management]
body: <p>I am trying to get a video playing in an iOS applocation, using MPMoviePlayerController to append a movie-view to an existing view when a user pushes a button.
  The view appears as a black box on the right position and everything, but nothing happens.
  I am expecting the movie to start playing, but nothing happens and no hints from the application on why.</p>
  
  <p>Can anyone see where this goes wrong?</p>
  
  <pre><code>-(IBAction) playButtonClicked:(id)sender
  {
      NSString* path = [[NSBundle mainBundle] pathForResource:@"sample_mpeg4" ofType:@"mp4"];
      NSLog(@"Using videoPath %@", path);
      NSURL* url = [NSURL fileURLWithPath:path];
      MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
      [self.view addSubview:player.view];
      player.view.frame = CGRectMake(10, 10, 300, 220);
     [player play];
  </code></pre>
  
  <p>}</p>
  
  <p>The movie exists and logs the correct path, but still no movie playing.</p>
  
  <pre><code>2012-07-06 11:51:13.492 experiments[84702:12203] Using videoPath /Users/marius/Library/Application Support/iPhone Simulator/5.1/Applications/9799C851-8D2B-4CFE-8CFA-A4C4C954787F/experiments.app/sample_mpeg4.mp4
  </code></pre>
  
  <p>From what I have read and understood this should be working.
  Any hints or suggestions on what to try?</p>
  
  <hr>
  
  <p>I moved the movie to a HTTP-server (fg.mp4) and are tailing the access-logs.
  When clicking the play-button the usual black window appears.
  Serverside i find two new entries in the log:</p>
  
  <pre><code>168.122.x.x - - [06/Jul/2012:22:42:33 +0200] "GET /fg.mp4 HTTP/1.1" 304 192 "-" "AppleCoreMedia/1.0.0.9B176 (iPhone Simulator; U; CPU OS 5_1 like Mac OS X; en_us)"
  168.122.x.x - - [06/Jul/2012:22:42:33 +0200] "GET /fg.mp4 HTTP/1.1" 206 33304 "-" "AppleCoreMedia/1.0.0.9B176 (iPhone Simulator; U; CPU OS 5_1 like Mac OS X; en_us)"
  </code></pre>
  
  <p>So the phone gets parts of the movie content, and -apparently- prepares to get the rest when needed.
  Is there some obvious parameter for the MPMoviePlayerController I'm missing?</p>
  
  <hr>
  
  <p><strong>UPDATE: Solution and working code</strong></p>
  
  <p>The problem is caused by ARC and the fact that no reference to the <code>MPMoviePlayerController</code> were kept after calling the method setting up the controller.
  The solution: Adding a class-variable to the class and use this to keep a reference to the controller for the lifetime of the movie.</p>
  
  <p>So early in the class declaration (outside any message/function-definitions):</p>
  
  <pre><code>MPMoviePlayerController* mpController;
  </code></pre>
  
  <p>And the abeformentioned <code>playButtonClicked</code> uses this variable to keep track of the controller:</p>
  
  <pre><code>NSString* path = [[NSBundle mainBundle] pathForResource:@"sample_mpeg4" ofType:@"mp4"];
  NSURL* url = [NSURL fileURLWithPath:path];
  mpController = [[MPMoviePlayerController alloc] initWithContentURL:url];
  mpController.view.frame = CGRectMake(10, 10, 300, 220);
  [self.view addSubview:mpController.view];
  [mpController play];
  </code></pre>