I have a relatively simple application that plays sound using AVAudioPlayer , for example:
NSURL *file3 = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/ball_bounce.aiff", [[NSBundle mainBundle] resourcePath]]]; player3 = [[AVAudioPlayer alloc] initWithContentsOfURL:file3 error:nil]; [player3 prepareToPlay];
to be called later for playback, for example:
[player3 play]
But this sound is called in several places (collisions with a bouncing ball), many times. Sometimes the ball hits two things in a fairly fast sequence when the sound from the first bounce is still playing, when the ball collides for the second time. This second rebound then does not produce sound. How can I make it play a sound every time it collides, even if it involves paying for a sound that overlaps an already playing sound?
Any help is greatly appreciated.
source share