Thanks to the wonderful Octave project for introducing me to AVAudioPlayer. It's a great little way to add some sounds to your app. Here's an example for how to get started:
- (void) playSoundWithFilename:(NSString*)filename { NSString *file = [filename stringByDeletingPathExtension]; NSString *extension = [filename pathExtension]; NSURL *soundFileURL = [[NSBundle mainBundle] URLForResource:file withExtension:extension]; NSError* error = nil; self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:&error]; [self.audioPlayer play]; }
Did you add your sound file as a member of your Target? It's a silly thing, but I've missed this more than once... not sure why the checkbox sometimes defaults to false while dragging sound files in.
Has your AVAudioPlayer instance been released before it can play your sound? Using something like a "self.audioPlayer" property (as above) might be what you're looking for, so your view can handle keeping it around for you.