ios - 用手机录制音频,但在 iOS 中通过蓝牙耳机播放录音
问题描述
是否可以用手机录制声音但通过蓝牙耳机强制播放?
这就是我设置 AVAudioSession 类别的方式
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with:[AVAudioSessionCategoryOptions.mixWithOthers])
录音被迫使用手机麦克风。但是,在播放声音时,它也会从手机中发出。我希望仅通过蓝牙耳机播放声音。
我尝试覆盖输出音频端口
try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.none)
但仍然没有工作。
解决方案
问题已经解决了。我刚刚添加了 allowBluetoothA2DP 选项,然后它就可以工作了。
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with:[AVAudioSessionCategoryOptions.allowBluetoothA2DP, AVAudioSessionCategoryOptions.mixWithOthers])
推荐阅读
- reactjs - Reactjs Facebook 登录
- django - 在 docker build 中运行“/usr/local/bin/gunicorn”会显示“stat /usr/local/bin/gunicorn:没有这样的文件或目录”
- r - 绘制二进制和连续值的热图
- javascript - 有没有可能使用javascript中的ISOtime格式找到时区的方法
- vue.js - Nuxt 中的服务器端单例注入
- r - 使用 R.Update 时的维数不正确
- sql - SQL 语句的索引
- wordpress - Wordpress:创建图片库时选择图片大小
- java - 通过对 element.getText() 的一次调用从 XPath 结果中排除某些子节点?
- javascript - 从默认路由重定向到另一条路由时的延迟