Reputation: 3777
I'm trying to build a custom keyboard for iOS 8 that a custom play sound when a key is pressed. I'm using a AVAudioPlayer
and small mp3-files.
This works fine in the simulator, but on a real device I don't get any sounds.
RequestOpenAccess
is enabled.
Please not that I'm not trying to play the default keyboard click sound, but a custom sound. Most existing questions seems to be about the default system sound.
edit: I've also tried using .caf and .aiff files and loading and playing them with SystemSoundID.
Upvotes: 2
Views: 858
Reputation: 1352
I'm positive this is not your case but it often happens that the sound on the device is turned off. I made the mistake searching for an hour why sound didn't work. If it could only be that, it would be a quick fix ;)
Upvotes: 0
Reputation: 403
This snippet plays custom sound in my keyboard project.
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"your_custom_sound"
ofType:@"mp3"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesPlaySystemSound (soundID);
Cited from:
How to play tock sound when tapping custom keyboard buttons
Upvotes: 2