博客
关于我
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/

你可能感兴趣的文章
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
no1
查看>>