修复连麦时可能出现50007问题,出现该错误时尝试离开房间后重试加入

This commit is contained in:
zlzw 2023-03-15 15:49:56 +08:00
parent 06dddb5273
commit fe29d307a9

View File

@ -123,6 +123,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private TextView debugView; private TextView debugView;
private LiveExoPlayerManager mPlayer; private LiveExoPlayerManager mPlayer;
private boolean isPk = false; private boolean isPk = false;
private boolean userJoinLinkMic = false;//用户是否已加入房间
//0未申请1申请中2连麦中 //0未申请1申请中2连麦中
RCRTCRoom rcrtcRoom; RCRTCRoom rcrtcRoom;
@ -734,6 +735,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() { RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
userJoinLinkMic = false;
Log.e("ry", "退出多人房间成功"); Log.e("ry", "退出多人房间成功");
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() { public void run() {
@ -883,6 +885,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void UsertoRY() { public void UsertoRY() {
userinputStreamList.clear(); userinputStreamList.clear();
Log.e("ry", "主播同意了UsertoRY"); Log.e("ry", "主播同意了UsertoRY");
if (userJoinLinkMic) {//已经在房间内不再joinRoom直接去连麦
subscribeMic(rcrtcRoom);
return;
}
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create() RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
// 根据实际场景选择音视频直播LIVE_AUDIO_VIDEO 或音频直播LIVE_AUDIO // 根据实际场景选择音视频直播LIVE_AUDIO_VIDEO 或音频直播LIVE_AUDIO
.setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO) .setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO)
@ -893,7 +899,41 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override @Override
public void onSuccess(RCRTCRoom data) { public void onSuccess(RCRTCRoom data) {
userJoinLinkMic = true;
rcrtcRoom = data; rcrtcRoom = data;
subscribeMic(data);
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", LiveActivity.mLiveUid + errorCode + "");
if (errorCode.getValue() == 50007) {//userJoinLinkMic可能失效直接leaveRoom
userJoinLinkMic = false;
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
ToastUtil.show("离开房间成功");
UsertoRY();
}
});
}else{
ToastUtil.show("房间失败" + errorCode);
}
}
});
}
private void subscribeMic(RCRTCRoom data) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -938,19 +978,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
}); });
} }
}); });
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", LiveActivity.mLiveUid + errorCode + "");
ToastUtil.show("房间失败" + errorCode);
}
});
} }
/** /**
@ -1246,9 +1273,4 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
} }