I don't know squat about audio or the Terminal. I've use this Terminal command to convert a wav file for use in iOS:
afconvert -v -f 'caff' -d LEI16 -s 1 /users/myUserName/Desktop/hibeep.wav /users/myUserName/Desktop/hibeep.caf
After adding the file to my project, nothing happens when I execute:
NSURL * softURL = [[NSBundle mainBundle] URLForResource: @"hibeep" withExtension: @"caf"];
CFURLRef softSoundURL = (__bridge CFURLRef) softURL;
AudioServicesCreateSystemSoundID(softSoundURL, &_beepSound);
AudioServicesPlaySystemSound (_beepSound);
Yet, when I click on hibeep.caf in the Project Navigator, the sound will play fine.
I have tried this in both the simulator and on an iPad.
Any suggestions?
Thanks
TL;DR;
afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v
Long version: I know this is old, but this thread has solved my problem, so here's solution to the problem in the question.
CAF is only a container and you are using the wrong codec for the data held in the container. Quote from apple doc:
Custom alert sounds are played by the iOS system-sound facility, so they must be in one of the following audio data formats:
Linear PCM MA4 (IMA/ADPCM) µLaw aLaw
Here's the proper terminal command when converting WAV to CAF (MA4)
afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v
Try to select your audio file and check if the target is selected
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With