title: iPhone: AVAudioPlayer unsupported file type
body: <p>My app downloads an mp3 from our server and plays it back to the user. The file is 64 kbps (which is well within the acceptable range for iPhone if I understand correctly). I have looked up how to do this on dozens of sites and they all suggest that i do exactly this:</p>
  
  <pre><code>NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://.../file.mp3"]];
  NSError *e = nil;
  AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:data error&amp;e];
  [player setDelegate:self];
  </code></pre>
  
  <p>When I run the code, player comes back null and I get this error:</p>
  
  <pre><code>2011-02-04 10:44:46.176 MyApp[6052:207] Error loading audio: Error Domain=NSOSStatusErrorDomain Code=1954115647 "The operation couldn’t be completed. (OSStatus error 1954115647.)"
  2011-02-04 10:44:49.647 MyApp[6052:207] unsupported file type
  </code></pre>
  
  <p>I have checked the file and I know that it works. It will play with no problems on Windows Media Player, and Quicktime on mac. I have also uploaded the file to the iPhone emulator and it plays with no problems whatsoever. The file is fine, but for some reason AVAudioPlayer doesn't like it.</p>
  
  <p>Is there something I need to change? Is there some kind of setting for NSData to specify what kind of file it is? Does anyone have any idea?</p>