I am trying to understand how to play those sounds in iOS. I did found a few code snippets but they dont play anything when I use it. What am I doing wrong?
http://iphonedevwiki.net/index.php/AudioServices
- (IBAction) playSystemSound: (id) sender {
AudioServicesPlaySystemSound (1100);
}
If you are using valid soundID and playing the sound on device then the code you have presented should work.
Alternatively you can use the following code to play the custom sound or audio file if it 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 you could check that out also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With