Archive for 5th May 2009

AudioServicesCreateSystemSoundID error -1500

The iPhone application is going along fine, and I decided to look into adding some sound to the application. So, I found a .caf sound file on my Macintosh, brought it into the project, and then used the SoundEffect class from the Metronome sample application.

Here is the initialization code that I am using:

theSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle 
                pathForResource:@"soundfile" ofType:@"caf"]];

When running the application in the Simulator, everything worked fine and the sound played loud and clear. However, when running the application on an actual device, there was no sound to be heard. Stepping through the code, I traced the problem down to initWithContentsOfFile method of the SoundEffect class, which was returning an error -1500 on this line of code:

OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)aFileURL, &aSoundID);

After trying to solve the problem by poring over the code, I decided on a lark to try to use the same exact .caf file that the Metronome application used. Of course, this worked, which apparently means that if you get the error -1500 from the AudioServicesCreateSystemSoundID call, it is possible that you are using a sound file that is compatible with the Mac but not with the iPhone.