gpt4 book ai didi

iphone - 为什么我的 .aif 短声音文件只能在 iOS 模拟器上播放,而不能在设备上播放?

转载 作者:搜寻专家 更新时间:2023-10-30 20:19:35 24 4
gpt4 key购买 nike

我希望根据按下的按钮在我的 iPhone (iOS 6.1) 上播放声音。

转换为 aif、caf、wav 和压缩格式后,我无法在设备上播放声音。已检查音量,已重新启动设备,文件名中不包含大写字母。

我阅读了很多关于这个问题的主题,但找不到合适的解决方案,这意味着我的问题要么更复杂,要么很愚蠢——当然很愚蠢。

这是我播放声音的代码:

// Plays sound of given filename
- (void) playSound:(NSString*)name {
SystemSoundID sound = [self createSoundID:name];
AudioServicesPlaySystemSound(sound);
NSLog(@"file played: %@",name);
}

// Creates a playable sound out of filename
-(SystemSoundID) createSoundID:(NSString*) name
{
NSString *path = [NSString stringWithFormat: @"%@/%@",
[[NSBundle mainBundle] resourcePath], name];


NSURL* filePath = [NSURL fileURLWithPath: path isDirectory: NO];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
return soundID;
}

最佳答案

如果声音在模拟器上运行良好但在真实设备上运行不正常,则意味着您应该打开设备的铃声和警报设置。您还应该检查静音按钮是否打开。

关于iphone - 为什么我的 .aif 短声音文件只能在 iOS 模拟器上播放,而不能在设备上播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15813409/

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