fix:修复声网上麦后自动开麦问题

This commit is contained in:
Max
2024-01-23 15:22:46 +08:00
parent e478c9c202
commit 522c4a9f6f

View File

@@ -11,6 +11,9 @@ import com.nnbc123.library.utils.SingleToastUtil;
import io.agora.rtc2.ClientRoleOptions;
import io.agora.rtc2.Constants;
import io.agora.rtc2.IRtcEngineEventHandler;
import io.reactivex.Observable;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
/**
* @author by 梁馨 on 2020/9/14.
@@ -129,7 +132,12 @@ public class EngineEventHandler extends IRtcEngineEventHandler {
super.onClientRoleChanged(oldRole, newRole, newRoleOptions);
//角色切换 麦克风切换
if (newRole == Constants.CLIENT_ROLE_BROADCASTER) {
RtcEngineManager.get().setMute(RtcEngineManager.get().isMute);
com.chuhai.utils.log.LogUtil.INSTANCE.d(TAG, "onClientRoleChanged() setMute mute:"+RtcEngineManager.get().isMute,false);
Observable.create((ObservableOnSubscribe) emitter -> {
com.chuhai.utils.log.LogUtil.INSTANCE.d(TAG, "onClientRoleChanged() setMute-main mute:"+RtcEngineManager.get().isMute,false);
RtcEngineManager.get().setMute(RtcEngineManager.get().isMute);
emitter.onComplete();
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
@@ -151,6 +159,7 @@ public class EngineEventHandler extends IRtcEngineEventHandler {
super.onRemoteAudioStats(remoteAudioStats);
Logger.t(TAG).d("onRemoteAudioStats uid%d", remoteAudioStats.uid);
long uid = (long) remoteAudioStats.uid;
com.chuhai.utils.log.LogUtil.INSTANCE.d(TAG, "onRemoteAudioStats() setRemoteMute mute:"+(!AvRoomDataManager.get().checkIsOnMicByAccount(uid + "")),false);
// 如果麦上没有这个人,不接收这个人的声音
RtcEngineManager.get().setRemoteMute(uid, !AvRoomDataManager.get().checkIsOnMicByAccount(uid + ""));