音频将在iPhone模拟器中播放,但不会在设备上播放
问题描述:
基本上,当我的应用程序上的按钮被触摸时,播放音频。很简单,但它却无法在我的实际设备上工作,但在模拟器中运行良好。当按钮被触摸时,执行该功能:音频将在iPhone模拟器中播放,但不会在设备上播放
- (IBAction)playButtonSound
{
SystemSoundID buttonSound;
NSURL *tapSound = [[NSBundle mainBundle] URLForResource: @"Button_Sound" withExtension: @"caf"];
CFURLRef buttonSoundURLRef = (CFURLRef) [tapSound retain];
AudioServicesCreateSystemSoundID (buttonSoundURLRef, &buttonSound);
AudioServicesPlaySystemSound(buttonSound);
[tapSound release];
}
我还是一个新手iPhone,所以我不能完全肯定这种情况的原因是什么。
答
您的设备上是否禁用了系统声音?顾名思义,如果用户禁用了系统声音,则通常不会播放AudioServicesPlaySystemSound
。有一个属性kAudioServicesPropertyIsUISound
,应该可以设置为NO来禁用此行为。
我不这么认为。 是的,我检查了文件名,他们是正确的。 – Robbeh 2011-04-06 03:03:51