AVAudioPlayer initialization: error code -50

Make sure your NSURL is valid, or you will get error code -50 "Operation could not be completed".


Regarding the comment from Brynjar: The Apple NSURL Class Reference describing URLWithString states

To create NSURL objects for file system paths, use fileURLWithPath:isDirectory: instead.

I have found that using URLWithString for file system paths generates the error reported by pix0r and therefore could be another explanation for error code = -50


“ OSStatus error -50” means paramErr, an old-style Mac error code indicating a bad parameter.