Playing small blips, beeps, etc (sounds less than 30 seconds) is actually pretty easy - this is exactly what AudioServices is meant to do. You need to first obtain an ID for each sound, using something like this:
SystemSoundID soundID = 0;
CFURLRef soundFileURL = (CFURLRef)[NSURL URLWithString:somePathString];
OSStatus errorCode = AudioServicesCreateSystemSoundID(soundFileURL, &soundID);
if (errorCode != 0) {
// Handle failure here
}
You'll then hold onto that ID until you need to use it, and then you can play the sound simply using this line:
AudioServicesPlaySystemSound(soundID);
There's also AudioServicesPlayAlertSound()
that will behave slightly differently depending on the device's capability, such as vibrating an iPhone if the device is configured to by the user. You should read Apple's notes in the docs for a more complete explanation: http://is.gd/57dtl.
Note that you have minimal control over the playback of sounds using AudioServices - you can't stop them, control the volume, etc. AudioServices is only meant for alert sounds and other such short beeps and blips. There is, of course, AVAudioPlayer but its a bit more heavyweight than what you need in this case. You're probably better off sticking with AudioServices unless one of its constraints makes it unusable.
You need to link AudioToolbox.framework in order to use these functions.
P.S. Welcome to Stack Overflow! Don't forget to read the FAQ and mark accepted answers for your questions (if they're good answers worth accepting, of course).