我想将语音路由到蓝牙。
下面的代码是我的播放器。
AudioTrack at;
try {
minbuffer = AudioTrack.getMinBufferSize(8000,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT);
if (minbuffer < VOICE_SPEECH_SIZE)
minbuffer = VOICE_SPEECH_SIZE;
at = new AudioTrack(AudioManager.STREAM_VOICE_CALL, 8000,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, minbuffer,
AudioTrack.MODE_STREAM);
at.play();
while (PlayOutblinker == Thread.currentThread()) {
byte[] tt = vbuff.take();
at.write(tt, 0, tt.length);
}
} finally {
at.stop();
at.release();
at = null;
}
我搜索并找到以下内容:
public static void SetRouteBT(Context context, boolean isRoute) {// TODO
AudioManager mAudioManager = (AudioManager) context
.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
mAudioManager.startBluetoothSco();
mAudioManager.setBluetoothScoOn(isRoute);
}
但它不起作用。当我setBluetoothScoOn(true)
的声音没有路由但与扬声器和麦克风断开连接时。问题出在哪里?