1

我正在通过 Linphone SDK 构建一个视频聊天应用程序。

存在一个问题,当有人“接听”视频通话时,扬声器默认关闭,因此用户需要使用电话扬声器,即用于通话的扬声器,而不是扬声器。但是,同时,拨打电话的人默认打开扬声器。

LinphoneManager.getInstance().routeAudioToSpeaker();

我以为这是 Linphone 打开扬声器的代码,但实际上不是。

用户默认接听视频电话,如何开启外放?

4

3 回答 3

2

LinphoneCore有两种方便的方法:

启用扬声器(布尔值)

静音麦克风(布尔值)

只需在里面创建辅助函数LinphoneManager

public void enableVoice() {
    getLc().muteMic(false);
    getLc().enableSpeaker(true);
}

public void disableVoice() {
    getLc().muteMic(true);
    getLc().enableSpeaker(false);
}

如果您无权访问LinphoneManager,则上述函数应调用:

LinphoneManager.getLc().{method_call};
于 2016-12-06T10:42:16.417 回答
0
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    
    ....
    
    btnSpeaker.setOnClickListener {
        mIsSpeakerEnabled = !mIsSpeakerEnabled
        it.isSelected = mIsSpeakerEnabled
        toggleSpeaker()
    }

    ....
  
}



private fun toggleSpeaker() {

        val currentAudioDevice = core.currentCall?.outputAudioDevice
        val speakerEnabled = currentAudioDevice?.type == AudioDevice.Type.Speaker

        for (audioDevice in core.audioDevices) {
            if (speakerEnabled && audioDevice.type == AudioDevice.Type.Earpiece) {
                core.currentCall?.outputAudioDevice = audioDevice
                return
            } else if (!speakerEnabled && audioDevice.type == AudioDevice.Type.Speaker) {
                core.currentCall?.outputAudioDevice = audioDevice
                return
            }/* If we wanted to route the audio to a bluetooth headset
            else if (audioDevice.type == AudioDevice.Type.Bluetooth) {
                core.currentCall?.outputAudioDevice = audioDevice
            }*/
        }
    }
于 2021-07-27T07:34:56.937 回答
0
private AudioManager mAudioManager;

...

public LinphoneMiniManager(Context c) {
        mContext = c;
        mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));

        mAudioManager.setSpeakerphoneOn(true);
...
于 2020-03-06T00:49:37.713 回答