title: (iOS) Why does AVAudioPlayer initWithContentsOfURL always fail with error code=-43
body: <pre><code>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:&amp;avPlayerError];
  if (avPlayerError)
  {
      NSLog(@"Error: %@", [avPlayerError description]);
  }
  else
  {
      [avPlayer play];
  }
  </code></pre>
  
  <p>If I copy the NSLog output from <code>NSLog(@"songURL = %@", songURL);</code> and paste it in safari, Quicktime plugin plays the files no problem so I know the URLs are valid. I've tried with <code>.m4a</code> and <code>.mp3</code> files and have tried removing the spaces from <code>songName</code> but not matter what I always get Error: </p>
  
  <blockquote>
    <p>Error Domain=NSOSStatusErrorDomain Code=-43 "The operation couldn’t be completed. (OSStatus error -43.)".</p>
  </blockquote>
  
  <p>But they are just standard <code>.m4a</code> / <code>.mp3</code> files created in iTunes.</p>