我的音板应用程序在模拟器上播放声音,但不播放设备

时间:2012-02-01 01:16:23

标签: ios xcode audio

我正在Xcode 4.2上制作一个音板应用程序。当我在模拟器上运行应用程序时,声音播放正常。但是,当我在设备上运行时,没有声音会播放。我的代码如下。

- (IBAction)awhaaa:(id)sender {

    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"awhaaa", CFSTR ("wav"),NULL);
    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);
}

2 个答案:

答案 0 :(得分:2)

是真的名为awhaaa.wav的文件吗?模拟器,因为它在你的mac上运行,是不区分大小写的。手机区分大小写,所以如果文件是aWhaaa.WAV或awHAaA.wAv,它将在模拟器中工作,但不在设备上。

答案 1 :(得分:1)

检查以下内容:在设备上,进入设置并调高音量 - > Ringer and Alerts

然后再试一次。