我正在创建一个非常简单的应用程序。 2个按钮,都播放声音。每个剪辑持续1秒钟并回应“TouchUpInside”。他们是我在iTunes中转换的.caf文件。为什么音频在模拟器中工作,但不在我的iPad上?
这里是我的代码,再次,它工作在模拟器,但无法在设备上:
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);
}
文件名没有问题吗?面对mac被设置为casemapping的事实,并且由于文件名中的拼写错误,情况相同 – aknew
嗯,我自己弄明白了。我想发布解决方案,以便其他人不会犯这个错误。使用“SystemSound”时,确保您的设置中启动了系统声音。 – JoshD