0
votes

I have an audio player that plays local files.

audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]

It works fine. However if I click xcode run button to rebuild the app, the player is not working. It gives me Error

Error Domain=NSOSStatusErrorDomain Code=2003334207 "The operation couldn't be completed. (NSOSStatus error 2003334207.)"

The url is absolutely the same. I checked the file. It is where it says it is and it is not corrupt or anything.

Edit:

[[NSFileManager defaultManager] fileExistsAtPath:url.path]

returns false but if the file is there what this means is that I don't have access to it?

1
Might be a duplicate question of this one: stackoverflow.com/questions/3401069/…Stephan
Have you tried [[NSFileManager defaultManager] fileExistsAtPath:url.path] ? Maybe the url doesn't point to the right location.Teo

1 Answers

0
votes

Likely, with iOS8, the path that you have saved won't be valid across launches.

The solution is to save the filename and not the complete path, and to recreate the URL or complete path, by getting the path to the Documents (or tmp) folder and appending the filename to it.