初始化 AVAudioSession 时保持蓝牙声音 [英] Keep bluetooth sound when initializing AVAudioSession

查看:32
本文介绍了初始化 AVAudioSession 时保持蓝牙声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我快要疯了.

我有一个录音应用.我遇到了一个问题,当我打开我的应用程序时,如果我在蓝牙设备上听音乐,它会自动路由回手机内置扬声器.

I have a recording app. I'm running into a problem that when I open my app, if i'm listening to music on a bluetooth device, it gets automatically routed back to the phone internal speaker.

无论如何我都希望一切都保持不变.即使我开始录音,如果用户正在听蓝牙扬声器上的东西,请继续这样做.用户有耳机吗?把音乐留在那里.就让一切保持原样.

I want everything to stay the same no matter what. Even when I start recording, if the user is listening to something on a bluetooth speaker, keep doing that. The user has headphones? Keep the music there. Just leave everything as is.

这是我目前初始化会话的方式:

This is how I'm currently initializing my session:

[[AVAudioSession sharedInstance]
    setCategory:AVAudioSessionCategoryPlayAndRecord
    withOptions:AVAudioSessionCategoryOptionMixWithOthers | AudioSessionCategoryOptionAllowBluetooth
    error: nil];

我允许它播放、录音、与其他人混音并允许使用蓝牙,那么为什么要将音频输出重新路由回内部扬声器???

I'm allowing it to play, record, mix with others and allow bluetooth, so why is it re routing the audio output back to the internal speaker???

谢谢

5 月 30 日编辑

我设法得到了一些更好的东西,但仍然缺少一些东西.

I managed to get something better but still missing something.

如果我添加这一行:

[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:nil];

音乐留在蓝牙设备中,但听起来很可怕.

The music stays in the bluetooth device BUT it sounds horrible.

根据这个答案:https://stackoverflow.com/a/18541874/517688这是因为

According to this answer: https://stackoverflow.com/a/18541874/517688 it's because

EnableBluetoothInput 据此影响输入和输出.还要记住,由于蓝牙输入设备的限制,音频将以 8000 Hz 播放

EnableBluetoothInput affects both input and output according to this. Also remember, the audio will play at 8000 Hz due to the limitation of bluetooth input devices

因此,在使用蓝牙设备时,没有办法在不使声音失真的情况下保持一切不变??

So there is no way to keep everything the same without distorting sound when using a Blueetooth device??

推荐答案

不幸的是,我直接从 Apple 技术支持那里得到了这个答案

Unfortunately I got this answer directly from Apple Technical Support

鉴于当前交付的系统配置,没有支持的方法来实现所需的功能.如果您希望 Apple 考虑在未来添加对此类功能的支持,请通过位于 http 的 Bug Reporter 工具提交增强请求://bugreport.apple.com.

There is no supported way to achieve the desired functionality given the currently shipping system configurations. If you would like for Apple to consider adding support for such features in the future, please submit an enhancement request via the Bug Reporter tool at http://bugreport.apple.com.

就是这样...

这篇关于初始化 AVAudioSession 时保持蓝牙声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆