简体   繁体   English

无法在Xcode iPhone模拟器上播放声音

[英]Can't Play Sound on Xcode iphone simulator

I am trying to play a sound thats linked to a button, but I get the following error code. 我正在尝试播放链接到按钮的声音,但出现以下错误代码。 How can I fixed this problem? 我该如何解决这个问题?

2012-01-13 07:22:58.887 M3NYFAC3Z[5875:1e03] Error loading /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: _CFXMLNodeGetInfoPtr Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 2012-01-13 07:22:58.887 M3NYFAC3Z [5875:1e03]加载错误/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:dlopen(/ System / Library /扩展/ AudioIPCDriver.kext / Contents / Resources / AudioIPCPlugIn.bundle / Contents / MacOS / AudioIPCPlugIn,262):找不到符号:_CFXMLNodeGetInfoPtr参考自:/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 2012-01-13 07:22:58.892 M3NYFAC3Z[5875:1e03] Error loading /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: _CFXMLNodeGetInfoPtr Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 预期:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security 2012-01-13 07:22:58.892 M3NYFAC3Z [5875:1e03]加载错误/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:dlopen(/ System / Library /扩展/ AudioIPCDriver.kext / Contents / Resources / AudioIPCPlugIn.bundle / Contents / MacOS / AudioIPCPlugIn,262):找不到符号:_CFXMLNodeGetInfoPtr参考自:/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 2012-01-13 07:25:28.994 M3NYFAC3Z[5875:1e03] AQMEIO_Base::DoStartIO: timeout 2012-01-13 07:25:29.271 M3NYFAC3Z[5875:1e03] AQMEDevice(0x8831a00)::StartIO: error -66681 2012-01-13 07:25:29.272 M3NYFAC3Z[5875:1e03] CA_UISoundClientBase::StartPlaying: AddRunningClient failed (status = -66681). 预期:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security 2012-01-13 07:25:28.994 M3NYFAC3Z [5875:1e03] AQMEIO_Base :: DoStartIO:timeout 2012-01-13 07:25:29.271 M3NYFAC3Z [5875:1e03] AQMEDevice(0x8831a00):: StartIO:error -66681 2012 -01-13 07:25:29.272 M3NYFAC3Z [5875:1e03] CA_UISoundClientBase :: StartPlaying:AddRunningClient失败(状态= -66681)。 [Switching to process 5875 thread 0x207] sharedlibrary apply-load-rules all [切换到进程5875线程0x207] sharedlibrary apply-load-rules all

This is my code: 这是我的代码:

-(IBAction)playobey:(id)sender { 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"renegadeyamaha" ofType:@"wav"];
    AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 
    [audioPlayer play];
}

You need to keep a reference to your AVAudioPlayer in an ivar/property somewhere. 您需要在某处的ivar / property中保留对AVAudioPlayer的引用。 It's probably being created and then released immediately before it's had a chance to finish playing your sound. 它可能正在创建,然后在它有机会完成播放声音之前立即发布。

I wrote a little AVAudioPlayer-based sound player class that might make your life easier: 我写了一个基于AVAudioPlayer的小型声音播放器类,可以让你的生活更轻松:

https://github.com/nicklockwood/SoundManager https://github.com/nicklockwood/SoundManager

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM