gpt4 book ai didi

ipad - 声音无法在真实设备上播放

转载 作者:行者123 更新时间:2023-12-03 02:25:37 25 4
gpt4 key购买 nike

我正在尝试使用以下代码在iPad上播放声音:

-(void)playSound:(NSString *)filename {
SystemSoundID soundID;
NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:@"wav"];


if (path) {

UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;

AudioSessionSetProperty (
kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
&sessionCategory
);

AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path],&soundID);
AudioServicesPlaySystemSound (soundID);

}
}

声音正在模拟器中播放,但是在真实设备上不起作用(不,它没有被静音:-))

最佳答案

检查文件扩展名是否区分大小写,是“WAV”还是“Wav” ...而不是“wav”
或出于相同原因检查文件名。

那可以解决您的问题。

关于ipad - 声音无法在真实设备上播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5592716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com