4
我有兩種不同的按鈕按鈕聲音動作。當我按下一個按鈕時,它應該播放一個聲音,當我按下另一個時,它應該停止第一個聲音並播放另一個聲音,我該怎麼做?如何停止AudioToolbox聲音?
感謝,
-(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);
}
非常感謝,它的工作 – Mihai 2013-03-12 20:14:00