I'm stuck. I can play an audio file with the AVAudioplayer but I can't find a way to release the audio when the audio is played again without a clipping sound.
My short term solution was to lower the volume of the first sound which works but doesn't release the audio.
How can I release the first audio when the action is called a second time?
Thanks,
Nick
Code:
- (IBAction)playSound1:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"wav"];
if(theAudio)[theAudio release];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
My short term solution was to lower the volume of the first sound which works but doesn't release the audio.
Code:
- (IBAction)playSound1:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"wav"];
if(theAudio)theAudio.volume -= .99;
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
How can I release the first audio when the action is called a second time?
Thanks,
Nick