修改融云合流不成功的问题,退出画面有问题

This commit is contained in:
18142669586 2023-08-09 14:13:52 +08:00
parent d899975495
commit 7a26e81f67
2 changed files with 272 additions and 196 deletions

View File

@ -1,5 +1,6 @@
package com.yunbao.live.presenter; package com.yunbao.live.presenter;
import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK; import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
@ -36,6 +37,7 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.ViewUtils;
import com.tencent.trtc.TRTCCloud; import com.tencent.trtc.TRTCCloud;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveInfoModel;
@ -714,7 +716,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
inputStreamList.add(stream); inputStreamList.add(stream);
RCRTCMixConfig config = new RCRTCMixConfig(); RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig(); RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig); config.setMediaConfig(mediaConfig);
@ -1128,22 +1129,30 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void leaveDRRoom() { public void leaveDRRoom() {
//清理PK上面对方的头像 //清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", "")); EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
Log.e("ry", "退出多人OKKK" + inputStreamList.size()); Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0; isDRPK = 0;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (btn_close != null) { if (btn_close != null) {
btn_close.setVisibility(View.GONE); btn_close.setVisibility(View.GONE);
} }
}
});
for (int i = 0; i < inputStreamList.size(); i++) { for (int i = 0; i < inputStreamList.size(); i++) {
Log.e("ry", "退出多人ID" + inputStreamList.get(i).getUserId());
//退出副房间 //退出副房间
RCRTCEngine.getInstance().leaveOtherRoom(inputStreamList.get(i).getUserId(), true, new IRCRTCResultCallback() { RCRTCEngine.getInstance().leaveOtherRoom(inputStreamList.get(i).getUserId(), true, new IRCRTCResultCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
Log.e("ry", "退出多人成功");
} }
@Override @Override
public void onFailed(RTCErrorCode rtcErrorCode) { public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", "退出多人失败" + rtcErrorCode);
} }
}); });
@ -2179,6 +2188,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/** /**
* 修改最终PK数据 * 修改最终PK数据
*
* @param leftGift 左边数据 * @param leftGift 左边数据
* @param rightGift 右边数据 * @param rightGift 右边数据
* @param bean 排位数据 * @param bean 排位数据

View File

@ -1,6 +1,7 @@
package com.yunbao.live.views; package com.yunbao.live.views;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
import static com.yunbao.live.activity.LiveActivity.mLiveRyLinkMicPkPresenter; import static com.yunbao.live.activity.LiveActivity.mLiveRyLinkMicPkPresenter;
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList; import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList;
@ -55,6 +56,7 @@ import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.momo.TencentTRTCBeautyManager; import com.yunbao.live.momo.TencentTRTCBeautyManager;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter; import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.socket.SocketSendBean;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -82,6 +84,10 @@ import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RTCErrorCode; import cn.rongcloud.rtc.base.RTCErrorCode;
import cn.rongcloud.rtc.core.CameraVideoCapturer; import cn.rongcloud.rtc.core.CameraVideoCapturer;
import cn.rongcloud.rtc.core.RendererCommon; import cn.rongcloud.rtc.core.RendererCommon;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.message.TextMessage;
/** /**
* Created by cxf on 2018/10/7. * Created by cxf on 2018/10/7.
@ -218,10 +224,54 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override @Override
public void run() { public void run() {
Log.e("ry", inviterRoomId + extra + "Request"); Log.e("ry", inviterRoomId + extra + "Request");
UserBean userBean = new UserBean(); UserBean userBean = new UserBean();
userBean.setId(inviterRoomId); userBean.setId(inviterRoomId);
if (extra.equals(SOCKET_LIVE_DRPK)) { //收到邀请这个时候正在PK或连麦中 自动拒绝对方
if (isPking() == true) {
rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), false, false, "extra", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK)
.param("action", 8);
msg1.create();
String targetId = userBean.getId();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗" + userBean.getId());
}
});
}
});
}else if (extra.equals(SOCKET_LIVE_DRPK)) {
//收到多人PK申请 //收到多人PK申请
if (mLiveRyLinkMicPkPresenter != null) { if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean); mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
@ -381,6 +431,22 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override @Override
public void onFinishOtherRoom(String roomId, String userId) { public void onFinishOtherRoom(String roomId, String userId) {
super.onFinishOtherRoom(roomId, userId); super.onFinishOtherRoom(roomId, userId);
Log.e("ry",roomId+"房间是"+userId);
RCRTCEngine.getInstance().leaveOtherRoom(roomId, true, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry",roomId+"退出啊房间成功"+userId);
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry",roomId+"退出啊房间失败"+userId);
}
});
if (mLiveRyLinkMicPkPresenter != null) { if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.leaveDRRoom(); mLiveRyLinkMicPkPresenter.leaveDRRoom();
} }