首页 > 解决方案 > 如果已连接,如何将音频路由切换到蓝牙耳机

问题描述

如何在通话中切换音频路由(从扬声器到 ios 中的蓝牙耳机)或将默认连接设置为蓝牙耳机(如果已连接),我使用的是react-native-incall-manager包。

我曾尝试调用 InCallManager.chooseAudioRoute('BLUETOOTH') 但它不起作用。这是我的代码

if (this.props.isBluetoothConnected) {
  InCallManager.chooseAudioRoute('BLUETOOTH');
} else {
  if (this.props.isEarPhonePlugged) {
    InCallManager.setForceSpeakerphoneOn(false);
    InCallManager.chooseAudioRoute('EARPIECE')
  } else {
    InCallManager.start({media: 'video'});
    InCallManager.chooseAudioRoute('SPEAKER_PHONE')
    InCallManager.setForceSpeakerphoneOn(true);
  }
}

标签: react-nativeexporeact-native-androidreact-native-iosios-bluetooth

解决方案


推荐阅读