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

查看:353
本文介绍了保持蓝牙音响初始化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.

根据这样的回答: http://stackoverflow.com/a/18541874/517688 这是因为

According to this answer: http://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

因此​​,有没有办法把一切都相同,而无需使用Blueetooth设备??当声音失真

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

推荐答案

不幸的是,我从苹果技术支持

Unfortunately I got this answer directly from Apple Technical Support

有是实现鉴于目前推出的系统配置所需的功能没有支持的方法。如果您想为苹果考虑在未来增加对这种功能的支持,请 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天全站免登陆