4
votes

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:Adithya.K

1 Answers

2
votes
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);
        }