IPhone / ipod vibrate with custom sound

I have my own sound that I want to play while the phone vibrates, the most common thing is to do:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

but it uses system sound. Is there a way to use my own sound? What is the sound format I can use?

+5
source share
1 answer

Check out AudioServicesPlayAlertSound , this will play the custom sound and vibrate if the user has vibration in their sound settings. Proper use will be something like this ...

SystemSoundID soundFileObject;

NSURL * soundFileURL= [[NSBundle mainBundle] URLForResource: @"mySoundFile" withExtension: @"aif"];

CFURLRef soundFileURLRef = (CFURLRef) [soundFileURL retain];

AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);

AudioServicesPlayAlertSound (soundFileObject);

:.caf,.aif .wav . , !

+5

All Articles