首页 文章

如何从手机,手机扬声器,耳机或蓝牙设备切换音频输出

提问于
浏览
3

我试图在我的应用程序中的不同源之间切换音频源 . 我们使用第三方视频库并使用AudioManager播放声音 . 现在我们尝试使用UI选项在电话耳机,电话扬声器,耳机/蓝牙(任何连接)之间的音频输出之间进行选择 . 就像我们在Phone Call应用程序中看到的那样(当多个音频输出源可用时,手机,扬声器,蓝牙) .

1 回答

  • 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);
            }
    

相关问题