views:

303

answers:

0

Hi, Im currently building a soundboard and I am using the following code to play sounds:

NSString *path = [[NSBundle mainBundle] pathForResource:@"hawhaw" ofType:@"wav"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];

Now this plays the sound fine. Just a slight problem though, I have many different buttons playing sounds as it is a soundboard, if you tap loads of these buttons on the soundboard all at once repeatedly all audio suddenly stops, the application does not crash though and still works, But just with no audio. Anyone have any insight as to why this is happening? Do I need to be releasing "theAudio" or something along those lines? thanks in advance.