It's up to you to implement this behaviour. I suggest you keep track of any AVAudioPlayer that might be playing and stop it before creating and starting a new one.
eg, you could use a property to store every AVAudioPlayer you create. Then, before creating a new one, stop the old one.
There's many ways to do this. Say you have a URL for each button, here's one possible procedure:
// note that audioPlayer is a property. It might be defined like this:
// @property (nonatomic,strong) AVAudioPlayer *audioPlayer
- (IBAction)button1Pressed:(id)sender {
NSString *stream = @"url1.mp3";
[self playUrl:[NSURL URLWithString:stream]];
}
- (IBAction)button2Pressed:(id)sender {
NSString *stream = @"url2.mp3";
[self playUrl:[NSURL URLWithString:stream]];
}
- (void) playUrl:(NSURL *) url {
//stop a previously running audioPlayer if it is running:
[audioPlayer pause]; //this will do nothing if audioPlayer is nil
//create a new one and start it:
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[audioPlayer start];
}