Hello,
I'm trying to play a sound and then play the same sound a second time while muting the first sound. The code I'm using is
This code releases the sound when the button is hit a second time, but it creates a pop noise.
Is there a way to quickly fade out the first sound as the second sound starts?
Thanks,
Nick
*problem solved with
NSString *path = [[NSBundle mainBundle] pathForResource
"audio" ofType
"wav"];
if(theAudio)theAudio.volume -= .99;
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: path] error:NULL] ;
[theAudio play] ;
I'm trying to play a sound and then play the same sound a second time while muting the first sound. The code I'm using is
Code:
- (IBAction)playSound1:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"audio" ofType:@"wav"];
if(theAudio)[theAudio release];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: path] error:NULL];
[theAudio play];
}
This code releases the sound when the button is hit a second time, but it creates a pop noise.
Is there a way to quickly fade out the first sound as the second sound starts?
Thanks,
Nick
*problem solved with
NSString *path = [[NSBundle mainBundle] pathForResource
if(theAudio)theAudio.volume -= .99;
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: path] error:NULL] ;
[theAudio play] ;
Last edited: