我想在我的应用程序中播放声音,因为我正在使用 .mp3 文件类型。它在模拟器中运行良好,但是当我在我的设备上吃午饭时,它不工作并且不产生任何声音,任何人都可以帮助我为什么它不能在设备上工作,或者哪种文件格式更适合在 iPhone 和 iPad 中播放音频文件?
NSURL *tapSound = [[NSBundle mainBundle] URLForResource: [NSString stringWithFormat:@"%@",SoundFileName] withExtension: @""];
// Store the URL as a CFURLRef instance
self.soundFileURLRef = (CFURLRef) [tapSound retain];
// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID (
soundFileURLRef,
&soundFileObject
);
AudioServicesPlaySystemSound (soundFileObject);
以上是我播放声音的代码
谢谢你。