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

你可能感兴趣的文章
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置服务器文件上传与下载
查看>>
Nginx 配置清单(一篇够用)
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
Nginx 集成Zipkin服务链路追踪
查看>>
nginx 集群配置方式 静态文件处理
查看>>
nginx+mysql+redis+mongdb+rabbitmq 自动化部署脚本
查看>>
nginx+php的搭建
查看>>
nginx+tomcat+memcached
查看>>
Nginx+Tomcat实现动静分离
查看>>
nginx+Tomcat性能监控
查看>>
nginx+uwsgi+django
查看>>
nginx+vsftp搭建图片服务器
查看>>
Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流
查看>>
nginx-vts + prometheus 监控nginx
查看>>
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>