If you are using ARC see: “Playing a System Sound (ARC Version)”.
Today I needed to add a simple beep sound to an app. The code snippet below shows all the relevant calls.
// Required import... Also need AudioToolbox.framework #import <AudioToolbox/AudioToolbox.h> // ivar SystemSoundID mBeep; // Create the sound ID NSString* path = [[NSBundle mainBundle] pathForResource:@"Beep" ofType:@"aiff"]; NSURL* url = [NSURL fileURLWithPath:path]; AudioServicesCreateSystemSoundID((CFURLRef)url, &mBeep); // Play the sound AudioServicesPlaySystemSound(mBeep); // Dispose of the sound AudioServicesDisposeSystemSoundID(mBeep);
If I had found a page with a snippet like this on it it would have saved me some time. Maybe this page will save you some!
Pingback: Snippet: Playing a System Sound (ARC Version) | iOS Developer Zone
Pingback: MonoTouch Play System Sound | Jisku.com - Developers Network
Pingback: How to play a System Sound on the iPhone/iPad? | TechwikiHow