Kyle Kyle - 1 year ago 92
Objective-C Question

Best method to play an short audio sound on iOS 8.2

What is the best way to play an audio on iOS 8.2?

Answer Source

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);

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download