In my app, one can record and save songs. Upon updating my app, I get an error trying to initialize an AVAudioPlayer. The song is saved in the documents directory, and I simply create a URL to the documents directory with that song and get the error above. When reading other answers to similar questions, it says that -43 is a file not found error, so I outputted everything in my documents directory, and I can clearly see that the file I'm trying to access is in the documents directory. It cannot be an error in the path to the documents directory as I simply use
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
to get the documents directory.
How I initialize the audioplayer, the error and URL I'm trying to access:
[[AVAudioPlayer alloc]initWithContentsOfURL:urlOfSong error:&error];
if (error)
{
NSLog(@"Error in audioPlayer: %@",
[error localizedDescription]);
NSLog(@"error with this: %@",urlOfSong);
}
2013-01-24 18:51:40.223 app[14104:907] Error in audioPlayer: The operation couldn’t be completed. (OSStatus error -43.)
2013-01-24 18:51:40.224 app[14104:907] error with this: file://localhost/var/mobile/Applications/C8F1FB54-CF7E-46EC-9B87-8BE3CE9B0A3D/Documents/k%20-%20Spongebob.m4a
Which can be seen that the file I'm trying to play is called k - Spongebob.m4a
Here is the output of my documents directory:
2013-01-24 18:51:40.228 app[14104:907] (
"Recording 11413, 10:28 PM - All I Need.m4a",
"k - Spongebob.m4a"
)
Keep in mind that I mentioned that this was only AFTER I updated my app. When testing before sending out the update, everything worked perfectly. And if I record a new song and save it and then try to play it using the exact same methods, it works just fine. This is happening when I'm trying to play a song that I recorded before the update.
Any help guys???