title: ios MPMoviePlayerController detecting not found url while playing video
body: <p>I have a video player which loads video from some given url and plays. Whenever resource at given url is not valid and server returns error code with error response, I am not able to get any callback for the same. I have subscribed to following notifications.</p>
  
  <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.playerController];
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieDurationAvailable:) name:MPMovieDurationAvailableNotification object:nil];
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willChangePlayingMovie:) name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:nil];
  </code></pre>
  
  <p>I am playing video with hls video. My media have hls and mp4 url. whenever hls video fails, i wanted to fallback to mp4.</p>
  
  <p>EDIT:
  Just to clarify, not getting callback means notification is not firing. sorry for confusion.</p>
  
  <p>Code snippet on viewdidload</p>
  
  <pre><code>self.playerController = [[MPMoviePlayerController alloc] init];
  self.playerController.shouldAutoplay = YES;
  self.playerController.controlStyle = MPMovieControlStyleNone;
  
  [self.playerController.view setFrame:self.playerView.bounds];
  self.playerController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  [self.playerController.view translatesAutoresizingMaskIntoConstraints];
  
  
  
  [self.playerView addSubview:self.playerController.view];
  self.playerController.view.userInteractionEnabled = NO;
  self.playerController.view.backgroundColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1.0];
  self.playerController.backgroundView.backgroundColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1.0];
  //To hide top and bottom Bar
  
  self.playerController.view.backgroundColor = [UIColor blackColor];
  self.playerController.backgroundView.backgroundColor = [UIColor blackColor];
  </code></pre>
  
  <p>while setting url (from viewdidappear, notification also added here, code for that is in beginning)</p>
  
  <pre><code>NSURL *fileUrl;
  NSString *fileExtension;
  fileUrl = self.content.media.hlsUrl;
  if ([Reachability reachabilityForInternetConnection].isReachable) {
              [self.playerController setContentURL:fileUrl];
  
              BOOL isFirstTimeUpdate = [[NSUserDefaults standardUserDefaults] boolForKey:@"IS_FIRST_TIME_UPDATE"];
              if(isFirstTimeUpdate == NO){
                  [self.playerController pause];
              }
              else{
                  [self.playerController play];
              }
              [self.activityIndicator startAnimating];
          }else{
              self.errorLabel.text = kZErNoInternet;
              self.errorView.hidden = NO;
          }
  </code></pre>