iphone - 音频文件不使用 iphone sdk 播放

标签 iphone objective-c core-audio

我正在尝试在我的 iPhone 应用程序中播放音频文件。我已经使用了这段代码

#import <AVFoundation/AVFoundation.h>

 NSBundle *bundle = [NSBundle mainBundle];
    NSString *musicPath = [bundle pathForResource:@"audioSample" ofType:@"mp3"];
    NSURL *musicURL = [NSURL fileURLWithPath:musicPath];
    NSError *error= [NSError errorWithDomain:@"Domain" code:0 userInfo:nil];

    AVAudioPlayer *aplayer= [[AVAudioPlayer alloc] initWithContentsOfURL:musicURL error:&error];
    aplayer.delegate = self;
    [aplayer play];

但是将运行这个应用程序我得到这个错误。任何人都可以帮我解决这个问题。我不明白为什么会发生这个错误。

System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:  dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 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
2012-08-03 10:12:07.330 SampleAudioCode[591:12003] Error loading /Library/Audio/Plug-Ins/HAL/Digidesign CoreAudio.plugin/Contents/MacOS/Digidesign CoreAudio:  dlopen(/Library/Audio/Plug-Ins/HAL/Digidesign CoreAudio.plugin/Contents/MacOS/Digidesign CoreAudio, 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
2012-08-03 10:12:07.330 SampleAudioCode[591:12003] Cannot find function pointer NewDigiCoreAudioPlugIn for factory B8A063B5-2F3D-444A-88CB-D0B8F1B22042 in CFBundle/CFPlugIn 0xdc50f50 </Library/Audio/Plug-Ins/HAL/Digidesign CoreAudio.plugin> (bundle, not loaded)

谢谢你的回答..

最佳答案

这似乎是仅使用 iOS 模拟器时 AVAudio 框架的问题。在实际硬件上进行测试(在我的例子中是 iPad 2 和 iPad 1)不会产生这些相同的错误

这个错误只是来自系统框架的控制台噪音,你应该忽略它,它不会影响你。如果您的应用程序崩溃或无法播放,真正的原因在别处。

and please also add CoreFoundation framwork.

关于iphone - 音频文件不使用 iphone sdk 播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11789569/

相关文章:

iphone - 访问 iOS 的视频解码器?

objective-c - 如何从 UIColor 对象中获取红绿蓝 (RGB) 和 alpha?

ios - 背景 View 中的视频背景

objective-c - 将 NSError 返回转换为 CFErrorRef 返回

objective-c - 从另一个应用程序获取证书根

iphone - 如何将 mp4 文件从文档复制到照片库(在 iPhone 中)?

ios - 列出创建的类的所有实例

ios - 如何指定 AVAudioEngine Mic-Input 的格式?

ios - AudioKit:如何点击同一输入进行多次使用(AudioKitUI + 语音识别)

ios - AVAudioEngine 分离 channel