我有两种不同的按钮按下声音动作。当我按下一个按钮时,它应该播放一个声音,当我按下另一个按钮时,它应该停止第一个声音并播放另一个,我该怎么做?
谢谢,
-(void) onButtonPressAlbina {
[soundID2 stop];
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"albina" ofType:@"m4a"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesPlaySystemSound (soundID);
}
-(void) onButtonPressBalena {
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"balena" ofType:@"m4a"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesPlaySystemSound (soundID);
}