[英]On android how to reroute audio from a2dp
I have a Samsung vibrant and I am connecting to to my car using bluetooth. 我有一个三星充满活力,我正在使用蓝牙连接到我的车。 In the samsung music app there is a button to route the audio to via bluetooth or via phone. 在三星音乐应用程序中,有一个按钮可以通过蓝牙或电话路由音频。
Anyone know how there were able create this functionality. 任何人都知道如何创建此功能。 I looked at the sdk and I see 我看着sdk,我看到了
ROUTE_BLUETOOTH_A2DP ROUTE_BLUETOOTH_A2DP
This constant is deprecated. 不推荐使用此常量。 Do not set audio routing directly, use setSpeakerphoneOn(), setBluetoothScoOn() methods instead. 不要直接设置音频路由,而是使用setSpeakerphoneOn(),setBluetoothScoOn()方法。
Routing audio output to bluetooth A2DP Constant Value: 16 (0x00000010) 将音频输出路由到蓝牙A2DP常数值:16(0x00000010)
but as you can see it is listed as "deprecated", i see the option for setBluetoothScoOn, but not an equivalent to for setting a2dp on. 但正如你可以看到它被列为“已弃用”,我看到了setBluetoothScoOn的选项,但不等同于设置a2dp的选项。
My end goal would be to create a widget that allows me to turn on and off outing to the a2dp. 我的最终目标是创建一个小部件,允许我打开和关闭外出到a2dp。 So I can turn it on when I want to stream music and turn it off when I want to use navigator, but listen to music or the radio at the same time. 因此,当我想要使用导航器播放音乐并将其关闭时,我可以打开它,但同时听音乐或收音机。
Here's what you are looking for: (not sure if this was available at the time of your question...) 以下是您要找的内容:(不确定您的问题是否可用...)
setBluetoothA2dpOn();
But it's also deprecated. 但它也被弃用了。
My guess would be to use this instead: 我的猜测是使用它代替:
audioManager.startBluetoothSco();
audioManager.setBluetoothScoOn(true);
And to stop routing: 并停止路由:
audioManager.setBluetoothScoOn(false);
audioManager.stopBluetoothSco();
audioManager is a instance of the AudioManager. audioManager是AudioManager的一个实例。
Here's a reference to AudioManager: AudioManager 这是对AudioManager: AudioManager的引用
Hope this helps, cheers 希望这会有所帮助,欢呼
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.