If you want to play a short sound (less than 30 seconds), you can do it easily:
Note . You will need to add an AudioToolbox structure and import it ( #import <AudioToolbox/AudioToolbox.h>)
SystemSoundID mySSID;
NSString *path = [[NSBundle mainBundle] pathForResource:@"beep" ofType:@"wav"];
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: path], &mySSID);
AudioServicesPlaySystemSound(mySSID);
Also note that the file may be:
- Duration no more than 30 seconds
- In linear PCM or IMA4 format (IMA / ADPCM)
- Packed in .caf, .aif or .wav file
source
share