补充下麦时调用融云接口

This commit is contained in:
zlzw 2022-11-24 16:35:33 +08:00
parent 86a0a19fec
commit ec40f8fa0d

View File

@ -1,14 +1,22 @@
package com.yunbao.live.utils; package com.yunbao.live.utils;
import android.os.Handler;
import android.os.Looper;
import android.util.Log; import android.util.Log;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveActivity;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
import cn.rongcloud.rtc.base.RTCErrorCode;
/** /**
* 统一管理连麦状态 * 统一管理连麦状态
*/ */
@ -67,9 +75,54 @@ public class MicStatusManager {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
Log.e("ry", code + "退出多人"); Log.e("ry", code + "退出多人");
clear(); RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {
/**
* 当切换失败且SDK处于无法回退状态时回调该角色已经无法使用当前角色继续进行音视频
* SDK内部会退出房间并清理所有资源该用户只能重新加入房间才能继续音视频
*/
@Override
public void onKicked() {
}
@Override
public void onSuccess() {
Log.e("ry", "下麦成功");
// 该用户切换为观众成功可以以观众身份进行音视频
//退出rtc播放
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "退出多人房间成功");
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
MicStatusManager.getInstance().clear();
ToastUtil.show("已成功退出語音連麥");
}
});
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", errorCode + "退出多人房间成功");
}
});
}
/**
* 当切换失败且不影响当前角色继续音视频时回调
* @param errorCode 失败错误码
*/
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "下麦失败" + errorCode);
}
});
} }
}); });
EventBus.getDefault().post("endMic");
} }
} }