Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVAudioPlayer initialization: error code -50

I recently ran into a problem that I couldn't find discussed anywhere on the internet - I was initializing an AVAudioPlayer to play an audio file, and getting the following error:

Error Domain=NSOSStatusErrorDomain Code=-50 "Operation could not be completed. (OSStatus error -50.)

As it turns out, I had made a mistake creating my NSURL to send to the audio player init method, resulting in the NSURL object being null. Stupid mistake, pretty easy to find when debugging, but I thought I'd list it here just in case someone else does the same thing.

like image 875
pix0r Avatar asked Dec 07 '09 18:12

pix0r


2 Answers

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

like image 51
Jens Ayton Avatar answered Sep 17 '22 14:09

Jens Ayton


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

like image 28
Martin Lockett Avatar answered Sep 17 '22 14:09

Martin Lockett