Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nickculbertson

macrumors regular
Original poster
Nov 19, 2010
226
0
Nashville, TN
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

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:mad:"audio" ofType:mad:"wav"];
if(theAudio)theAudio.volume -= .99;
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: path] error:NULL] ;
[theAudio play] ;
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.