本文介绍了为什么音频在模拟器中工作但在我的iPad上没有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正致力于创建一个非常简单的应用。 2个按钮,都播放声音。每个剪辑持续1秒钟并响应TouchUpInside。它们是我在iTunes中转换的.caf文件。
I am working on creating a very simple app. 2 buttons, both play sound. Each clip lasts 1 second and responds to "TouchUpInside". They are .caf files that I converted in iTunes.
这是我的代码,再一次,它可以在模拟器中运行但不在设备上运行:
Here is my code, once again, it works in the simulator but not on the device:
enter code here- (void)viewDidLoad {
NSLog(@"InView did load");
AudioServicesCreateSystemSoundID ((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"bigaif" ofType:@"caf"]], &systemSoundID);
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource: @"smallwav" ofType:@"wav"]],
&systemSoundIDTwo);
}
-(IBAction) playSound:(id) sender {
AudioServicesPlaySystemSound(systemSoundID);
}
-(IBAction) playSoundTwo:(id) sender {
AudioServicesPlaySystemSound(systemSoundIDTwo);
}
推荐答案
我找到了答案。我正在使用SystemSound,你知道什么,我的设备设置中的系统声音已静音。
I found my answer. I was using SystemSound and what do you know, I had my system sounds muted in my device settings.
这篇关于为什么音频在模拟器中工作但在我的iPad上没有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!