博客
关于我
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) 不生效
阅读量:487 次
发布时间:2019-03-07

本文共 611 字,大约阅读时间需要 2 分钟。

在项目中使用AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)来实现系统震动功能时,我遇到了一个令人困惑的问题。尽管设备本身支持震动,但在实际项目中却无法正常产生震动。我开始按照文档操作,最终发现问题可能与AVAudioSession的设置有关。

首先,确认设备是支持的,运行单独的demo时震动正常。接着,我注意到AVAudioSession.sharedInstance().category返回的是playAndRecord,这可能影响震动功能。我查阅了资料,发现在playAndRecord模式下,mode属性的设置会影响震动效果。当mode设置为default时,震动可能无法生效。

经过多次尝试,发现将AVAudioSessionmode设置为voiceChat后,震动功能恢复正常。进一步查看文档,了解到voiceChat模式用于优化多路音频处理,即使未手动设置也可能因为使用了Voice-Processing I/O而自动调整。

最终,我确认将AVAudioSessionmode改为voiceChat能够解决问题,系统震动功能正常运行。这次经历提醒我,在开发过程中要重视所有可能影响功能的属性设置,确保每一步的设置都与预期相符。

通过系统化的排查和深入理解AVAudioSession的作用,我成功解决了问题,也加深了对iOS音频处理机制的理解。

转载地址:http://gcrdz.baihongyu.com/

你可能感兴趣的文章
Pillow lacks the JPEG 2000 plugin
查看>>
ping 命令的七种用法,看完瞬间成大神
查看>>
Pinia:$patch的使用场景
查看>>
Pinia:$subscribe()的使用场景
查看>>
Pinpoint对Kubernetes关键业务模块进行全链路监控
查看>>
Pinterest 大规模缓存集群的架构剖析
查看>>
pintos project (2) Project 1 Thread -Mission 1 Code
查看>>
PinYin4j库的使用
查看>>
PIP
查看>>
pip install goose-extractor // SyntaxError: Missing parentheses in call to 'print'
查看>>
pip install 出现报asciii码错误的解决
查看>>
pip throws TypeError: parse() got an unexpected keyword argument ‘transport_encoding‘ 在尝试安装新软件包时
查看>>
pip 下载慢
查看>>
pip 安装出现异常
查看>>
Pip 安装失败:需要 SSL
查看>>
Pip 安装挂起
查看>>
pip/pip3更换国内源
查看>>
pip3 install PyQt5 --user 失败
查看>>
pip3命令全解析:Python3包管理工具的详细使用指南
查看>>
pip3安装命令重复创建文件‘/tmp/pip-install-xxxxx/package‘失败
查看>>