AudioServicesPlaySystemSound 在模拟器 xCode 6 GM 上静音

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25859337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:34:22  来源:igfitidea点击:

AudioServicesPlaySystemSound muted on simulator xCode 6 GM

iosxcodeavaudioplayer

提问by carlodurso

I run the following code on simulator and I don't get any sound:

我在模拟器上运行以下代码,但没有任何声音:

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"pageflip" ofType:@"mp3"];
NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];

AudioServicesCreateSystemSoundID((__bridge CFURLRef) soundUrl, &_soundEffect);
AudioServicesPlaySystemSound(_soundEffect);

The code has been successfully tested on xCode 5 and iOS 7. Libraries imported as required.

该代码已在 xCode 5 和 iOS 7 上成功测试。根据需要导入库。

I've logged the soundPath and it returns the correct location on the filesystem.

我已经记录了 soundPath 并且它返回了文件系统上的正确位置。

Has anyone experienced a similar issue?

有没有人遇到过类似的问题?

回答by carlodurso

This is an issue with the simulator. On a device it'll work as expected.

这是模拟器的问题。在设备上它会按预期工作。

回答by Frankeex

I have a similar issue now. My AudioServicesPlaySystemSound was working until the XCode update to 6.0.1. One could assume that there is something broken in the update.

我现在有一个类似的问题。我的 AudioServicesPlaySystemSound 一直在工作,直到 XCode 更新到 6.0.1。人们可以假设更新中有一些问题。