If you need to play short sounds, less than 30 seconds, Audio Session Services are your friend. Here is a snippet of code to play a wav file:
For this to work, you will need to import <AudioToolbox/AudioToolbox.h> header file, and also add the AudioToolbox.framework to your project.
For those interested in a little background information, Audio Session Services is a set of functions written in C. There are a few subtleties that give this away. Here is the definition for the AudioServicesCreateSystemSoundID function:
The giveaway is how we call this function:
Notice the parameter outSystemSoundID, which is a pointer to SystemSoundID, a 32 bit unsigned integer. To pass this value as a pointer in C, you pass the address of the variable, which is done using &soundID.
More tips on Audio Session Services in the works…
No comments:
Post a Comment