音频路由歌蓝牙编程? [英] Route Audio song to blue-tooth programmatically?
问题描述
怎么听从蓝牙设备我的音频文件,编程?
我在前面和后面扬声器之间已经路线我的音频文件,而路由通过蓝牙。
How to listen my audio file from Blue-Tooth device, programmatically? I have already route my audio file in between front and rear speaker, while routing over Bluetooth.
推荐答案
如果将设备连接到蓝牙,音频通过设备播放将通过蓝牙流唯一正确的?
If the device is connected to a bluetooth, audio played through the device will be streamed through bluetooth only right?
因此,也许你可以先检查设备是否连接到蓝牙设备搭配:
So maybe you can first check whether the device is connected to a bluetooth device with :
AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
if(audioManager.isBluetoothA2dpOn()) {
// Play audio...
}
Android的 AudioManager 类有更多的细节你可以钻进去。
Android's AudioManager class has more details what you can dig into.
如果蓝牙未连接,您可以以编程方式检查并连接到使用蓝牙机器人的包。
If the bluetooth is not connected you can programmatically check and connect to available bluetooth devices using Androids bluetooth package.
这篇关于音频路由歌蓝牙编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!