我正在尝试使用 AVAudioPlayer 播放简单的声音,但我一直在控制台中收到此错误:
2011-09-02 20:29:07.369 MusicLog[967:10103] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
这是我的代码,当我按下按钮时应该播放声音:
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"tick" ofType:@"caf"];
NSError *error;
NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
AVAudioPlayer *tickPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:&error];
[tickPlayer setDelegate:self];
[tickPlayer setNumberOfLoops:0];
[tickPlayer prepareToPlay];
if (tickPlayer == nil)
{
NSLog(@"%@", [error description]);
}
else
{
[tickPlayer play];
}
我是不是把文件放在了错误的地方?我只是将文件拖到项目中,并根据需要选择副本。
编辑:经过更多测试后,我发现在运行 IOS 4.2 模拟器时不会出现此错误,仅在 IOS 5 模拟器上出现。我可以假设这是 iOS 5 中的错误吗?
谢谢,
最佳答案
我遇到了同样的问题。这似乎只是模拟器中 iOS5 上的问题。我还没有在 iOS 5 设备上测试过。我一直希望 XCode 升级会消除错误,但到目前为止运气不好。
关于iphone - AVAudioPlayer 错误加载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7290418/