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")
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() {
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
@ -246,7 +245,11 @@ public class SWAuManager extends BaseCacheManager {
}
public static String getChannelName(String liveUid) {
return CommonAppConfig.SWChannelPrefix + liveUid;
if(liveUid.contains("g")){
return liveUid;
}else{
return CommonAppConfig.SWChannelPrefix + liveUid;
}
}
//远程监听

View File

@ -218,7 +218,7 @@ public class SWManager extends BaseCacheManager {
surfaceView.setZOrderMediaOverlay(true);
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);
}
@ -262,7 +262,7 @@ public class SWManager extends BaseCacheManager {
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
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);
}
});
@ -310,6 +310,7 @@ public class SWManager extends BaseCacheManager {
rtcConnection.channelId = channelName; //對方主播的頻道
rtcConnection.localUid = tempUid;//自己的ID
L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName);
// 用内部通知刷新多人PK的用户信息
mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
@Override
public void onJoinChannelSuccess(String channel, int scUid, int elapsed) {
@ -321,7 +322,7 @@ public class SWManager extends BaseCacheManager {
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
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);
}
});
@ -450,6 +451,10 @@ public class SWManager extends BaseCacheManager {
this.linkUserContainer = linkUserContainer;
}
public static String getChannelName(String liveUid) {
return CommonAppConfig.SWChannelPrefix + liveUid;
if(liveUid.contains("g")){
return liveUid;
}else{
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) {
if (code == 0) {
LiveRyLinkMicPkPresenter.mApplyUid = CommonAppConfig.getInstance().getUid();
btn_start_dr_pk.setVisibility(View.VISIBLE);
// dr_pk_view.setVisibility(View.VISIBLE);
final SocketSendBean msg1 = new SocketSendBean()

View File

@ -112,7 +112,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mIsAnchor = isAnchor;
mRoot = root;
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();
@ -773,7 +773,8 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_DRPK)
.param("action", 2)
.param("uid", CommonAppConfig.getInstance().getUid());
.param("uid", u.getId())
.param("pkuid",CommonAppConfig.getInstance().getUid());
msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), list.get(i).getId() + "", new V2TIMSendCallback<V2TIMMessage>() {
@Override

View File

@ -1022,42 +1022,68 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
}
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", drPkbeans.get(i).getId()).param("uid", CommonAppConfig.getInstance().getUid()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create();
String targetId = "g" + drPkbeans.get(i).getId();
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
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++) {
if (CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
removeIndex = i;
}
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("tx", "aaa" + errorCode.toString());
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
}
});
//
int index = livePushRyViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1);
L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 " + u.getUserNiceName());
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("uid", drPkbeans.get(i).getId())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create();
String targetId = "g" + drPkbeans.get(i).getId();
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("tx", "aaa" + errorCode.toString());
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
}
});
//
int index = livePushRyViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1);
L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 " + u.getUserNiceName());
}
}
dRjoinOtherRoom(u);
}
}
}
dRjoinOtherRoom(u);
});
/*for (int i = 0; i < users.size(); i++) {
JSONObject user = users.getJSONObject(i);
@ -1221,7 +1247,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
setMyDrPkDetailsView();
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
public void onSuccess(int code, String msg, String[] info) {
if (info.length > 0) {
@ -1235,7 +1261,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
}
setDrPkUserInfoView(drPkbeans);
}
@ -1244,74 +1269,84 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
private void setDrPkUserInfoView(List<DrPkbean> drPkbeanList) {
for (int j = 0; j <drPkbeanList.size(); j++) {
if (j == 0) {
//设置多人PK数据
if (detailsView2 != null) {
livePushRyViewHolder.dr2_preview.removeView(detailsView2);
}
detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
textGrade2 = detailsView2.findViewById(R.id.text_grade2);
imageGrade2.setTag(String.valueOf(drPkbeanList.get(0).getId()));
textPkName2.setText(drPkbeanList.get(0).getUser_nicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
} else if (j == 1) {
if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
}
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(String.valueOf(drPkbeanList.get(1).getId()));
textPkName4.setText(drPkbeanList.get(1).getUser_nicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
} else if (j == 2) {
//设置多人PK数据
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);
L.eSw("setDrPkUserInfoView"+new Gson().toJson(drPkbeanList));
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
for (int j = 0; j <drPkbeanList.size(); j++) {
if (j == 0) {
L.eSw("j == 0"+j);
//设置多人PK数据
if (detailsView2 != null) {
livePushRyViewHolder.dr2_preview.removeView(detailsView2);
}
detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
textGrade2 = detailsView2.findViewById(R.id.text_grade2);
imageGrade2.setTag(String.valueOf(drPkbeanList.get(0).getId()));
textPkName2.setText(drPkbeanList.get(0).getUser_nicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
} else if (j == 1) {
L.eSw("j == 1"+j);
if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
}
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(String.valueOf(drPkbeanList.get(1).getId()));
textPkName4.setText(drPkbeanList.get(1).getUser_nicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
} else if (j == 2) {
L.eSw("j == 2"+j);
if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
}
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(String.valueOf(drPkbeanList.get(2).getId()));
textPkName4.setText(drPkbeanList.get(2).getUser_nicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
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");
}
}
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(String.valueOf(drPkbeanList.get(2).getId()));
textPkName4.setText(drPkbeanList.get(2).getUser_nicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
}
}
},1000);
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.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.google.gson.Gson;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@ -216,8 +217,7 @@ public class SocketRyClient {
EventBus.getDefault().post("endMic");
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE).setObject(map.toJavaObject(LinkMicUserBean.class)));
} else if (actions == 8) {
//踢下麥
//提下買退出
if (WordUtil.isNewZh()) {
ToastUtil.show("您已被移出多人語音連麥");
} else {
@ -302,6 +302,7 @@ public class SocketRyClient {
// break;
case Constants.SOCKET_LIVE_DRPK_RANDOM:
case Constants.SOCKET_LIVE_DRPK://多人PK
L.eSw("map"+new Gson().toJson(map));
int action3 = map.getIntValue("action");
//收到多人PK邀请
if (action3 == 1) {
@ -314,7 +315,7 @@ public class SocketRyClient {
else if (action3 == 2) {
UserBean u = new UserBean();
// u.setUserNiceName(map.getString("uname"));
u.setId(map.getString("uid"));
u.setId(map.getString("pkuid"));
L.eSw("action3 == 2:"+u.getId());
mListener.onLinkDRMicPkApplyOk(u);
} else if (action3 == 6) {//开始Pk

View File

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

View File

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

View File

@ -5276,7 +5276,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void upDataPkScore(JSONArray pkScores, int time) {
L.eSw("upDataPkScore(JSONArray pkScores, int time) {"+new Gson().toJson(pkScores));
isShowGif = true;
/*if (detailsView == null) {
if (detailsView == null) {
L.eSw("upDataPkScore(JSONArray pkScores, int time) {detailsView=null");
detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
timeTitle = detailsView.findViewById(R.id.time_title);
@ -5316,7 +5316,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
detailsView.setLayoutParams(params);
}
});
}*/
}
if (time > 0) {
mPkTimeCount2 = 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.EnterRoomNewModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.LivePkMicModel;
import com.yunbao.common.bean.LiveRoomActivityModel;
import com.yunbao.common.bean.LiveUserGiftBean;
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")){
JSONArray array = pkInfo.getJSONArray("userlist");
//判断是否是多人连麦
if(array!=null){//多人連麥
if(array.size()>0){//多人連麥
if (mLivePlayViewHolder != null) {
for (int j = 0; j < array.size(); j++) {
UserBean drPkbean = new UserBean();
JSONObject da = array.getJSONObject(j);
drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean);
if(!String.valueOf(da.getIntValue("id")).equals(String.valueOf(data.getLiveInfo().getUid()))){
drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean);
}
}
}
}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) {
@ -709,8 +715,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
for (int j = 0; j < array.size(); j++) {
UserBean drPkbean = new UserBean();
JSONObject da = array.getJSONObject(j);
drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean);
if(!String.valueOf(da.getIntValue("id")).equals(data.getLiveInfo().getUid())){
drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean);
}
}
}
@ -768,10 +776,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel));
}
}
//liveHandler.postDelayed(loadTimeoutRunnableGone, 15_000);
AppManager.runDebugCode(() -> {
// liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000);
liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000);
});
liveHandler.postDelayed(loadTimeoutRunnableGone, 15_000);
if (TextUtils.equals(data.getEnterRoomInfo().getIsconnection(), "1")) {
//通知心愿单位置换地方
EventBus.getDefault().post(new LiveAudienceEvent()

View File

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