add[声望升级-多人PK]

This commit is contained in:
Martin 2024-04-30 18:29:09 +08:00
parent 7d46ab8520
commit b4adf4c77c
13 changed files with 268 additions and 153 deletions

View File

@ -114,6 +114,17 @@ public class EnterRoomInfoModel extends BaseModel {
@SerializedName("gift_wall_lighten_total") @SerializedName("gift_wall_lighten_total")
private String giftWallLightenTotal; private String giftWallLightenTotal;
@SerializedName("connection_info")
private LivePkMicModel connectionInfo;
public LivePkMicModel getConnectionInfo() {
return connectionInfo;
}
public void setConnectionInfo(LivePkMicModel connectionInfo) {
this.connectionInfo = connectionInfo;
}
public String getGiftWallLightenNumber() { public String getGiftWallLightenNumber() {
return giftWallLightenNumber; return giftWallLightenNumber;
} }

View File

@ -0,0 +1,36 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class LivePkMicModel extends BaseModel {
@SerializedName("pkuid")
private String pkuid;
@SerializedName("pkuname")
private String pkuname;
@SerializedName("pkuimg")
private String pkuimg;
public String getPkuid() {
return pkuid;
}
public void setPkuid(String pkuid) {
this.pkuid = pkuid;
}
public String getPkuname() {
return pkuname;
}
public void setPkuname(String pkuname) {
this.pkuname = pkuname;
}
public String getPkuimg() {
return pkuimg;
}
public void setPkuimg(String pkuimg) {
this.pkuimg = pkuimg;
}
}

View File

@ -232,7 +232,6 @@ public class SWAuManager extends BaseCacheManager {
}); });
} }
/** /**
* 退出对方直播间 * 退出对方直播间
* @param uid 自己的ID * @param uid 自己的ID
@ -246,8 +245,12 @@ public class SWAuManager extends BaseCacheManager {
} }
public static String getChannelName(String liveUid) { public static String getChannelName(String liveUid) {
if(liveUid.contains("g")){
return liveUid;
}else{
return CommonAppConfig.SWChannelPrefix + liveUid; return CommonAppConfig.SWChannelPrefix + liveUid;
} }
}
//远程监听 //远程监听
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() { private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {

View File

@ -218,7 +218,7 @@ public class SWManager extends BaseCacheManager {
surfaceView.setZOrderMediaOverlay(true); surfaceView.setZOrderMediaOverlay(true);
frameLayout.addView(surfaceView); frameLayout.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN , uid);
mRtcEngine.setupLocalVideo(videoCanvas); mRtcEngine.setupLocalVideo(videoCanvas);
} }
@ -262,7 +262,7 @@ public class SWManager extends BaseCacheManager {
SurfaceView surfaceView = new SurfaceView(mContext); SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true); surfaceView.setZOrderMediaOverlay(true);
pkContainer.addView(surfaceView); pkContainer.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT,Integer.parseInt(toUid)); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN ,Integer.parseInt(toUid));
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
} }
}); });
@ -310,6 +310,7 @@ public class SWManager extends BaseCacheManager {
rtcConnection.channelId = channelName; //對方主播的頻道 rtcConnection.channelId = channelName; //對方主播的頻道
rtcConnection.localUid = tempUid;//自己的ID rtcConnection.localUid = tempUid;//自己的ID
L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName); L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName);
// 用内部通知刷新多人PK的用户信息
mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() { mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
@Override @Override
public void onJoinChannelSuccess(String channel, int scUid, int elapsed) { public void onJoinChannelSuccess(String channel, int scUid, int elapsed) {
@ -321,7 +322,7 @@ public class SWManager extends BaseCacheManager {
SurfaceView surfaceView = new SurfaceView(mContext); SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true); surfaceView.setZOrderMediaOverlay(true);
frameLayout.addView(surfaceView); frameLayout.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT,Integer.parseInt(toUid)); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN ,Integer.parseInt(toUid));
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
} }
}); });
@ -450,6 +451,10 @@ public class SWManager extends BaseCacheManager {
this.linkUserContainer = linkUserContainer; this.linkUserContainer = linkUserContainer;
} }
public static String getChannelName(String liveUid) { public static String getChannelName(String liveUid) {
if(liveUid.contains("g")){
return liveUid;
}else{
return CommonAppConfig.SWChannelPrefix + liveUid; return CommonAppConfig.SWChannelPrefix + liveUid;
} }
}
} }

View File

@ -406,6 +406,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
if (code == 0) { if (code == 0) {
LiveRyLinkMicPkPresenter.mApplyUid = CommonAppConfig.getInstance().getUid();
btn_start_dr_pk.setVisibility(View.VISIBLE); btn_start_dr_pk.setVisibility(View.VISIBLE);
// dr_pk_view.setVisibility(View.VISIBLE); // dr_pk_view.setVisibility(View.VISIBLE);
final SocketSendBean msg1 = new SocketSendBean() final SocketSendBean msg1 = new SocketSendBean()

View File

@ -112,7 +112,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mIsAnchor = isAnchor; mIsAnchor = isAnchor;
mRoot = root; mRoot = root;
mPkContainer = linkMicViewHolder.getPkContainer(); mPkContainer = linkMicViewHolder.getPkContainer();
mPkTimeString2 =mContext.getString(R.string.live_pk_time_2); mPkTimeString2 = mContext.getString(R.string.live_pk_time_2);
//从本地取数据 //从本地取数据
String pkTime = CommonAppConfig.getInstance().getAnchorPkTime(); String pkTime = CommonAppConfig.getInstance().getAnchorPkTime();
@ -773,7 +773,8 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
final SocketSendBean msg = new SocketSendBean() final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_DRPK) .param("_method_", Constants.SOCKET_LIVE_DRPK)
.param("action", 2) .param("action", 2)
.param("uid", CommonAppConfig.getInstance().getUid()); .param("uid", u.getId())
.param("pkuid",CommonAppConfig.getInstance().getUid());
msg.create(); msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), list.get(i).getId() + "", new V2TIMSendCallback<V2TIMMessage>() { V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), list.get(i).getId() + "", new V2TIMSendCallback<V2TIMMessage>() {
@Override @Override

View File

@ -1022,9 +1022,31 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
drPkbeans.remove(removeIndex); drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans)); L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
} }
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) {
JSONObject obj = JSONObject.parseObject(info[0]);
drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
int removeIndex = -1;
for (int i = 0; i < drPkbeans.size(); i++) { for (int i = 0; i < drPkbeans.size(); i++) {
if (CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
removeIndex = i;
}
}
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
}
for (int i = 0; i <drPkbeans.size(); i++) {
if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) { 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", drPkbeans.get(i).getId()).param("uid", CommonAppConfig.getInstance().getUid()).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("uid", drPkbeans.get(i).getId())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create(); msg1.create();
String targetId = "g" + drPkbeans.get(i).getId(); String targetId = "g" + drPkbeans.get(i).getId();
@ -1058,6 +1080,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
} }
dRjoinOtherRoom(u); dRjoinOtherRoom(u);
}
}
});
/*for (int i = 0; i < users.size(); i++) { /*for (int i = 0; i < users.size(); i++) {
JSONObject user = users.getJSONObject(i); JSONObject user = users.getJSONObject(i);
@ -1221,7 +1247,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
setMyDrPkDetailsView(); setMyDrPkDetailsView();
isShow = true; isShow = true;
} }
HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", u.getId()).execute(new HttpCallback() { HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", mApplyUid).execute(new HttpCallback() {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
if (info.length > 0) { if (info.length > 0) {
@ -1235,7 +1261,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
if (removeIndex != -1) { if (removeIndex != -1) {
drPkbeans.remove(removeIndex); drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
} }
setDrPkUserInfoView(drPkbeans); setDrPkUserInfoView(drPkbeans);
} }
@ -1244,8 +1269,13 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
private void setDrPkUserInfoView(List<DrPkbean> drPkbeanList) { private void setDrPkUserInfoView(List<DrPkbean> drPkbeanList) {
L.eSw("setDrPkUserInfoView"+new Gson().toJson(drPkbeanList));
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
for (int j = 0; j <drPkbeanList.size(); j++) { for (int j = 0; j <drPkbeanList.size(); j++) {
if (j == 0) { if (j == 0) {
L.eSw("j == 0"+j);
//设置多人PK数据 //设置多人PK数据
if (detailsView2 != null) { if (detailsView2 != null) {
livePushRyViewHolder.dr2_preview.removeView(detailsView2); livePushRyViewHolder.dr2_preview.removeView(detailsView2);
@ -1262,6 +1292,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
detailsLinearLayout2.setVisibility(View.VISIBLE); detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE); linearGrade2.setVisibility(View.GONE);
} else if (j == 1) { } else if (j == 1) {
L.eSw("j == 1"+j);
if (detailsView4 != null) { if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4); livePushRyViewHolder.dr4_preview.removeView(detailsView4);
} }
@ -1277,21 +1308,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
detailsLinearLayout4.setVisibility(View.VISIBLE); detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE);
} else if (j == 2) { } else if (j == 2) {
//设置多人PK数据 L.eSw("j == 2"+j);
if (detailsView3 != null) {
livePushRyViewHolder.dr3_preview.removeView(detailsView3);
}
detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3);
linearGrade3 = detailsView3.findViewById(R.id.linear_grade3);
textPkName3 = detailsView3.findViewById(R.id.text_pk_name3);
imageGrade3 = detailsView3.findViewById(R.id.image_grade3);
textGrade3 = detailsView3.findViewById(R.id.text_grade3);
imageGrade3.setTag(String.valueOf(drPkbeanList.get(1).getId()));
textPkName3.setText(drPkbeanList.get(1).getUser_nicename());
livePushRyViewHolder.dr3_preview.addView(detailsView3);
detailsLinearLayout3.setVisibility(View.VISIBLE);
linearGrade3.setVisibility(View.GONE);
if (detailsView4 != null) { if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4); livePushRyViewHolder.dr4_preview.removeView(detailsView4);
@ -1308,10 +1325,28 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
detailsLinearLayout4.setVisibility(View.VISIBLE); detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE);
if (detailsView3 != null) {
livePushRyViewHolder.dr3_preview.removeView(detailsView3);
}
detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3);
linearGrade3 = detailsView3.findViewById(R.id.linear_grade3);
textPkName3 = detailsView3.findViewById(R.id.text_pk_name3);
imageGrade3 = detailsView3.findViewById(R.id.image_grade3);
textGrade3 = detailsView3.findViewById(R.id.text_grade3);
imageGrade3.setTag(String.valueOf(drPkbeanList.get(1).getId()));
textPkName3.setText(drPkbeanList.get(1).getUser_nicename());
livePushRyViewHolder.dr3_preview.addView(detailsView3);
detailsLinearLayout3.setVisibility(View.VISIBLE);
linearGrade3.setVisibility(View.GONE);
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success"); ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
} }
} }
}
},1000);
L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList)); L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList));
} }

View File

@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSON;
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.GsonUtils; import com.blankj.utilcode.util.GsonUtils;
import com.google.gson.Gson;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
@ -216,8 +217,7 @@ public class SocketRyClient {
EventBus.getDefault().post("endMic"); EventBus.getDefault().post("endMic");
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE).setObject(map.toJavaObject(LinkMicUserBean.class))); Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE).setObject(map.toJavaObject(LinkMicUserBean.class)));
} else if (actions == 8) { } else if (actions == 8) {
//踢下麥 //提下買退出
if (WordUtil.isNewZh()) { if (WordUtil.isNewZh()) {
ToastUtil.show("您已被移出多人語音連麥"); ToastUtil.show("您已被移出多人語音連麥");
} else { } else {
@ -302,6 +302,7 @@ public class SocketRyClient {
// break; // break;
case Constants.SOCKET_LIVE_DRPK_RANDOM: case Constants.SOCKET_LIVE_DRPK_RANDOM:
case Constants.SOCKET_LIVE_DRPK://多人PK case Constants.SOCKET_LIVE_DRPK://多人PK
L.eSw("map"+new Gson().toJson(map));
int action3 = map.getIntValue("action"); int action3 = map.getIntValue("action");
//收到多人PK邀请 //收到多人PK邀请
if (action3 == 1) { if (action3 == 1) {
@ -314,7 +315,7 @@ public class SocketRyClient {
else if (action3 == 2) { else if (action3 == 2) {
UserBean u = new UserBean(); UserBean u = new UserBean();
// u.setUserNiceName(map.getString("uname")); // u.setUserNiceName(map.getString("uname"));
u.setId(map.getString("uid")); u.setId(map.getString("pkuid"));
L.eSw("action3 == 2:"+u.getId()); L.eSw("action3 == 2:"+u.getId());
mListener.onLinkDRMicPkApplyOk(u); mListener.onLinkDRMicPkApplyOk(u);
} else if (action3 == 6) {//开始Pk } else if (action3 == 6) {//开始Pk

View File

@ -208,55 +208,65 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
/** /**
* 开启单人PK * 开启单人PK
*
* @param Uid * @param Uid
*/ */
public void setPkView(String Uid) { public void setPkView(String Uid) {
L.eSw("setPkView Uid "+Uid);
mPkContainer.setVisibility(View.VISIBLE);
swAuManager.updateMyChannelView((FrameLayout) mLeftContainer, Integer.parseInt(liveUid)); swAuManager.updateMyChannelView((FrameLayout) mLeftContainer, Integer.parseInt(liveUid));
ry_view.removeAllViews(); ry_view.removeAllViews();
//加入对方主播房间 //加入对方主播房间
swAuManager.setPkContainer1((FrameLayout) mRightContainer); swAuManager.setPkContainer1((FrameLayout) mRightContainer);
swAuManager.joinExRoomEx(Integer.parseInt(Uid), CommonAppConfig.SWToken, SWAuManager.getChannelName(Uid)); swAuManager.joinExRoomEx(Integer.parseInt(Uid), CommonAppConfig.SWToken, SWAuManager.getChannelName(Uid));
} }
List<UserBean> drMicUserList = new ArrayList<>(); List<UserBean> drMicUserList = new ArrayList<>();
boolean isAdd = true; boolean isAdd = true;
@Override @Override
public void setDrMicInfo(UserBean u) { public void setDrMicInfo(UserBean u) {
L.eSw("setDrMicInfo:"+u.getId()+" drMicUserList:"+new Gson().toJson(drMicUserList)); L.eSw("setDrMicInfo:-----------------" + u.getId());
for (int i = 0; i <drMicUserList.size(); i++) { for (int i = 0; i < drMicUserList.size(); i++) {
if(u.getId().equals(drMicUserList.get(i).getId())){ if (u.getId().equals(drMicUserList.get(i).getId())) {
isAdd = false; isAdd = false;
} }
} }
//加载多人PK(连麦)主播视图 //加载多人PK(连麦)主播视图
if(isAdd){ if (isAdd) {
dr_pk_view.setVisibility(View.VISIBLE); dr_pk_view.setVisibility(View.VISIBLE);
drMicUserList.add(u); drMicUserList.add(u);
if(drMicUserList.size()==1){ if (drMicUserList.size() == 1) {
L.eSw("setDrMicInfo:-----------------drMicUserList.size() == 1");
ry_view.removeAllViews(); ry_view.removeAllViews();
swAuManager.updateMyChannelView((FrameLayout) dr1_preview, Integer.parseInt(liveUid)); swAuManager.updateMyChannelView((FrameLayout) dr1_preview, Integer.parseInt(liveUid));
swAuManager.joinChannelDrEx(dr2_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, u.getId(),SWAuManager.getChannelName(u.getId())); swAuManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId()));
dr2_preview.setVisibility(View.VISIBLE);
dr3_preview.setVisibility(View.GONE); dr3_preview.setVisibility(View.GONE);
dr4_preview.setVisibility(View.GONE); dr4_preview.setVisibility(View.GONE);
}else if(drMicUserList.size()==2){ } else if (drMicUserList.size() == 2) {
dr3_preview.setVisibility(View.GONE); L.eSw("setDrMicInfo:-----------------drMicUserList.size() == 2");
dr4_preview.setVisibility(View.VISIBLE); dr4_preview.setVisibility(View.VISIBLE);
swAuManager.joinChannelDrEx(dr4_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, u.getId(),SWAuManager.getChannelName(u.getId())); swAuManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId()));
}else if(drMicUserList.size()==3){ } else if (drMicUserList.size() == 3) {
L.eSw("setDrMicInfo:-----------------drMicUserList.size() == 3");
dr4_preview.setVisibility(View.VISIBLE); dr4_preview.setVisibility(View.VISIBLE);
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drMicUserList.get(1).getId()); dr3_preview.setVisibility(View.VISIBLE);
swAuManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, drMicUserList.get(1).getId(),SWAuManager.getChannelName(drMicUserList.get(1).getId())); swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drMicUserList.get(1).getId());
swAuManager.joinChannelDrEx(dr4_preview,CommonAppConfig.getInstance().getUid(),CommonAppConfig.SWToken, drMicUserList.get(2).getId(),SWAuManager.getChannelName(drMicUserList.get(2).getId())); swAuManager.joinChannelDrEx(dr3_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drMicUserList.get(1).getId(), SWAuManager.getChannelName(drMicUserList.get(1).getId()));
swAuManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drMicUserList.get(2).getId(), SWAuManager.getChannelName(drMicUserList.get(2).getId()));
} }
} }
} }
/** /**
* 退出单人pk * 退出单人pk
*
* @param pkUid * @param pkUid
*/ */
public void endpk(String pkUid) { public void endpk(String pkUid) {
mPkContainer.setVisibility(View.GONE);
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid)); swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid));
swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid)); swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid));
mLeftContainer.removeAllViews(); mLeftContainer.removeAllViews();
@ -266,15 +276,19 @@ boolean isAdd = true;
/** /**
* 退出所有连麦主播的房間 * 退出所有连麦主播的房間
*/ */
public void endPk(){ public void endPk() {
dr_pk_view.setVisibility(View.GONE); dr_pk_view.setVisibility(View.GONE);
dr1_preview.setVisibility(View.GONE);
dr2_preview.setVisibility(View.GONE);
dr3_preview.setVisibility(View.GONE);
dr4_preview.setVisibility(View.GONE);
dr1_preview.removeAllViews(); dr1_preview.removeAllViews();
dr2_preview.removeAllViews(); dr2_preview.removeAllViews();
dr3_preview.removeAllViews(); dr3_preview.removeAllViews();
dr4_preview.removeAllViews(); dr4_preview.removeAllViews();
//退出所有连麦主播的房間 //退出所有连麦主播的房間
for (int i = 0; i <drMicUserList.size(); i++) { for (int i = 0; i < drMicUserList.size(); i++) {
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drMicUserList.get(i).getId()); swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drMicUserList.get(i).getId());
} }
//將當前主播畫面放大 //將當前主播畫面放大
swAuManager.updateMyChannelView((FrameLayout) ry_view, Integer.parseInt(liveUid)); swAuManager.updateMyChannelView((FrameLayout) ry_view, Integer.parseInt(liveUid));
@ -285,13 +299,11 @@ boolean isAdd = true;
*/ */
private void joinLiveMic() { private void joinLiveMic() {
L.eSw("joinLiveMic"); L.eSw("joinLiveMic");
HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm") HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm").params("roomid", LiveActivity.mLiveUid).execute(new HttpCallback() {
.params("roomid", LiveActivity.mLiveUid)
.execute(new HttpCallback() {
@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 + "热热热");
if(code==0){ if (code == 0) {
swAuManager.setMicAn(true); swAuManager.setMicAn(true);
} }
} }
@ -801,7 +813,7 @@ boolean isAdd = true;
builder.build().show(); builder.build().show();
} else if ("endMic".equals(str)) { } else if ("endMic".equals(str)) {
L.eSw("endMic.equals(str))"+str); L.eSw("endMic.equals(str))" + str);
// 开始切换为观众身份 // 开始切换为观众身份
//声网-将用户身份切换只观众 //声网-将用户身份切换只观众
endLiveMic(); endLiveMic();

View File

@ -583,12 +583,14 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
} }
} }
SWManager.get().updateMyChannelView((FrameLayout) mBigContainer); SWManager.get().updateMyChannelView((FrameLayout) mBigContainer);
currentPosition = 0;
drpkUid3 = "";
} }
public void setAnPkRtc(UserBean u) { public void setAnPkRtc(UserBean u) {
if (swManager != null && u != null) { if (swManager != null && u != null) {
L.eSw("设置对方主播的视图setAnPkRtc" + u); L.eSw("设置对方主播的视图setAnPkRtc" + u);
mPkContainer.setVisibility(View.VISIBLE);
//将自己的渲染视图设置到 leftContainer //将自己的渲染视图设置到 leftContainer
swManager.updateMyChannelView((FrameLayout) mLeftContainer); swManager.updateMyChannelView((FrameLayout) mLeftContainer);
//清除 mBigContainer 中的渲染 //清除 mBigContainer 中的渲染

View File

@ -5276,7 +5276,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void upDataPkScore(JSONArray pkScores, int time) { public void upDataPkScore(JSONArray pkScores, int time) {
L.eSw("upDataPkScore(JSONArray pkScores, int time) {"+new Gson().toJson(pkScores)); L.eSw("upDataPkScore(JSONArray pkScores, int time) {"+new Gson().toJson(pkScores));
isShowGif = true; isShowGif = true;
/*if (detailsView == null) { if (detailsView == null) {
L.eSw("upDataPkScore(JSONArray pkScores, int time) {detailsView=null"); L.eSw("upDataPkScore(JSONArray pkScores, int time) {detailsView=null");
detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
timeTitle = detailsView.findViewById(R.id.time_title); timeTitle = detailsView.findViewById(R.id.time_title);
@ -5316,7 +5316,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
detailsView.setLayoutParams(params); detailsView.setLayoutParams(params);
} }
}); });
}*/ }
if (time > 0) { if (time > 0) {
mPkTimeCount2 = time; mPkTimeCount2 = time;
drPKtIME = time; drPKtIME = time;

View File

@ -38,6 +38,7 @@ import com.yunbao.common.bean.BannerBean;
import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.LivePkMicModel;
import com.yunbao.common.bean.LiveRoomActivityModel; import com.yunbao.common.bean.LiveRoomActivityModel;
import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
@ -644,17 +645,22 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if(mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")){ if(mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")){
JSONArray array = pkInfo.getJSONArray("userlist"); JSONArray array = pkInfo.getJSONArray("userlist");
//判断是否是多人连麦 //判断是否是多人连麦
if(array!=null){//多人連麥 if(array.size()>0){//多人連麥
if (mLivePlayViewHolder != null) { if (mLivePlayViewHolder != null) {
for (int j = 0; j < array.size(); j++) { for (int j = 0; j < array.size(); j++) {
UserBean drPkbean = new UserBean(); UserBean drPkbean = new UserBean();
JSONObject da = array.getJSONObject(j); JSONObject da = array.getJSONObject(j);
if(!String.valueOf(da.getIntValue("id")).equals(String.valueOf(data.getLiveInfo().getUid()))){
drPkbean.setId(String.valueOf(da.getIntValue("id"))); drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean); mLivePlayViewHolder.setDrMicInfo(drPkbean);
} }
} }
}
}else{//单人连麦 }else{//单人连麦
mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid()); LivePkMicModel connection_info = data.getEnterRoomInfo().getConnectionInfo();
if(!StringUtil.isEmpty(connection_info.getPkuid())){
mLivePlayViewHolder.setPkView(connection_info.getPkuid());
}
} }
} }
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
@ -709,10 +715,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
for (int j = 0; j < array.size(); j++) { for (int j = 0; j < array.size(); j++) {
UserBean drPkbean = new UserBean(); UserBean drPkbean = new UserBean();
JSONObject da = array.getJSONObject(j); JSONObject da = array.getJSONObject(j);
if(!String.valueOf(da.getIntValue("id")).equals(data.getLiveInfo().getUid())){
drPkbean.setId(String.valueOf(da.getIntValue("id"))); drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean); mLivePlayViewHolder.setDrMicInfo(drPkbean);
} }
} }
}
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time")); upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
} }
@ -768,10 +776,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel)); mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel));
} }
} }
//liveHandler.postDelayed(loadTimeoutRunnableGone, 15_000);
AppManager.runDebugCode(() -> { AppManager.runDebugCode(() -> {
// liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000); liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000);
}); });
liveHandler.postDelayed(loadTimeoutRunnableGone, 15_000);
if (TextUtils.equals(data.getEnterRoomInfo().getIsconnection(), "1")) { if (TextUtils.equals(data.getEnterRoomInfo().getIsconnection(), "1")) {
//通知心愿单位置换地方 //通知心愿单位置换地方
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent()

View File

@ -72,7 +72,7 @@
android:layout_height="270dp" android:layout_height="270dp"
android:layout_marginTop="130dp" android:layout_marginTop="130dp"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="visible"> android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"