views:

25

answers:

0

I have this code to play a sound but the first time you play it it takes a good 5 seconds to load...

How can I speed this up?

-(IBAction)playSound{ //play the cricket noise
 NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Cricket_Sound" ofType:@"mp3"];
 audioPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundPath] error:NULL];
 audioPlayer.delegate = self;
 [audioPlayer prepareToPlay];
 audioPlayer.numberOfLoops = 0;
 [audioPlayer play];
}