Oksana Oksana - 5 months ago 21
iOS Question

Playing system sound without importing your own

Is it possible to play already existing system sounds without importing your own?

Answer

This code plays apple system sound "Tock.aiff"..I believe you can play different system sounds using this

NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
AudioServicesDisposeSystemSoundID(soundID);

See this thread

Apple's own example on using system sounds..

http://developer.apple.com/library/ios/#samplecode/SysSound/Introduction/Intro.html

Comments