我正在通过linphone SDK构建视频聊天应用。
有一个问题是,当某人"接收"视频通话时,默认情况下响亮的扬声器会关闭,因此用户需要使用电话扬声器(用于电话的扬声器,而不是大声扬声器。但是,与此同时,默认情况下,打电话给电话的发言人大声。
LinphoneManager.getInstance().routeAudioToSpeaker();
我认为这是Linphone大声扬声器的代码,但实际上不是。
当用户默认收到视频通话时,我该如何打开扬声器?
LinphoneCore
有两种方便的方法:
enableSpeaker(boolean)
mutemic(boolean)
只需在LinphoneManager
中创建助手功能:
public void enableVoice() {
getLc().muteMic(false);
getLc().enableSpeaker(true);
}
public void disableVoice() {
getLc().muteMic(true);
getLc().enableSpeaker(false);
}
如果您无法访问LinphoneManager
,则以上功能应致电:
LinphoneManager.getLc().{method_call};
private AudioManager mAudioManager;
...
public LinphoneMiniManager(Context c) {
mContext = c;
mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));
mAudioManager.setSpeakerphoneOn(true);
...
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
}*/
}
}