What is the best way to play an audio on iOS 8.2?
The easiest way is to import the AudioToolbox framework like so #import <AudioToolbox/AudioToolbox.h>
then all you need to do is this:
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Beep" ofType:@"mp3"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundPath], &soundID);
AudioServicesPlaySystemSound(soundID);
This is best for really short sounds like beeps e.t.c because you wont have much control over the sounds like you would with AVAudioPlayer
.
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