Linphone SDK - 如何打开外放
Linphone SDK - how to turn on loud speaker
我正在通过 Linphone SDK 构建一个视频聊天应用程序。
有一个问题,当某人"receives"视频通话时,扬声器默认关闭,因此用户需要使用phone扬声器,phone 呼叫,而不是外放。不过同时,来电者的喇叭默认是开着的。
LinphoneManager.getInstance().routeAudioToSpeaker();
我以为这是林phone打开扬声器的代码,但实际上不是。
用户接听视频电话时默认开启外放如何?
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};
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
}*/
}
}
我正在通过 Linphone SDK 构建一个视频聊天应用程序。
有一个问题,当某人"receives"视频通话时,扬声器默认关闭,因此用户需要使用phone扬声器,phone 呼叫,而不是外放。不过同时,来电者的喇叭默认是开着的。
LinphoneManager.getInstance().routeAudioToSpeaker();
我以为这是林phone打开扬声器的代码,但实际上不是。
用户接听视频电话时默认开启外放如何?
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};
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
}*/
}
}