Reputation: 14418
I have my own sound that I want to play while the phone vibrates, the most common thing to do is to do:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
but this is using the system's sound. Is there a way to use my own sound? What is the format of the sound that I can use?
Upvotes: 5
Views: 1137
Reputation: 7936
Check out AudioServicesPlayAlertSound, this will play a custom sound and vibrate if the user has vibration enabled in their sound settings. The proper usage would be something like this...
SystemSoundID soundFileObject;
NSURL * soundFileURL= [[NSBundle mainBundle] URLForResource: @"mySoundFile" withExtension: @"aif"];
CFURLRef soundFileURLRef = (CFURLRef) [soundFileURL retain];
AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);
AudioServicesPlayAlertSound (soundFileObject);
The supported file types are .caf, .aif, or .wav according to the above link. Hope that helps!
Upvotes: 5