It looks like you are not freeing the AudioPlayer object. Thus, you can play three times, probably due to the number of open files that you can have in the AVAudioPlayer object.
view delegate methods for AVAudioPlayer: in particular
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error
you need to do something like
(in your main code)
AudioPlayer.delegate = self;
then add a function like
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
[player release];
}
, .