So, I'm trying to check the audio player on the iPhone, and I left Troy Brant's iOS book. I have the core modules Core Audio, Core Foundation, AudioToolbox and AVFoundation added to my project. The error message I get is in the subject field. I read how 20 pages of Google search results before starting the assignment here! / Sigh. Thanks if you can help. Here is my code, quite a bit of verbatim from his book:
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"Yonah" ofType:@"caf"]; NSLog(@"%@", soundFilePath); NSURL *fileURL = [NSURL URLWithString:soundFilePath]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&error]; if (!error) { audioPlayer.delegate = self;
EDIT: Saint Shinto. I realized what it was. I changed
NSURL *fileURL = [NSURL URLWithString:soundFilePath];
to
NSURL *fileURL = [NSURL fileURLWithPath:soundFilePath];
to the last one, and I was getting a weird error stranger than the one that was in the subject, but I was looking for it, and I changed my OS input device from my webcam to my internal microphone and guessed that it worked according to the fileURLWithPath method . I will. Damned.
source share