我正在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);
}
是的,那是實際的文件名。我再次檢查以確保拼寫/大小寫是正確的。 – user1176046 2012-02-01 01:52:51
一種可能性是wav文件本身。嘗試將其轉換爲CAF或MP3,看看它是否仍然給你帶來麻煩。 – jsd 2012-02-01 17:32:19