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

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;
import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
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;
@ -36,6 +37,7 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.ViewUtils;
import com.tencent.trtc.TRTCCloud;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.LiveInfoModel;
@ -714,7 +716,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
inputStreamList.add(stream);
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
@ -1128,22 +1129,30 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void leaveDRRoom() {
//清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (btn_close != null) {
btn_close.setVisibility(View.GONE);
}
}
});
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() {
@Override
public void onSuccess() {
Log.e("ry", "退出多人成功");
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", "退出多人失败" + rtcErrorCode);
}
});
@ -2179,11 +2188,12 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/**
* 修改最终PK数据
*
* @param leftGift 左边数据
* @param rightGift 右边数据
* @param bean 排位数据
*/
public void onPkProgressEnd(long leftGift, long rightGift,LivePKUserListBean bean) {
public void onPkProgressEnd(long leftGift, long rightGift, LivePKUserListBean bean) {
if (mLiveLinkMicPkViewHolder != null) {
mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean, true);
}

View File

@ -1,6 +1,7 @@
package com.yunbao.live.views;
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.live.activity.LiveActivity.mLiveRyLinkMicPkPresenter;
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.momo.TencentTRTCBeautyManager;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSendBean;
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.core.CameraVideoCapturer;
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.
@ -116,7 +122,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
//修改上面主播的头像
@Subscribe(threadMode = ThreadMode.MAIN)
public void onUPAnchorInfo(AnchorInfoEvent e) {
Log.i(TAG, "onUPAnchorInfo: "+e);
Log.i(TAG, "onUPAnchorInfo: " + e);
if (e != null) {
if (!e.isClear()) {
tv_avatarOther_name.setText(e.getUserNiceName());
@ -218,10 +224,54 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void run() {
Log.e("ry", inviterRoomId + extra + "Request");
UserBean userBean = new UserBean();
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申请
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
@ -354,7 +404,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void onError(String error) {
ToastUtil.show( R.string.net_error);
ToastUtil.show(R.string.net_error);
}
});
@ -381,6 +431,22 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void onFinishOtherRoom(String roomId, String 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) {
mLiveRyLinkMicPkPresenter.leaveDRRoom();
}