5

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?

drewh
  • 10,077
  • 7
  • 34
  • 43
  • possible duplicate of [iPhone: how to make key click sound for custom keypad?](http://stackoverflow.com/questions/818515/iphone-how-to-make-key-click-sound-for-custom-keypad) – Ejaz May 03 '14 at 12:17
  • Check out this thread: [http://stackoverflow.com/questions/818515/iphone-how-to-make-key-click-sound-for-custom-keypad](http://stackoverflow.com/questions/818515/iphone-how-to-make-key-click-sound-for-custom-keypad) – aSquared Aug 01 '09 at 19:04

5 Answers5

4

The click sound you want is, I believe, in the sample app called SysSound.

http://developer.apple.com/iphone/library/samplecode/SysSound/

Michael Morrison
  • 1,323
  • 1
  • 18
  • 30
4

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);
Govind
  • 2,337
  • 33
  • 43
2

I found this, which sounds like what you are looking for.

Surya
  • 4,922
  • 8
  • 41
  • 54
1

Nothing public. There's probably an answer if you're willing to dive into private APIs, but this is strongly discouraged (as you will likely break future compatibility, and may get rejected from the app store).

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
1

There's an example on the iPhone Dev Center web site for playing short-duration sounds (5 seconds or less), You can use that code to play any sound you want. Find a click sound doing a google search and use that. That's all you need.

http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#PLAY_SHORT_SOUNDS_AND_ALERTS_2

AudioServicesCreateSystemSoundID (fileURL, soundID);
Jordan
  • 21,746
  • 10
  • 51
  • 63
  • But how can I play the exact keyboard tap sound? I can't seem to find that anywhere on the net, and what if Apple changes it in the future? – drewh May 19 '09 at 19:43
  • What could they possibly change it to that would be so different? An owl hooting? – willc2 May 20 '09 at 04:03
  • 2
    I'm sorry, I just cracked myself up making hooting noises while fake typing. Ignore me! – willc2 May 20 '09 at 04:04