即使插入耳机,如何通过蓝牙扬声器播放音频? [英] How to play audio through Bluetooth speaker even when headset is plugged in?

查看:310
本文介绍了即使插入耳机,如何通过蓝牙扬声器播放音频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将手机连接到蓝牙扬声器,并且已插入耳机.现在,我想通过蓝牙扬声器播放音频. 当我将音频流设置为AudioManager.STREAM_MUSIC时,它只能在耳机上播放.

I have my phone connected to a Bluetooth speaker and the headphones plugged in. Now I'd like to play audio through the Bluetooth speaker. When I set the audio stream to AudioManager.STREAM_MUSIC it just plays over the headphones.

也可以在耳机上播放也没关系,但是我需要在蓝牙扬声器上播放它.

It doesn't matter if it plays on the headphones as well but I need it to play on the Bluetooth speaker.

这怎么可能?应用程序SoundAbout可以做到这一点,因此必须有一种方法.

How is this possible? The app SoundAbout manages to do that so there must be a way.

当我插入耳机并仅随后连接到蓝牙扬声器时,所有音频都会通过我想要的蓝牙扬声器播放. 但我不能期望用户发现了这一点,并且在向他们显示复杂的消息之前,我宁愿找到一种方法,使声音在连接到某些扬声器时始终通过BT扬声器播放.

When I plug in the headphones and only afterwards connect to the Bluetooth speakers all audio plays through the Bluetooth speakers which I want. But I can't expect the user to find that out and before having to show them a complicated message I'd rather find out a way to make the sound always play through BT speakers when connected to some.

谢谢

(请注意,这个问题与此不同:

(Note this is not the same question as this: How to Play audio through speaker even when headset is plugged in? I want it to play on Bluetooth speakers, not on the integrated speaker of the phone.)

推荐答案

解决方案

假设您已经在新的媒体播放器实例上测试了STREAM_RING,并且没有直接设置流类型,但没有成功,您需要为蓝牙设备配置正确的配置文件.

Suppose you already tested STREAM_RING on your new instance of media player and not directly setting stream type, and it didn't work out, You need a correct profile for your bluetooth device.

看看本文 阅读实施HAL"部分,其中有很多您可以使用的不同配置文件的来源.

Take a look at this article Read the "Implementing HAL" section, there is alot of source for different profile that you may be able to use.

还有一个简单的解决方案,即在getServiceConnected()方法中将设备配置文件更改为HEADSET,它将变成保持连接的设备,但输出将变为单声道!我记得,这对于扬声器来说很可惜,某些硬件可能不支持A2DP,但仍会被有线耳机打断.

There is also an easy solution which is to change your device profile to HEADSET in your getServiceConnected() method, it will turn into a Stay connected device but the output will become mono! As I recall, Which is a shame for speakers, A2DP also may not be supported in some hardwares and still interrupted by wire headsets.

我建议创建一个新的配置文件并使用它,与HAL一起工作有点棘手,但值得这样做,

I suggest to create a new profile and use it, a little bit tricky working with HAL but will worth it,

很抱歉,目前我无法为您提供源代码.

Sorry that I can not provide a source code for you at the moment.

这篇关于即使插入耳机,如何通过蓝牙扬声器播放音频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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