问题
Im trying to switch the audio source between different source in my app. We use a 3rd party Video Library and use AudioManager to play the sound. Now we are trying to have a UI option to select between audio output between Phone ear piece, Phone Speaker, Headphones/ Bluetooth (is any connected). Like we see in Phone Call app (when multiple audio output sources are available phone, speaker, bluetooth).
回答1:
Got it working: 'if(false) {
//For BT
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
mAudioManager.startBluetoothSco();
mAudioManager.setBluetoothScoOn(true);
} else if(true) {
//For phone ear piece
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
mAudioManager.stopBluetoothSco();
mAudioManager.setBluetoothScoOn(false);
mAudioManager.setSpeakerphoneOn(false);
} else {
//For phone speaker(loudspeaker)
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mAudioManager.stopBluetoothSco();
mAudioManager.setBluetoothScoOn(false);
mAudioManager.setSpeakerphoneOn(true);
}
来源:https://stackoverflow.com/questions/47057889/how-to-switch-audio-output-from-phone-phone-speaker-earphones-or-bluetooth-dev