The problem with getting the resource URL is for some reason: this code is in viewDidLoad, and it worked in other applications, but not for any reason:
NSString* audioString = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"]; NSLog(@"AUDIO STRING: %@" , audioString); NSURL* audioURL = [NSURL URLWithString:audioString]; NSLog(@"AUDIO URL: %d" , audioURL); NSError* playererror; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&playererror]; [audioPlayer prepareToPlay]; NSLog(@"Error %@", playererror);
LOG OUTPUT:
AUDIO LINE: /var/mobile/Applications/D9FA0569-45FF-4287-8448-7EA21E92EADC/SoundApp.app/sound.wav
AUDIO URL: 0
Error Domain Error = NSOSStatusErrorDomain Code = -50 "Operation could not be completed (error OSStatus -50.)"
iphone resources nsurl
Adam
source share