title: how to load multiple local files with the AVFoundation
body: <p>I wish to use the AVFoundation to load and play movie files. The first problem I have is attempting to load multiple local files. The code I found only allows me to load one. If I call the method below it exits with the exception:</p>
  
  <p>Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer  for the key path "currentItem.nonForcedSubtitleDisplayEnabled" from  because it is not registered as an observer.'</p>
  
  <p>Thanks for any advice</p>
  
  <p><code>
  - (IBAction)loadAssetFromFile:(NSString*)fileName withExtension:(NSString*)extension {</p>
  
  <pre><code>NSURL *fileURL = [[NSBundle mainBundle]
                    URLForResource:fileName withExtension:extension];
  
  AVURLAsset *asset = [AVURLAsset URLAssetWithURL:fileURL options:nil];
  NSString *tracksKey = @"tracks";
  
  [asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:tracksKey] completionHandler:
   ^{
  
       // Completion handler block.
       NSError *error = nil;
       AVKeyValueStatus status = [asset statusOfValueForKey:tracksKey error:&amp;error];
  
       if (status == AVKeyValueStatusLoaded) {
  
           self.playerItem = [AVPlayerItem playerItemWithAsset:asset];
  
           [playerItem addObserver:self forKeyPath:@"status" options:0 context:&amp;ItemStatusContext];
  
           [[NSNotificationCenter defaultCenter] addObserver:self
                                                    selector:@selector(playerItemDidReachEnd:)
                                                        name:AVPlayerItemDidPlayToEndTimeNotification
                                                      object:playerItem];
           self.player = [AVPlayer playerWithPlayerItem:playerItem];
           [playerView setPlayer:player];
       }
       else {
           // Deal with the error appropriately.
           NSLog(@"The asset's tracks were not loaded:\n%@", [error localizedDescription]);
       }
  
   }];
  </code></pre>
  
  <p>}
  </code></p>