Playing sounds in iPhone SDK?
Does anyone have a snippet that uses the AudioToolBox framework that can be used to play a short sound? I would be grateful if you shared it with me and the rest of the community. Everywhere else I have looked doesn't seem to be too clear with their code. Thanks! Here is an easy example using the AVAudioPlayer: -(void)PlayClick { NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"click" ofType:@"caf"]]; AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil]; [click play]; [click release]; } This assumes a file called "click.caf"