1

我有一个应用程序可以播放声音片段作为提示音。在实际设备上一切正常,但在模拟器上崩溃。

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4a"];
NSString *expandedFilePath = [filePath stringByExpandingTildeInPath];
NSURL *fileURL = [NSURL fileURLWithPath:expandedFilePath];
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
[self.player play];

我发现很多关于模拟器问题的帖子,有些人建议使用 stringByExpandingTildeInPath 但这没什么区别。我尝试过 mp3、m4a 和 wav 文件,它们的行为方式都相同。在 6.0 和 6.1 模拟器中我没有收到错误,但是当我在 5.1 模拟器中运行它时,我在控制台中收到以下错误:

2013-04-04 10:57:03.682 MyAppName[51504:1b03] 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: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security

只要代码没有可能导致真实设备出现问题的根本问题,我可能可以忍受这一点。

4

1 回答 1

0

模拟器很有趣AVAudioPlayer你应该在真实设备上测试你的代码,但是你发布的看起来不错。

于 2013-04-04T17:10:47.207 回答