I’m using AVAudioPlayer for playing some caf files on an app, it is working fine on all the simulators (iPhone and iPad) and on my iPhone, but when I test it on my iPad it doesn’t work and gives me this error: Error Domain=NSOSStatusErrorDomain Code=-43 “The operation couldn’t be completed. (OSStatus error -43.)”
Strange thing is that the same exact code it is working fine also on iPad for another app….
The iPad is updated to the IOS version 5.1.1
This is the code I’m using:
NSError *error;
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/music.caf", [[NSBundle mainBundle] resourcePath]]];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = 0;
audioPlayer.volume = 0.5;
if (audioPlayer == nil)
NSLog(@"%@", [error description]);
else
{
[audioPlayer prepareToPlay];
[audioPlayer play];
}
In .h file I have the import for AVFoundation and
AVAudioPlayer *audioPlayer;
and the AVFoundation.framework is in its place
I’m really getting crazy with this thing… any help will be very very much appreciated.
Thanks, Massy
1 Answer