3
我使用此代码,但它不工作;AVAudioPlayer错误
导入:
#import <AudioToolbox/AudioServices.h>
头文件:
AVAudioPlayer *_audioPlayer;
代码:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/welcome.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
_audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
_audioPlayer.numberOfLoops = 0;
if (_audioPlayer == nil)
{
NSLog(@"%@", [error description]);
}
else
{
[_audioPlayer play];
NSLog(@"PLAY");
}
的的NSLog:
Error Domain=NSOSStatusErrorDomain Code=-43 "The operation couldn’t be completed. (OSStatus error -43.)"
它不工作在我的iPhone(5.1)的iPad(5.0)iPhone 5.0模拟器。
任何人都知道我该如何解决这个问题?