(iOS) Why does AVAudioPlayer initWithContentsOfURL always fail with error code=-43
问题 NSString *songNameEscaped = [songName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *songURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", @"http://somerootpath/Music/", songNameEscaped]]; NSLog(@"songURL = %@", songURL); NSError *avPlayerError = nil; AVAudioPlayer *avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:songURL error:&avPlayerError]; if (avPlayerError) { NSLog(@"Error: %@", [avPlayerError description]); } else { [avPlayer play]; } If I