Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play iPhone tap sound?

I have a button in my iPhone app that I'd like to have play the default "keyboard tap" sound when it's tapped. I've been able to play my own custom sounds easily enough, but is there any way to play a default system sound like this in my app?

like image 928
drewh Avatar asked May 19 '09 18:05

drewh


1 Answers

usingsystemsounds
You must use the System Sound for this.The below might be usefule.Refer Multimedia Programming guide to know more.

CFBundleRef mainbundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef = CFBundleCopyResourceURL
                                     (mainbundle, CFSTR("tap"), CFSTR("aif"), NULL);
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundFileObject);

Also you can use the inbuilt system sounds by

AudioServicesPlaySystemSound(1100);
like image 139
Govind Avatar answered Sep 28 '22 06:09

Govind