I cannot, for the life of me, get audio files to play. I’ve been trying to suspend speech recognition and then play a small sound, but it just doesn’t work.
I attempted to to add the code to play the file to the demo project too and that doesn’t work either. I saw the other forum post about not being able to play files using AVAudioPlayer and he said that he just rebuilt and cleaned his project and it started working. I don’t know why that would fix my issue, but I tried it anyway and nothing.
Here’s my code for playing a small wav file.
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@”sound” ofType:@”wav”]];
NSError *error;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if (audioPlayer == nil)
NSLog(@”%@”,[error description]);
else
[audioPlayer play];
I could really use some help here.
Thanks!