gpt4 book ai didi

iphone - 用自定义声音振动 iphone/ipod

转载 作者:太空狗 更新时间:2023-10-30 03:52:13 26 4
gpt4 key购买 nike

我有自己的声音,我想在手机振动时播放,最常见的做法是:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

但这是使用系统的声音。有没有办法使用我自己的声音?我可以使用什么格式的声音?

最佳答案

查看 AudioServicesPlayAlertSound ,如果用户在他们的声音设置中启用了振动,这将播放自定义声音和振动。正确的用法应该是这样的……

SystemSoundID soundFileObject;

NSURL * soundFileURL= [[NSBundle mainBundle] URLForResource: @"mySoundFile" withExtension: @"aif"];

CFURLRef soundFileURLRef = (CFURLRef) [soundFileURL retain];

AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);

AudioServicesPlayAlertSound (soundFileObject);

根据以上链接,支持的文件类型为 .caf、.aif 或 .wav。希望对您有所帮助!

关于iphone - 用自定义声音振动 iphone/ipod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6970534/

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