title: Trying to fix AVAudioPlayer lag on its initial use
body: <p>This issue has shown up in several other question here on SO:</p>
  
  <p><a href="https://stackoverflow.com/questions/900461/slow-start-for-avaudioplayer-the-first-time-a-sound-is-played">Slow start for AVAudioPlayer the first time a sound is played</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2550480/delay-in-playing-sounds-using-avaudioplayer">Delay in playing sounds using AVAudioPlayer</a></p>
  
  <p>I've tried implementing the fixes suggested but none of them are solving my problem.  My application presents the user with a grid of objects to touch, when an object is touched a sound is played.  This works great except on the initial touch there is a delay of ~2 seconds.</p>
  
  <p>To get around this I initialize my audio player with a dummy aiff file:</p>
  
  <pre><code>- (void)viewDidLoad{
      NSString *soundFile = [Card loadCardSoundPath:@"dummy"];
  
      AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:
                               [NSURL fileURLWithPath:soundFile] error:nil];
      self.audioPlayer = player;
      [audioPlayer setDelegate:self];
      [audioPlayer prepareToPlay];
  //    [audioPlayer play];
      [player release];
  ...
  [super viewDidLoad]; 
  }
  </code></pre>
  
  <p>Then when an object is touched I call:</p>
  
  <pre><code>NSString *soundFile = [Card loadCardSoundPath:name];
  
  if (soundFile != nil){
  
              AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:
                                       [NSURL fileURLWithPath:soundFile] error:nil];
              self.audioPlayer = player;
              [self.audioPlayer setDelegate:self];
              [self.audioPlayer prepareToPlay];
              [self.audioPlayer play];
              [player release]; 
  }
  </code></pre>
  
  <p>The behavior i'm observing is this: I observe the audio delay when I click the first object if I create a dummy audio player and call prepareToPlay but not play.  However if I call play on the dummy audio player then I don't get the delay on the initial object but the view load gets delayed by 2 seconds.</p>
  
  <p>Is there a way to get around this?  Should I simply create an NSArray of AVAudioPlayers on load and tell them all to prepare to play, and then just call play when the object is clicked?</p>