diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index ec6e0e055..e4fb57369 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -1649,6 +1649,13 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } } + @Override + public void onLinkDRMicPkQuit(String uid) { + if(mLiveSwLinkMicPkPresenter!=null){ + mLiveSwLinkMicPkPresenter.onLinkDRMicPkQuit(uid); + } + } + @Override public boolean isSoftInputShowed() { if (mKeyBoardHeightUtil != null) { diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 5737cd95a..7493e4e30 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -551,6 +551,11 @@ public class LiveAudienceActivity extends LiveActivity { //manager.getmLivePlayViewHolder().setDrMicInfo(u); } + @Override + public void onLinkDRMicPkQuit(String uid) { + + } + @Override public void onLinkDRMicPkApplyOk(UserBean u) { L.eSw("onLinkDRMicPkApplyOk:" + u.getId()); diff --git a/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java index 25fe644df..01e860dd1 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java @@ -1288,6 +1288,13 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl } } + public void linkDrMicRemoveListUid(String uid){ + if (mLiveAnchorViewHolder != null) { + mLiveAnchorViewHolder.removeYaoqing(uid); + } + } + + /** * 发起多人主播连麦PK申请 * @@ -1655,6 +1662,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl break; case LEAVE_PK_SCORE: if (mLiveSwLinkMicPkPresenter != null) { + mLiveSwLinkMicPkPresenter.closeButtonGone(); mLiveSwLinkMicPkPresenter.upDataPkScore(event.getPkScores(), event.getUid(), event.getTime()); } if (mLiveRoomViewHolder != null) { diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index 4a8c493d2..470923b0f 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -490,7 +490,8 @@ public class LiveAudienceEvent extends BaseModel { SUD_GAME_CREATE_ROOM(75, "主播创建sud游戏"), PK_RANK_START(76, "PK排位赛开始"), GuardSpecialEffect(77, "PK排位赛开始"), - LIVE_DIALOG_ANCHOR_TIPS(78, "主播公会赛tips"); + LIVE_DIALOG_ANCHOR_TIPS(78, "主播公会赛tips"), + LIVE_REMOVE_LIVEUID(79, "主播退出多人PK"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java index 874d557c7..acba3a23a 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java @@ -5,6 +5,7 @@ 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.LiveSwAnchorActivity.PKing; import static com.yunbao.live.activity.LiveSwAnchorActivity.isDRPK; +import static com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder; import static com.yunbao.live.views.LivePushSwViewHolder.btn_close; import static com.yunbao.live.views.LivePushSwViewHolder.rtcRoom; @@ -457,6 +458,30 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { showDRApplyDialog(u); } + public void onLinkDRMicPkQuit(String uid) { + HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", mApplyUid).execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (info.length > 0) { + //退出所有直播間 + livePushSwViewHolder.exitChannelDrPk(drPkbeans); + + JSONObject obj = JSONObject.parseObject(info[0]); + drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class); + + for (int i = 0; i < drPkbeans.size(); i++) { + if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) { + livePushSwViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1); + } + } + if(drPkbeans.size()==1){ + mLiveAnchorViewHolder.closeEndPkBt(); + } + } + } + }); + } + /** * 主播与主播PK 主播收到其他主播发过来的多人PK申请同意了的回调 */ @@ -466,14 +491,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { if (livePushSwViewHolder != null) { livePushSwViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1); } - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK) - .param("action", 3) - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("pkuid", CommonAppConfig.getInstance().getUid()) - .param("type", 3) - .param("uid", u.getId()) - .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 3).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("type", 3).param("uid", u.getId()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.create(); String targetId = "g" + CommonAppConfig.getInstance().getUid(); @@ -498,6 +516,8 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } }); dRjoinOtherRoom(u); + //展示结束连麦按钮 + mLiveAnchorViewHolder.showEndPkBt(); } /** @@ -509,18 +529,18 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { mApplyUrl = u.getAvatar(); mApplyNmae = u.getUserNiceName(); if (by != 1) { - Log.e("ry", "1"+u.getUserNiceName() + "单人收到" + u.getAvatar()); + Log.e("ry", "1" + u.getUserNiceName() + "单人收到" + u.getAvatar()); if (mIsApplyDialogShow == false) { if (u.isRandomPk()) { - Log.e("ry", "2"+u.getUserNiceName() + "单人收到" + u.getAvatar()); + Log.e("ry", "2" + u.getUserNiceName() + "单人收到" + u.getAvatar()); showPkDialog(u); } else { - Log.e("ry", "3"+u.getUserNiceName() + "单人收到" + u.getAvatar()); + Log.e("ry", "3" + u.getUserNiceName() + "单人收到" + u.getAvatar()); showApplyDialog(u); } } } else { - Log.e("ry", "4"+u.getUserNiceName() + "单人收到" + u.getAvatar()); + Log.e("ry", "4" + u.getUserNiceName() + "单人收到" + u.getAvatar()); isPK(u); } } @@ -553,14 +573,8 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { LiveSwAnchorActivity.isDRPK = 1; /*---------------------------------------------------------------- */ - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK) - .param("action", 2) //回复PK申请 2 - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("pkuid", bean.getId()) - .param("uid", CommonAppConfig.getInstance().getUid()) - .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 2) //回复PK申请 2 + .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", bean.getId()).param("uid", CommonAppConfig.getInstance().getUid()).param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); if (RandomPkManager.getInstance().isRankModel()) { L.eSw("排位赛"); msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png"); @@ -570,7 +584,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { System.out.println("PK回执 = " + msg1.toString()); 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( bean.getId(), conversationType, messageContent); + io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(bean.getId(), conversationType, messageContent); RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { @Override @@ -633,11 +647,13 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { if (obj != null) { if (obj.getString("ispk").equals("0")) { isPK(u); - }else{ + } else { ToastUtil.show(mContext.getString(R.string.pking_over)); } } - }}}); + } + } + }); } else { if (mPkWaitCount < 0) { final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 8); @@ -701,6 +717,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } } }); + mLiveAnchorViewHolder.closeEndPkBt(); livePushSwViewHolder.exitChannelDrPk(drPkbeans); leaveHandler.removeCallbacks(leaveRunnable); } @@ -911,17 +928,9 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class); for (int i = 0; i < drPkbeans.size(); i++) { if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) { - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK) - .param("action", 2) - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("pkuid", CommonAppConfig.getInstance().getUid()) - .param("msgtype", 2) - .param("uid", drPkbeans.get(i).getId()) - .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 2).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("msgtype", 2).param("uid", drPkbeans.get(i).getId()).param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.create(); - L.eSw("uiduiduiduiduiduiduiduid"+drPkbeans.get(i).getId()); + L.eSw("uiduiduiduiduiduiduiduid" + drPkbeans.get(i).getId()); String targetId = String.valueOf(drPkbeans.get(i).getId()); Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); @@ -953,16 +962,9 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) { - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK) - .param("action", 3) - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("pkuid", CommonAppConfig.getInstance().getUid()) - .param("msgtype", 3) - .param("uid", drPkbeans.get(i).getId()) - .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 3).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("msgtype", 3).param("uid", drPkbeans.get(i).getId()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.create(); - L.eSw("發送給自己直播間"+drPkbeans.get(i).getId()); + L.eSw("發送給自己直播間" + drPkbeans.get(i).getId()); String targetId = "g" + CommonAppConfig.getInstance().getUid(); Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; //群聊 TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); @@ -987,17 +989,10 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } - if(!mApplyUid.equals(String.valueOf(drPkbeans.get(i).getId()))&&!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))){ - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK) - .param("action", 3) - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("pkuid", CommonAppConfig.getInstance().getUid()) - .param("msgtype", 3) - .param("uid", drPkbeans.get(i).getId()) - .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + if (!mApplyUid.equals(String.valueOf(drPkbeans.get(i).getId())) && !CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) { + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 3).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("msgtype", 3).param("uid", drPkbeans.get(i).getId()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.create(); - L.eSw("發送給其他主播直播间"+drPkbeans.get(i).getId()); + L.eSw("發送給其他主播直播间" + drPkbeans.get(i).getId()); String targetId = "g" + drPkbeans.get(i).getId(); Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; //群聊 TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); @@ -1022,41 +1017,13 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } } dRjoinOtherRoom(u); + //展示结束连麦按钮 + //设置多人PK 房主ROOM UID + mLiveAnchorViewHolder.setDrpkRoomId(mApplyUid); + mLiveAnchorViewHolder.showEndPkBt(); } } }); - - - /*for (int i = 0; i < users.size(); i++) { - JSONObject user = users.getJSONObject(i); - Log.e("ry", mApplyUid + "VS" + user.getString("id") + "列表"); - if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) { - if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) { - *//** - * 向指定用户发送跨房间连麦请求 - *

- * 1: inviterAutoMix为true时: - * - * 1.1:如果被邀请方在加入邀请方房间之前发布了资源,当被邀请方加入邀请者房间成功后,服务器会把被邀请方流资源合并到邀请方视图 ·(默认仅悬浮布局合流)上。 - * - * 1.2:如果被邀请方在加入邀请方房间之前没有发布过资源,将会在被邀请方发布资源成功后,服务器会把被邀请方流资源合并到邀请方视图(默认仅悬浮布局合流)上。 - * - * 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。 - *

- *//* - IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() { - @Override - public void onSuccess() { - } - - @Override - public void onFailed(RTCErrorCode errorCode) { - - } - }); - } - } - }*/ } }); } @@ -1071,22 +1038,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } } }); - /*LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - JSONObject obj = JSON.parseObject(info[0]); - if (obj != null) { - if (obj.getString("ispk").equals("0")) { - - - } else { - ToastUtil.show(mContext.getString(R.string.pking_over)); - } - } - } - } - });*/ } else { if (mPkWaitCount < 0) { IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() { @@ -1199,7 +1150,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } - public void setPkUserInfoView(UserBean userBean){ + public void setPkUserInfoView(UserBean userBean) { } @@ -1431,7 +1382,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { * 主播与主播PK 所有人收到PK开始的回调 */ public void onLinkMicPkStart(String pkUid, int i) { - L.eSw("onLinkMicPkStart pkUid "+pkUid+" "+i); + L.eSw("onLinkMicPkStart pkUid " + pkUid + " " + i); Log.d("tag", i + "mPkTimeCount2"); mIsPk = true; hideSendPkWait(); @@ -1440,7 +1391,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { mPkUid = pkUid; mApplyUid = null; mApplyStream = null; - isDRPK=1; + isDRPK = 1; if (mLiveLinkMicPkViewHolder == null) { mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer); mLiveLinkMicPkViewHolder.addToParent(); @@ -1611,7 +1562,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { mLiveLinkMicPkViewHolder = null; } - public void clearData() { mIsApplyDialogShow = false; mAcceptPk = false; @@ -1635,11 +1585,14 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { mLiveLinkMicPkViewHolder = null; } - public void setSelfStream(String selfStream) { mSelfStream = selfStream; } + public void closeButtonGone() { + mLiveAnchorViewHolder.closeEndPkBt(); + } + /** * 更新Pk分数 */ @@ -1864,6 +1817,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME2, getNextSecondTime()); } } else { + mLiveAnchorViewHolder.showEndPkBt(); livePushSwViewHolder.timeTitle.setVisibility(View.GONE); if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); diff --git a/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java b/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java index 6ac19c675..98e54cd41 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java @@ -247,6 +247,8 @@ public interface SocketMessageListener { //接受多人PK void onLinkDRMicPkApplyOk(UserBean u); + void onLinkDRMicPkQuit(String uid); + /** * 主播与主播PK 所有人收到PK开始的回调 */ diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java index e8b726e08..324b8db5a 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java @@ -199,7 +199,7 @@ public class SocketSwClient { //用户连麦 case Constants.LIAN_MAI: int actions = map.getIntValue("action"); - L.eSw("用户连麦:actions"+actions); + L.eSw("用户连麦:actions" + actions); //主播邀请用户连麦消息 if (actions == 1) { EventBus.getDefault().post("inviteMic"); @@ -304,7 +304,7 @@ public class SocketSwClient { // break; case Constants.SOCKET_LIVE_DRPK_RANDOM: case Constants.SOCKET_LIVE_DRPK://多人PK - L.eSw("map"+new Gson().toJson(map)); + L.eSw("map" + new Gson().toJson(map)); int action3 = map.getIntValue("action"); //收到多人PK邀请 if (action3 == 1) { @@ -314,13 +314,13 @@ public class SocketSwClient { mListener.onLinkDRMicPkApply(u); } else if (action3 == 2) { //收到对方同意多人PK邀请 - if("0".equals(map.getString("msgtype"))){ + if ("0".equals(map.getString("msgtype"))) { return; } UserBean u = new UserBean(); // u.setUserNiceName(map.getString("uname")); u.setId(map.getString("pkuid")); - L.eSw("action3 == 2:"+u.getId()); + L.eSw("action3 == 2:" + u.getId()); L.eSw("收到对方同意多人PK邀请"); mListener.onLinkDRMicPkApplyOk(u); SWManager.get().setDimensions(3);//退出直播间,将分别率设置为 VD_840x480 @@ -334,7 +334,7 @@ public class SocketSwClient { // LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)); } - } else if (action3 == 5) { + } else if (action3 == 5) {//结束PK // endDRGif(); LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE); if (LiveSwAnchorActivity.mLiveAnchorViewHolder != null) { @@ -353,20 +353,20 @@ public class SocketSwClient { /* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) { LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); }*/ - if(livePushSwViewHolder==null){ - if("4".equals(map.getString("msgtype"))){ + isDRPK = 1; + if (livePushSwViewHolder == null) { + if ("4".equals(map.getString("msgtype"))) { return; } UserBean u = new UserBean(); // u.setUserNiceName(map.getString("uname")); u.setId(map.getString("uid")); - if(StringUtil.isEmpty(u.getId())){ + if (StringUtil.isEmpty(u.getId())) { return; } - L.eSw("通知用户 action3 == 3:"+u.getId()); + L.eSw("通知用户 action3 == 3:" + u.getId()); mListener.onLinkDRMicPKToUser(u); Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)); - isDRPK = 1; } } else if (action3 == 10) { //显示pk分数 @@ -374,6 +374,13 @@ public class SocketSwClient { // LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)); } + } else if (action3 == 7) { + L.eSw("主播退出直播間:"+map.getString("uid")); + mListener.onLinkDRMicPkQuit(map.getString("uid")); + //清除已邀请人数 + if(LiveSwAnchorActivity.mLiveAnchorViewHolder!=null){ + LiveSwAnchorActivity.mLiveAnchorViewHolder.removeYaoqing(map.getString("uid")); + } } break; @@ -1282,10 +1289,13 @@ public class SocketSwClient { u.setUserNiceName(map.getString("uname")); u.setAvatar(map.getString("uhead")); u.setRandomPk("11".equals(map.getString("msgtype"))); - mListener.onLinkMicPkApply(u, map.getString("stream"), "11".equals(map.getString("msgtype"))?2:1); + mListener.onLinkMicPkApply(u, map.getString("stream"), "11".equals(map.getString("msgtype")) ? 2 : 1); break; case 2://收到对方主播PK回调 L.eSw("收到对方主播PK回调"); + /*if("1".equals(map.getString("random_pk"))){ + + }*/ RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); mListener.onLinkMicToPk(map.getString("uid"), map.getString("uhead"), map.getString("uhead")); mListener.onLinkMicPkStart(map.getString("uid"), map.getString("uhead"), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); @@ -1340,15 +1350,13 @@ public class SocketSwClient { } break; case 10://系统发起PK回调 - if(livePushSwViewHolder!=null){ - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK) - .param("action", 2) - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("pkuid", CommonAppConfig.getInstance().getUid()) - .param("msgtype", 2) - .param("uid", CommonAppConfig.getInstance().getUid()) + if (livePushSwViewHolder != null) { + final SocketSendBean msg1 = new SocketSendBean() + .param("_method_", SOCKET_LINK_MIC_PK).param("action", 2) + .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()) + .param("msgtype", 2).param("uid", CommonAppConfig.getInstance().getUid()) .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("random_pk", "1") + .param("is_auto ", "1") .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.create(); @@ -1376,65 +1384,25 @@ public class SocketSwClient { RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); LiveNetManager.get(mContext).getLiveInfo(map.getString("uid"), new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(LiveInfoModel data) { - mListener.onLinkMicToPk(map.getString("uid"), data.getAvatar(), map.getString("uhead")); - mListener.onLinkMicPkStart(map.getString("uid"), data.getAvatar(), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); - if (livePushSwViewHolder != null) { - UserBean userBean = new UserBean(); - userBean.setId(map.getString("uid")); - userBean.setAvatar(data.getAvatar()); - userBean.setUserNiceName(map.getString("uname")); - livePushSwViewHolder.setAnPkRtc(userBean); - } - } - - @Override - public void onError(String error) { - - } + @Override + public void onSuccess(LiveInfoModel data) { + mListener.onLinkMicToPk(map.getString("uid"), data.getAvatar(), map.getString("uhead")); + mListener.onLinkMicPkStart(map.getString("uid"), data.getAvatar(), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); + if (livePushSwViewHolder != null) { + UserBean userBean = new UserBean(); + userBean.setId(map.getString("uid")); + userBean.setAvatar(data.getAvatar()); + userBean.setUserNiceName(map.getString("uname")); + livePushSwViewHolder.setAnPkRtc(userBean); } - ); + } + + @Override + public void onError(String error) { + + } + }); } - /*JSONObject msg1 = new JSONObject(); - msg1.put("type", "autoLivePK"); - msg1.put("uid", CommonAppConfig.getInstance().getUid()); - msg1.put("pkuid", CommonAppConfig.getInstance().getUid()); - msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); - msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()); - IMRTCManager.getInstance().requestJoinOtherRoom(map.getString("uid"), true, msg1.toString(), new IRCRTCResultCallback() { - @Override - public void onSuccess() { - if (WordUtil.isNewZh()) { - ToastUtil.show("邀请 " + map.getString("uid") + " 发送成功"); - } else { - ToastUtil.show("invite " + map.getString("uid") + " successful"); - } - runOnUiThread(new Runnable() { - @Override - public void run() { - dismiss(); - } - }); - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - runOnUiThread(new Runnable() { - @Override - public void run() { - dismiss(); - } - }); - //todo 安卓端状态码说明文档:https://docs.rongcloud.cn/v4/views/rtc/call/code/android.html - Log.e("ry", rtcErrorCode + "aaaaaa" + CommonAppConfig.getInstance().getUid() + "VDSSSS" + map.getString("uid")); - if (WordUtil.isNewZh()) { - ToastUtil.show("邀请 " + map.getString("uid") + " 发送失败 :" + rtcErrorCode); - } else { - ToastUtil.show("invite " + map.getString("uid") + " lose :" + rtcErrorCode); - } - } - });*/ break; } } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java index 24614a852..6480eb369 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java @@ -278,6 +278,11 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder { } + @Override + public void removeLiveUid(String uid) { + + } + @Override public void removeDetailView() { diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 52ba0d341..196b6ebc7 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -425,6 +425,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } + @Override + public void removeLiveUid(String uid) { + + } + @Override public void release() { mEnd = true; diff --git a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java index 26dac4602..844383315 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java @@ -1,6 +1,5 @@ package com.yunbao.live.views; -import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import android.Manifest; import android.app.Activity; @@ -9,8 +8,6 @@ import android.content.Context; import android.graphics.Color; import android.media.AudioManager; import android.os.Build; -import android.os.Handler; -import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; @@ -24,16 +21,12 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.alibaba.fastjson.JSONObject; -import com.google.android.exoplayer2.PlaybackException; -import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.ui.StyledPlayerView; -import com.google.android.exoplayer2.video.VideoSize; import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BasePopupView; import com.lxj.xpopup.interfaces.XPopupCallback; import com.lzf.easyfloat.EasyFloat; -import com.lzy.okserver.OkDownload; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.BaseModel; @@ -70,31 +63,10 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.Locale; -import cn.rongcloud.rtc.api.RCRTCEngine; -import cn.rongcloud.rtc.api.RCRTCRemoteUser; -import cn.rongcloud.rtc.api.RCRTCRoom; -import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; -import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener; -import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleDataCallback; -import cn.rongcloud.rtc.api.callback.IRCRTCVideoInputFrameListener; import cn.rongcloud.rtc.api.stream.RCRTCInputStream; -import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo; -import cn.rongcloud.rtc.api.stream.RCRTCOutputStream; -import cn.rongcloud.rtc.api.stream.RCRTCVideoInputStream; -import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig; -import cn.rongcloud.rtc.api.stream.RCRTCVideoView; -import cn.rongcloud.rtc.base.RCRTCMediaType; -import cn.rongcloud.rtc.base.RCRTCParamsType; -import cn.rongcloud.rtc.base.RCRTCRemoteVideoFrame; -import cn.rongcloud.rtc.base.RCRTCStreamType; -import cn.rongcloud.rtc.base.RTCErrorCode; -import cn.rongcloud.rtc.core.RendererCommon; import io.agora.beautyapi.faceunity.agora.SWAuManager; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.functions.Consumer; @@ -116,9 +88,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { private ViewGroup mPkContainer; public StyledPlayerView mVideoView; - private FrameLayout playFrameLayout; - private FrameLayout playFrameLayout1; - private View mLoading, mLoading2; private ImageView mCover; private boolean mPaused;//是否切后台了 @@ -142,7 +111,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { private boolean userJoinLinkMic = false;//用户是否已加入房间 //0未申请1申请中2连麦中 - RCRTCRoom rcrtcRoom; String purl, srcUrl; SWAuManager swAuManager; String liveUid; @@ -184,8 +152,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { EventBus.getDefault().register(this); Bus.getOn(this); mRoot = (ViewGroup) findViewById(R.id.root); - playFrameLayout = (FrameLayout) findViewById(R.id.playView); - playFrameLayout1 = (FrameLayout) findViewById(R.id.playView1); mSmallContainer = (ViewGroup) findViewById(R.id.small_container); mLeftContainer = (ViewGroup) findViewById(R.id.left_container); mRightContainer = (ViewGroup) findViewById(R.id.right_container); @@ -275,6 +241,25 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,liveUid, SWAuManager.getChannelName(liveUid)); } + @Override + public void removeLiveUid(String uid) { + //先结束PK + if(drMicUserList!=null){ + List tempList = new ArrayList<>(); + int index = -1; + for (int i = 0; i () { - - - @Override - public void onSuccess(RCRTCRoom data) { - userJoinLinkMic = true; - 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() { - UsertoRY(); - } - }); - } else { - ToastUtil.show("房间失败" + errorCode); - } - - } - });*/ - - - } - - private void subscribeMic(RCRTCRoom data) { - runOnUiThread(new Runnable() { - @Override - public void run() { - RCRTCEngine.getInstance().enableSpeaker(true); - //遍历远端用户发布的资源列表 - Log.i(TAG, "软件资源数量:" + data.getLiveStreams().size()); - for (RCRTCInputStream stream : data.getLiveStreams()) { - Log.i(TAG, "资源流 type: " + stream.getMediaType()); - if (stream.getMediaType() == RCRTCMediaType.VIDEO) { - //暂停播放 - - //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 - - //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 - RCRTCVideoView remoteView = new RCRTCVideoView(contexts); - ((RCRTCVideoInputStream) stream).setVideoView(remoteView); - //todo 本demo只演示添加1个远端用户的视图 - remoteView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - remoteView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT); - ry_view.addView(remoteView); - Log.e("ry", stream.getMediaType() + "rcrtcOtherRoom成功 :" + data.getLiveStreams().size()); - } - userinputStreamList.add(stream); - } - rcrtcRoom.getLocalUser().subscribeStreams(userinputStreamList, new IRCRTCResultCallback() { - - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", userinputStreamList.size() + LiveActivity.mLiveUid + "订阅失败" + errorCode.toString()); - ToastUtil.show(mContext.getString(R.string.live_pk_link_error)); - } - - @Override - public void onSuccess() { - Log.e("ry", "订阅资源成功"); -// new Handler().postDelayed(new Runnable() { -// @Override -// public void run() { - toMic(); -// } -// }, 3000); - - } - }); - } - }); - } - - /** - * 主房间事件监听 - * 详细说明请参考文档:https://www.rongcloud.cn/docs/api/android/rtclib_v4/cn/rongcloud/rtc/api/callback/IRCRTCRoomEventsListener.html - */ - public IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() { - @Override - public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, List list) { - Log.e("ry", "远端来了" + list.size()); - //TODO 按需在此订阅远端用户发布的资源 - rcrtcRoom.getLocalUser().subscribeStreams(list, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "远端成功" + list.size()); - - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - Log.e("ry", "远端失败" + list.size()); - ToastUtil.show(mContext.getString(R.string.live_pk_link_error)); - } - }); - } - - @Override - public void onRemoteUserMuteAudio(RCRTCRemoteUser remoteUser, RCRTCInputStream stream, boolean mute) { - - } - - @Override - public void onRemoteUserMuteVideo(RCRTCRemoteUser remoteUser, RCRTCInputStream stream, boolean mute) { - - } - - @Override - public void onRemoteUserUnpublishResource(RCRTCRemoteUser remoteUser, List streams) { - - } - - @Override - public void onUserJoined(RCRTCRemoteUser remoteUser) { - - } - - @Override - public void onUserLeft(RCRTCRemoteUser remoteUser) { - - } - - @Override - public void onUserOffline(RCRTCRemoteUser remoteUser) { - - } - - @Override - public void onPublishLiveStreams(List streams) { - - } - - @Override - public void onUnpublishLiveStreams(List streams) { - - } - }; - - - public List userinputStreamList1 = new ArrayList<>(); - public List userinputStreamList2 = new ArrayList<>(); - - public void toMic() { - RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC, RCRTCParamsType.AudioScenario.MUSIC_CLASSROOM); - userinputStreamList1.clear(); - userinputStreamList2.clear(); - RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; - int minRate = 200; - int maxRate = 900; - switch (IMLoginManager.get(mContext).getSelectClarity()) { - case 0: - rcrtcVideoResolution = landscape == 1 ? RCRTCParamsType.RCRTCVideoResolution.parseVideoResolution(960, 720) : RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; - minRate = landscape == 1 ? 900 : 200; - maxRate = landscape == 1 ? 700 : 900; - break; - case 1: - rcrtcVideoResolution = landscape == 1 ? RCRTCParamsType.RCRTCVideoResolution.parseVideoResolution(960, 720) : RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280; - minRate = landscape == 1 ? 900 : 250; - maxRate = landscape == 1 ? 700 : 2200; - break; - case 2: - rcrtcVideoResolution = landscape == 1 ? RCRTCParamsType.RCRTCVideoResolution.parseVideoResolution(960, 720) : RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920; - minRate = landscape == 1 ? 900 : 400; - maxRate = landscape == 1 ? 700 : 4000; - break; - } - // 示例代码使用480x640分辨率演示 - RCRTCVideoStreamConfig config = RCRTCVideoStreamConfig.Builder.create() - //设置分辨率 - .setVideoResolution(rcrtcVideoResolution) - //设置帧率 - .setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_24) - //设置最小码率,480P下推荐200 - .setMinRate(minRate) - //设置最大码率,480P下推荐900 - .setMaxRate(maxRate).build(); - RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config); -// 创建视图渲染视图 -// RCRTCVideoView videoView = new RCRTCVideoView(contexts); -// RCRTCEngine.getInstance().getDefaultVideoStream().setVideoView(videoView); -//TODO 示例代码使用获取本地默认视频流、音频流演示 - ArrayList streams = new ArrayList<>(); -// streams.add(RCRTCEngine.getInstance().getDefaultVideoStream()); - streams.add(RCRTCEngine.getInstance().getDefaultAudioStream()); - if (landscape == 1) { - new Handler(Looper.getMainLooper()).post(new Runnable() { - @Override - public void run() { - setLiveBeanLandscape(1); - } - }); - - } -// 开启摄像头 -// RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(null); -// 开始切换为主播身份 - RCRTCEngine.getInstance().getRoom().getLocalUser().switchToBroadcaster(streams, new IRCRTCSwitchRoleDataCallback() { - /** - * 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。 - * SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。 - */ - @Override - public void onKicked() { - Log.e("ry", "切换onKicked"); - - } - - @Override - public void onSuccess(RCRTCLiveInfo data) { - rcrtcRoom.registerRoomListener(roomEventsListener); - //该用户切换为主播成功,可以以主播身份进行音视频 - Log.e("ry", "切换成功"); - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - if (onMicCallback != null) { - onMicCallback.onMikUpdate(); - } - //遍历远端用户列表 - for (int i = 0; i < rcrtcRoom.getRemoteUsers().size(); i++) { - Log.e("ry", rcrtcRoom.getRemoteUsers().get(i).getUserId() + "收到rcrtcOtherRoom" + rcrtcRoom.getRemoteUsers().size()); - //遍历远端用户发布的资源列表 - for (RCRTCInputStream stream : rcrtcRoom.getRemoteUsers().get(i).getStreams()) { - Log.e("ry", i + "收到" + stream.getMediaType() + "实打实打算" + rcrtcRoom.getRemoteUsers().get(i).getUserId()); - if (stream.getMediaType() == RCRTCMediaType.VIDEO) { - if (userinputStreamList1.size() == 0) { - - //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 - RCRTCVideoView remoteView = new RCRTCVideoView(contexts); - ((RCRTCVideoInputStream) stream).setStreamType(RCRTCStreamType.NORMAL); - ((RCRTCVideoInputStream) stream).setVideoView(remoteView); - ((RCRTCVideoInputStream) stream).setVideoFrameListener(new IRCRTCVideoInputFrameListener() { - @Override - public void onFrame(RCRTCRemoteVideoFrame videoFrame) { - String debugText = " 2、安卓主播开播, 安卓用户申请连麦后 ,安卓用户这边底部画面不全 :" + videoFrame.getFrameType().name() + "\n" + "rotation:" + videoFrame.getRotation() + "\n" + "timestampNs:" + videoFrame.getTimestampNs() + "\n" + "分辨率:" + videoFrame.getBuffer().getHeight() + "x" + videoFrame.getBuffer().getWidth() + "\n" + "当前时间:" + new SimpleDateFormat("HH:mm:ss", Locale.CHINA).format(new Date()) + "\n"; - //Log.d("ry", "onFrame: " + debugText); - new Handler(Looper.getMainLooper()).post(() -> { - debugView.setText(debugText); - - }); - } - }); - //todo 本demo只演示添加1个远端用户的视图 - ry_view.removeAllViews(); - remoteView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - remoteView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL); - ry_view.addView(remoteView); - } - userinputStreamList1.add(stream); - } - userinputStreamList2.add(stream); - } - } - //开始订阅资源 - rcrtcRoom.getLocalUser().subscribeStreams(userinputStreamList2, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "订阅资源成功"); - MicStatusManager.getInstance().setMicData(MicStatusManager.MIC_TYPE_OPEN, LiveActivity.mLiveUid); - AudioManager audioManager = (AudioManager) contexts.getSystemService(Context.AUDIO_SERVICE); - RCRTCEngine.getInstance().enableSpeaker(true); - audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); - audioManager.setSpeakerphoneOn(true); - - HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm").params("roomid", LiveActivity.mLiveUid).execute(new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - Log.e("ry", code + "热热热"); - } - }); - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - Log.e("ry", "订阅资源失败: " + rtcErrorCode.getReason()); - ToastUtil.show(mContext.getString(R.string.live_pk_link_error)); - } - }); - } - }); - - - } - - /** - * 当切换失败且不影响当前角色继续音视频时回调 - * @param errorCode 失败错误码 - */ - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", errorCode + "切换失败"); - - } - }); } @Override public void setLoadViewListener(LoadingListener listener) { super.setLoadViewListener(listener); } - - private void showLoadingDialog() { - if (PLAY_MODEL == PLAY_MODEL_480) return; - - new DialogUitl.Builder(mContext).setTitle("網絡提示").setContent("系統監測到您的網絡不穩定,對此將清晰度變成了流暢,您可以在側邊菜單中的「清晰度」選擇調回。").setView(R.layout.dialog_simple_tip).setClickCallback(new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - dialog.dismiss(); - } - }).build().show(); - PLAY_MODEL = PLAY_MODEL_480; - String url = srcUrl; - if (videoLandscape == VIDEO_VERTICAL) { - url = url.replace(".flv", videoRatioVertical[PLAY_MODEL_480] + videoFps[0] + ".flv"); - } else if (videoLandscape == VIDEO_HORIZONTAL) { - url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL_480] + videoFps[0] + ".flv"); - } - } - - private class ExoPlayerListener implements Player.Listener { - String TAG = "播放流"; - - @Override - public void onPlayerError(PlaybackException error) { - Player.Listener.super.onPlayerError(error); - debugView.setText("播放出错code=" + error.errorCode + " msg=" + error.getErrorCodeName()); - } - - @Override - public void onVideoSizeChanged(VideoSize videoSize) { - Player.Listener.super.onVideoSizeChanged(videoSize); - Log.i(TAG, "onVideoSizeChanged: width = " + videoSize.width + " height = " + videoSize.height); - //ToastUtil.show("分辨率: 宽 = " + videoSize.width + " 高 = " + videoSize.height); - if (videoSize.height > videoSize.width) { - videoLandscape = VIDEO_VERTICAL; - } else { - videoLandscape = VIDEO_HORIZONTAL; - } - } - - @Override - public void onPlaybackStateChanged(int playbackState) { - Player.Listener.super.onPlaybackStateChanged(playbackState); - if (playbackState == Player.STATE_BUFFERING) { - //showLoadingDialog(); - mLoading.setVisibility(View.VISIBLE); - OkDownload.getInstance().pauseAll(); - Log.i(TAG, "onPlaybackStateChanged: 缓存中"); - } else { - mLoading.setVisibility(View.INVISIBLE); - Log.i(TAG, "onPlaybackStateChanged: 播放中"); - } - } - - @Override - public void onIsPlayingChanged(boolean isPlaying) { - Player.Listener.super.onIsPlayingChanged(isPlaying); - if (isPlaying) { - hideCover(); - mLoading.setVisibility(View.INVISIBLE); - Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = " + waitNextUrl); - OkDownload.getInstance().startAll(); - if (loadingListener != null) { - loadingListener.onPlayer(); - } - if (waitNextUrl != null) { - waitNextUrl = null; - } - } - } - } - - private int mPkTimeCount = 0; - - - public interface PlayViewLayoutInterface { - void playViewLayout(int width, int height); - } - - private PlayViewLayoutInterface layoutInterface; - - public void setLayoutInterface(PlayViewLayoutInterface layoutInterface) { - mVideoView.post(new Runnable() { - @Override - public void run() { - int width = mVideoView.getMeasuredWidth(); - int height = mVideoView.getMeasuredHeight(); - if (layoutInterface != null) { - layoutInterface.playViewLayout(width, height); - } - } - }); - } - - } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java index 73bb5b84f..5de3bf44a 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java @@ -94,6 +94,11 @@ public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXL } + @Override + public void removeLiveUid(String uid) { + + } + @Override public void removeDetailView() { diff --git a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java index 712888d0a..a1d826ecd 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java @@ -26,6 +26,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; import com.tencent.rtmp.ITXLivePushListener; import com.tencent.rtmp.TXLiveConstants; import com.yunbao.common.CommonAppConfig; @@ -103,7 +104,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX private boolean isPk = false; private boolean isNeedOpenCamera = false; private SWManager swManager; - private String pkUid1; + private String pkUid1; //单人PK 对方主播 uid //修改上面主播的头像 @Subscribe(threadMode = ThreadMode.MAIN) @@ -252,9 +253,9 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX }); } - public void exitChannelDrPk(List drPkbeanList){ - for (int i = 0; i drPkbeanList) { + for (int i = 0; i < drPkbeanList.size(); i++) { + if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeanList.get(i).getId()))) { SWManager.get().exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), String.valueOf(drPkbeanList.get(i).getId())); } } @@ -275,8 +276,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX swManager.updateMyChannelView((FrameLayout) mLeftContainer); //清除 mBigContainer 中的渲染 mBigContainer.removeAllViews(); - - btn_close.setVisibility(View.VISIBLE); + showButtonGone(); //设置对方主播的渲染视图 设置到 rightContainer swManager.setPkContainer(mRightContainer); swManager.joinChannelEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId())); @@ -288,57 +288,57 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX .params("type", "1") .params("sign", "1") .execute(new HttpCallback() { - @Override - public void onSuccess(int code, String msgs, String[] info) { - if (code == 0) { - HttpClient.getInstance().get("Livepk.setPK", "Livepk.setPK") - .params("uid", CommonAppConfig.getInstance().getUid()) - .params("pkuid", u.getId()) - .params("type", "1") - .params("sign", "1") - .execute(new HttpCallback() { - @Override - public void onSuccess(int code, String msgs, String[] info) { - if (code == 0) { - L.eSw("555555555555555555555555555555555555"); - final SocketSendBean msg1 = new SocketSendBean() - .param("_method_", Constants.SOCKET_LINK_MIC_PK) - .param("action", 4) - .param("pkname", u.getUserNiceName()) - .param("pkuid", u.getId()) - .param("pkhead", u.getAvatar()) - .param("uname", u.getUserNiceName()) - .param("uhead", u.getAvatar()) - .param("uid", CommonAppConfig.getInstance().getUid()); - msg1.create(); + @Override + public void onSuccess(int code, String msgs, String[] info) { + if (code == 0) { + HttpClient.getInstance().get("Livepk.setPK", "Livepk.setPK") + .params("uid", CommonAppConfig.getInstance().getUid()) + .params("pkuid", u.getId()) + .params("type", "1") + .params("sign", "1") + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msgs, String[] info) { + if (code == 0) { + L.eSw("555555555555555555555555555555555555"); + final SocketSendBean msg1 = new SocketSendBean() + .param("_method_", Constants.SOCKET_LINK_MIC_PK) + .param("action", 4) + .param("pkname", u.getUserNiceName()) + .param("pkuid", u.getId()) + .param("pkhead", u.getAvatar()) + .param("uname", u.getUserNiceName()) + .param("uhead", u.getAvatar()) + .param("uid", CommonAppConfig.getInstance().getUid()); + msg1.create(); - Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; - TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); - Message message1 = Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent); + Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; + TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); + Message message1 = Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent); - RongIMClient.getInstance().sendMessage(message1, null, null, new IRongCallback.ISendMessageCallback() { - @Override - public void onAttached(Message message) { + RongIMClient.getInstance().sendMessage(message1, null, null, new IRongCallback.ISendMessageCallback() { + @Override + public void onAttached(Message message) { - } + } - @Override - public void onSuccess(Message message) { - Log.i("tx", "发送成功"); - } + @Override + public void onSuccess(Message message) { + Log.i("tx", "发送成功"); + } - @Override - public void onError(Message message, RongIMClient.ErrorCode errorCode) { + @Override + public void onError(Message message, RongIMClient.ErrorCode errorCode) { - } - }); - } + } + }); + } - } - }); - } - } - }); + } + }); + } + } + }); mLiveSwLinkMicPkPresenter.setPkUserInfoView(u); } @@ -346,22 +346,23 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX private int currentPosition = 0; private String drpkUid3 = ""; + public int setAnDrPkRtc(String uid, int position) { - L.eSw("setAnDrPkRtc uid:"+uid+" position"+position); - int temp= -1; + L.eSw("setAnDrPkRtc uid:" + uid + " position" + position); + int temp = -1; if (swManager != null && !StringUtil.isEmpty(uid)) { L.eSw("设置对方主播的视图 setAnDrPkRtc" + uid + "position:" + position); - if(currentPosition==0){ + if (currentPosition == 0) { position = 2; } - if(position==-1){ - temp = currentPosition+1; - }else{ + if (position == -1) { + temp = currentPosition + 1; + } else { temp = position; } switch (temp) { case 2: - swManager.joinChannelDrEx(dr2_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid)); + swManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid)); swManager.updateMyChannelView(dr1_preview); mBigContainer.removeAllViews(); @@ -370,17 +371,17 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX break; case 3: drpkUid3 = uid; - swManager.joinChannelDrEx(dr4_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid)); + swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid)); dr3_preview.setVisibility(View.GONE); dr4_preview.setVisibility(View.VISIBLE); break; case 4: dr3_preview.setVisibility(View.VISIBLE); //先退出这个主播的直播间,在进入该直播间,(视图问题暂时這樣處理) - swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drpkUid3); - swManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3)); + swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drpkUid3); + swManager.joinChannelDrEx(dr3_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3)); - swManager.joinChannelDrEx(dr4_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid)); + swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid)); break; } dr_pk_view.setVisibility(View.VISIBLE); @@ -389,7 +390,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX return currentPosition; } - public void anchorClose(){ + public void anchorClose() { swManager.updateMyChannelView((FrameLayout) mBigContainer); //用户主动断开连麦再退出画面 } @@ -399,7 +400,6 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX } - public void onLinkDRMicPkApply(UserBean userBean) { if (mLiveSwLinkMicPkPresenter != null) { mLiveSwLinkMicPkPresenter.onLinkDRMicPkApply(userBean); @@ -439,6 +439,10 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX btn_close.setVisibility(View.GONE); } + public void showButtonGone() { + btn_close.setVisibility(View.VISIBLE); + } + @Override public void toggleCamera() { if (mCameraFront) { @@ -471,86 +475,6 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX if (swManager != null) { swManager.createChannel(CommonAppConfig.SWToken, CommonAppConfig.getChannelName()); } - if (rcrtcLiveInfo != null) { - rcrtcLiveInfo.addPublishStreamUrl(pushUrl, new IRCRTCResultDataCallback() { - @Override - public void onSuccess(String[] data) { - //强制设置开播后cdn的尺寸竖屏,因为有时候PK异常退出,cdn没有还原竖屏。 - if (rtcRoom != null) { - RCRTCMixConfig config = new RCRTCMixConfig(); - RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig(); - config.setMediaConfig(mediaConfig); - //视频输出配置 - RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig(); - mediaConfig.setVideoConfig(videoConfig); - //大流视频的输出参数 - RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout(); - - //推荐宽、高、帧率参数值可以通过默认视频流的配置获取,也可以根据实际需求来自定义设置 - //如不设置宽高值则服务端将使用默认宽高 360 * 640 - //例:发布的视频分辨率为720 * 1280,如果不设置则观众端看到的视频分辨率为 360 * 640, - //所以如果想让观众端看到的视频分辨率和发布视频分辨率一致,则应从发布的视频流中获取分辨率配置并设置到 mediaConfig 中 - //設置開播分辨率 - //設置開播分辨率 - RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; - int minRate = 200; - int maxRate = 900; - switch (IMLoginManager.get(mContext).getSelectClarity()) { - case 0: - rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; - break; - case 1: - rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280; - break; - case 2: - rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920; - break; - } - int width = rcrtcVideoResolution.getWidth(); - int height = rcrtcVideoResolution.getHeight(); - normal.setWidth(width); //视频宽 - normal.setHeight(height); //视频高 - normal.setFps(15); //视频帧率 - videoConfig.setVideoLayout(normal); - //2. 合流画布设置 - //(请参照画布和声音配置示例代码) - //3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准),设置每个视频流小窗口的坐标及宽高 - ArrayList list = new ArrayList<>(); - config.setCustomLayouts(list); - //user1的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - list.add(videoLayout1); - videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video - videoLayout1.setX(0); //X 坐标 - videoLayout1.setY(0); //Y 坐标 - videoLayout1.setWidth(720); // 视频窗口的宽 - videoLayout1.setHeight(1280); // 视频窗口的高 - //2. 合流画布设置 - rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "混成功12"); - } - - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", "混失败" + errorCode); - - } - }); - } - - - } - - @Override - public void onFailed(RTCErrorCode errorCode) { - } - }); - startCountDown(); - } else { - ToastUtil.show("请稍后,准备中...."); - } } public boolean isPking() { @@ -563,7 +487,6 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX @Override public void onPause() { mPaused = true; - } @Override diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java index 7fb4954ca..a06dc20a3 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java @@ -122,6 +122,8 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL public abstract void initSwEngine(String liveUid); + public abstract void removeLiveUid(String uid); + public abstract void removeDetailView(); public abstract void setPkView(String liveUid); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java index 02e100b65..bf024bd45 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java @@ -25,6 +25,7 @@ import androidx.core.content.ContextCompat; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; +import com.google.gson.Gson; import com.ms.banner.Banner; import com.ms.banner.BannerConfig; import com.ms.banner.listener.OnBannerClickListener; @@ -40,6 +41,7 @@ import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.L; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; @@ -87,6 +89,25 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { private TextView mLiveTimeTextView;//主播的直播时长 private long mAnchorLiveTime;//主播直播时间 private LiveRoomHandler mLiveRoomHandler; + private static LinearLayout btn_end_pk_dr; + private String drpkRoomId; //多人 PK 房主 roomUid + public void setDrpkRoomId(String drpkRoomId) { + this.drpkRoomId = drpkRoomId; + } + + public void showEndPkBt(){ + if(btn_end_pk_dr!=null){ + if(btn_start_dr_pk_view.getVisibility()==View.GONE){ + btn_end_pk_dr.setVisibility(View.VISIBLE); + } + } + } + + public void closeEndPkBt(){ + if(btn_end_pk_dr!=null){ + btn_end_pk_dr.setVisibility(View.GONE); + } + } public LiveRyAnchorViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -108,6 +129,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { Bus.getOn(this); mDrawable0 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_0); mDrawable1 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_1); + btn_end_pk_dr = (LinearLayout) findViewById(R.id.btn_end_pk_dr); mBtnFunction = (ImageView) findViewById(R.id.btn_function); btn_dr = (TextView) findViewById(R.id.btn_dr); mBanner = (Banner) findViewById(R.id.banner); @@ -171,6 +193,22 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { yaoqing.clear(); } }); + btn_end_pk_dr.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + closeEndPkBt(); + HttpClient.getInstance().post("live.leaveDRPKroom", "live.leaveDRPKroom") + .params("roomid", drpkRoomId) + .params("uid", CommonAppConfig.getInstance().getUid()) + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + L.eSw("live.leaveDRPKroom:code:" + code + " info" + new Gson().toJson(info)); + + } + }); + } + }); btn_dr.setOnClickListener(new View.OnClickListener() { @Override @@ -204,6 +242,10 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { yaoqing.put(numinda, numinda); } + public void removeYaoqing(String numinda){ + yaoqing.remove(numinda); + } + @Override public void onClick(View v) { if (!canClick()) { diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 12e1183bc..dcc465b40 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -389,7 +389,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe liveHandler.removeCallbacks(loadTimeoutRunnableGone); if (mLivePlayViewHolder == null) { if (isSw) { - mLivePlayViewHolder = new LivePlaySwViewHolder(mContext, playContainer, 1); + mLivePlayViewHolder = new LivePlaySwViewHolder(mContext, playContainer, mLiveBean.getLandscape()); } else { mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1); } @@ -419,7 +419,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveAudienceViewHolder.subscribeActivityLifeCycle(); } else { mLivePlayViewHolder.initSwEngine(liveID); - mLivePlayViewHolder.setLiveBeanLandscape(1); + mLivePlayViewHolder.setLiveBeanLandscape(mLiveBean.getLandscape()); mLiveLinkMicPresenter.setLiveSdk(mLiveSDK); mLiveLinkMicAnchorPresenter.setLiveSdk(mLiveSDK); } @@ -983,6 +983,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRyLinkMicPkPresenter.release(); mLiveRyLinkMicPkPresenter = null; } + if(mLiveSwLinkMicPkPresenter!=null){ + mLiveSwLinkMicPkPresenter.clearData(); + mLiveSwLinkMicPkPresenter.release(); + mLiveSwLinkMicPkPresenter = null; + } if(mLivePlayViewHolder!=null){ mLivePlayViewHolder.stopPlay2(); } @@ -1705,6 +1710,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //mLivePlayViewHolder.setDrMicInfo(u); } + @Override + public void onLinkDRMicPkQuit(String uid) { + L.eSw("onLinkDRMicPkQuit:"+uid); + mLivePlayViewHolder.removeLiveUid(uid); + } + /** * 主播与主播PK 所有人收到PK开始的回调 */ diff --git a/live/src/main/res/layout/view_live_push_sw.xml b/live/src/main/res/layout/view_live_push_sw.xml index 4cd13440a..bbe8f0a50 100644 --- a/live/src/main/res/layout/view_live_push_sw.xml +++ b/live/src/main/res/layout/view_live_push_sw.xml @@ -44,7 +44,7 @@ android:layout_height="270dp" android:layout_marginTop="130dp" android:orientation="horizontal" - android:visibility="visible"> + android:visibility="gone"> + + + + + +