title: Error Message: MPMoviePlayerController instance is already playing
body: <p>In my app I am playing video(s) that are in the app, using the standard MPMoviePlayerController class.</p>
  
  <p>The first time around around this works great, however after watching 1 video if you try and watch something else the app crashes on MPMoviePlayerController's play method with the error:</p>
  
  <p>*** Terminating app due to uncaught exception 'MPMoviePlayerControllerPlaybackException', reason: 'MPMoviePlayerController instance  is already playing'</p>
  
  <p>I can not figure out why this is happening.</p>
  
  <p>I have VERY similar code in another app and I don't get this error.</p>
  
  <p>I am compiling for the device - 2.0 and running it on an iPhone with firmware 2.2.1.</p>
  
  <p>This is the code I have:</p>
  
  <pre><code>@synthesize movieURL;
  
  - (void) setMovieAndPlay
  {
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      moviePath = [[[paths lastObject] stringByAppendingPathComponent:movieURL] retain];
  
      [self playVideoWithURL:[NSURL fileURLWithPath:moviePath]];
  }
  
  -(void)playMovieAtURL:(NSURL*)theURL
  {
       MPMoviePlayerController *mMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
      mMoviePlayer.scalingMode = MPMovieScalingModeAspectFill;
  
       if ([defaults boolForKey:@"disableControls"])
       {
            mMoviePlayer.movieControlMode = MPMovieControlModeHidden;
       }
  
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:mMoviePlayer];
  
      [mMoviePlayer play];
  }
  
  - (void) moviePlayBackDidFinish:(NSNotification*)notification
  {
       MPMoviePlayerController *theMovie = [notification object];
  
       [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
  
       [theMovie release];
       theMovie = nil;
  
       NSDictionary *notiUserInfo = [notification userInfo];
  
       if (notiUserInfo != nil)
       {
            NSError *errorInfo = [notiUserInfo objectForKey:@"error"];
  
            if ([[errorInfo domain] isEqualToString:@"MediaPlayerErrorDomain"])
            {
                 UIAlertView *notice = [[UIAlertView alloc] initWithTitle:@"Error" message:[errorInfo localizedDescription] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
                 [notice show];
                 [notice release];
  
                 return;
            }
       }
  
       if ([defaults boolForKey:@"autoRepeat"])
       {
            [self playMovieAtURL:[NSURL fileURLWithPath:moviePath]];
       }
       else
       {
            KFAppDelegate *appDelegate = (KFAppDelegate *)[[UIApplication sharedApplication] delegate];
            [appDelegate endMovie];
       }
  }
  
  - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  {
      KFAppDelegate *appDelegate = (KFAppDelegate *)[[UIApplication sharedApplication] delegate];
      [appDelegate endMovie];
  }
  </code></pre>
  
  <p>What is even stranger is, if you look at the code, after the movie ends I check if the user has enable auto-repeat.</p>
  
  <p>If they have, I just start the movie over again, and THIS WORKS.</p>
  
  <p>However if they did not enable auto-repeat and leave this class and then try to watch another movie (or the same one) it gives that crash.</p>
  
  <p>Does anyone know why this would be happening?</p>
  
  <p>Am I doing something wrong?</p>
  
  <p>Thanks!</p>