0

I have this sound playing after pressing one button using AudioToolbox.

-(void) onButtonPressSound {
    NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"m4a"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesPlaySystemSound (soundID);

}

how can i make it play 2 sounds instead of one, one after the other, after pressing this button?

Thank you,

marko
  • 9,029
  • 4
  • 30
  • 46
Mihai
  • 131
  • 1
  • 1
  • 10

1 Answers1

2

There are 2 ways of doing this: first one: for a lazy one like me :) Take a sound which plays 2 sounds one after other . Another One:

SystemSoundID receiveMessageSound1;
SystemSoundID receiveMessageSound2;
NSString *sendPath1 = [[NSBundle mainBundle] pathForResource:@"Music1" ofType:@"wav"];
            CFURLRef baseURL = (__bridge CFURLRef)[NSURL fileURLWithPath:sendPath];
            AudioServicesCreateSystemSoundID(baseURL, &receiveMessageSound1);
            AudioServicesPlaySystemSound(receiveMessageSound1);
NSString *sendPath2 = [[NSBundle mainBundle] pathForResource:@"Music2" ofType:@"wav"];
            baseURL = (__bridge CFURLRef)[NSURL fileURLWithPath:sendPath2];
            AudioServicesCreateSystemSoundID(baseURL, &receiveMessageSound2);
            AudioServicesPlaySystemSound(receiveMessageSound2);

Hope this helps.

vishwa.deepak
  • 510
  • 4
  • 18