The audio will work in an iPhone simulator, but not on a device

advertisements

Basically, when a button on my app is touched, audio is played. Simple enough, and yet it fails to work on my actual device, but works well in the simulator. When the button is touched, this function is executed:

- (IBAction)playButtonSound
{
    SystemSoundID buttonSound;
    NSURL *tapSound   = [[NSBundle mainBundle] URLForResource: @"Button_Sound" withExtension: @"caf"];
    CFURLRef buttonSoundURLRef = (CFURLRef) [tapSound retain];
    AudioServicesCreateSystemSoundID (buttonSoundURLRef, &buttonSound);
    AudioServicesPlaySystemSound(buttonSound);
    [tapSound release];
}

I'm still an iPhone newbie, so I'm not entirely sure what the cause of this is.


  • Works on iPhone Simulator but not on device

Make sure you write the correct file names, iOS is case sensitive, simulator is not.