Sound systems in iOS

I am trying to figure out how to play these sounds in iOS. I found some snippets of code, but they do not play anything when I use it. What am I doing wrong?

http://iphonedevwiki.net/index.php/AudioServices

- (IBAction) playSystemSound: (id) sender { AudioServicesPlaySystemSound (1100); } 
+6
source share
1 answer

If you use the correct beep and play sound on the device, then the code you submitted should work.

Alternatively, you can use the following code to play a custom sound or audio file if this helps you

 - (IBAction) playSystemSound: (id) sender { NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"audio" ofType:@"mp3"]; SystemSoundID soundID; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID); AudioServicesPlaySystemSound (soundID); } 

Apple has provided sample code for playing sounds that you can also test.

+5
source

All Articles