title: How to do something when AVQueuePlayer finishes the last playeritem
body: <p>I've got an AVQueuePlayer which I'm creating from an array of 4 AVPlayerItems, and it all plays fine. </p>
  
  <p>I want to do something when the last item in the queue finishes playing, I've looked a load of answers on here and this is the one that looks most promising for what I want:
  <a href="https://stackoverflow.com/questions/10604740/the-best-way-to-execute-code-after-a-sound-has-finished-playing">The best way to execute code AFTER a sound has finished playing</a></p>
  
  <p>In my button handler i have this code:</p>
  
  <pre><code>static const NSString *ItemStatusContext;
  
      [thePlayerItemA addObserver:self forKeyPath:@"status" options:0 context:&amp;ItemStatusContext];
      [[NSNotificationCenter defaultCenter] addObserver:self
                                               selector:@selector(playerItemDidReachEnd)
                                                   name:AVPlayerItemDidPlayToEndTimeNotification
                                                 object:thePlayerItemA];
  
       theQueuePlayer = [AVQueuePlayer playerWithPlayerItem:thePlayerItemA]; 
  
      [theQueuePlayer play];
  </code></pre>
  
  <p>and then I have a function to handle playerItemDidReachEnd:</p>
  
  <pre><code>- (void)playerItemDidReachEnd:(NSNotification *)notification {
  // Do stuff here
  NSLog(@"IT REACHED THE END");
  }
  </code></pre>
  
  <p>But when I run this I get an Internal Inconsistency Exception:</p>
  
  <pre><code>    An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
  Key path: status
  Observed object: &lt;AVPlayerItem: 0x735a130, asset = &lt;AVURLAsset: 0x73559c0, URL = file://localhost/Users/mike/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/A0DBEC13-2DA6-4887-B29D-B43A78E173B8/Phonics%2001.app/yes.mp3&gt;&gt;
  Change: {
      kind = 1;
  </code></pre>
  
  <p>}</p>
  
  <p>What am I doing wrong?</p>