From 0b041bad7bed5a5a2e7bef7ea95da55aad11ec33 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 11 Nov 2022 14:04:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E4=BA=BAPK=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E6=96=B9=E6=AC=A1=E6=95=B0=E7=94=A8=E5=AE=8C=E4=BE=9D?= =?UTF-8?q?=E6=97=A7=E4=BC=9A=E5=8A=A0=E5=85=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presenter/LiveRyLinkMicPkPresenter.java | 74 ++++++++++++------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index 387427dd3..853e74610 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -26,6 +26,7 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.StringUtil; @@ -36,6 +37,7 @@ import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.custom.ProgressTextView; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.interfaces.ILiveLinkMicViewHolder; import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.socket.SocketRyLinkMicPkUtil; @@ -44,6 +46,7 @@ import com.yunbao.live.views.LiveLinkMicPkViewHolder; import com.yunbao.live.views.LivePushRyViewHolder; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import cn.rongcloud.rtc.api.RCRTCEngine; @@ -71,6 +74,7 @@ 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.LiveRyAnchorActivity.isDRPK; +import static com.yunbao.live.views.AbsRyLivePushViewHolder.leave; import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView; import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView1; import static com.yunbao.live.views.LivePushRyViewHolder.contexts; @@ -525,7 +529,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { //1. 设置自适应合流布局模式 config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE); //2. 合流画布设置 - if(rcrtcLiveInfo!=null) { + if (rcrtcLiveInfo != null) { rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { @Override public void onSuccess() { @@ -538,8 +542,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { } }); - }else{ - Log.w("PkDebug", "PK合流失败,rcrtcLiveInfo为空" ); + } else { + Log.w("PkDebug", "PK合流失败,rcrtcLiveInfo为空"); } } } @@ -643,6 +647,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { //1. 设置自适应合流布局模式 config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE); //2. 合流画布设置 + if (rcrtcLiveInfo == null) { + Log.w("PkDebug", "PK合流失败,rcrtcLiveInfo为空"); + } rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { @Override public void onSuccess() { @@ -834,6 +841,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.UN_LEAVELIVE)); LiveRyAnchorActivity.isDRPK = 1; LivePushRyViewHolder.btn_close.setVisibility(View.VISIBLE); SocketRyLinkMicPkUtil.linkMicPkAccept(mSocketRyClient, mApplyUid, mApplyUrl, mApplyNmae); @@ -1053,7 +1062,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { return bitmap; } - + private String TAG="多人PK"; /** * 退出多人PK */ @@ -1111,18 +1120,20 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { videoLayout1.setWidth(720); // 视频窗口的宽 videoLayout1.setHeight(1280); // 视频窗口的高 //2. 合流画布设置 - rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "混成功15"); - } + if (rcrtcLiveInfo != null) { + rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { + @Override + public void onSuccess() { + Log.e("ry", "混成功15"); + } - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", "混失败" + errorCode); + @Override + public void onFailed(RTCErrorCode errorCode) { + Log.e("ry", "混失败" + errorCode); - } - }); + } + }); + } } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { @@ -1175,6 +1186,11 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { @Override public void onSuccess(int code, String msgs, String[] info) { if (code == 0) { + Log.i("多人PK","1code = " + code + ", msgs = " + msgs + ", info = " + Arrays.deepToString(info)+" mApplyUid = "+mApplyUid); + if (info.length == 0) { + ToastUtil.show("多人PK次数已用完"); + return; + } rtcRoom.getLocalUser().responseJoinOtherRoom(mApplyUid, mApplyUid, true, true, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() { @Override public void onSuccess() { @@ -1185,6 +1201,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { @Override public void onSuccess(int code, String msg, String[] info) { + Log.i("多人PK","code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info)); + final SocketSendBean msg1 = new SocketSendBean() .param("_method_", SOCKET_LIVE_DRPK) .param("action", 10) @@ -1214,10 +1232,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { Log.e("ry", "发送失敗"); } }); - if(info.length==0){ - ToastUtil.show(msg); - return; - } + JSONObject obj = JSONObject.parseObject(info[0]); JSONArray users = obj.getJSONArray("userlist"); @@ -1874,6 +1889,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { * 主播与主播PK 断开连麦PK的回调 */ public void onLinkMicPkClose(int i) { + // //恢复播放画面 if (i == 1) { if (rtcRoom != null) { @@ -1902,18 +1918,20 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { //1. 设置自适应合流布局模式 config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE); //2. 合流画布设置 - rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "混成功16"); - } + if (rcrtcLiveInfo != null) { + rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { + @Override + public void onSuccess() { + Log.e("ry", "混成功16"); + } - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", "混失败" + errorCode); + @Override + public void onFailed(RTCErrorCode errorCode) { + Log.e("ry", "混失败" + errorCode); - } - }); + } + }); + } } runOnUiThread(new Runnable() { public void run() {