add[声望升级-多人PK]

This commit is contained in:
Martin 2024-04-29 09:30:04 +08:00
parent 9320d6c209
commit 7d46ab8520
9 changed files with 201 additions and 315 deletions

View File

@ -154,6 +154,26 @@ public class SWAuManager extends BaseCacheManager {
}); });
} }
/**
* 与主播连麦
* @param isUp true 上麦 false 下麦
*/
public void setMicAn(boolean isUp) {
L.eSw("setMicAn-isUp:"+isUp);
ChannelMediaOptions options = new ChannelMediaOptions();
if(isUp){
options.publishCameraTrack = false; //控制是否发视频
options.publishMicrophoneTrack = true; //控制是否发音频
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; //设置身份为主播
}else{
options.publishCameraTrack = false; //控制是否发视频
options.publishMicrophoneTrack = false; //控制是否发音频
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE; //设置身份为观众
options.audienceLatencyLevel=Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY ;//设置为极速直播观众
}
mRtcEngine.updateChannelMediaOptions(options);
}
/** /**
* PK-加入对方主播直播间 * PK-加入对方主播直播间
* @param strUid * @param strUid
@ -272,4 +292,5 @@ public class SWAuManager extends BaseCacheManager {
public void setLinkUserContainer(FrameLayout linkUserContainer) { public void setLinkUserContainer(FrameLayout linkUserContainer) {
this.linkUserContainer = linkUserContainer; this.linkUserContainer = linkUserContainer;
} }
} }

View File

@ -557,6 +557,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
*/ */
@Override @Override
public void onAnchorAcceptLinkMic() { public void onAnchorAcceptLinkMic() {
L.eSw("onAnchorAcceptLinkMic(1)");
if (mLiveLinkMicPresenter != null) { if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.onAnchorAcceptLinkMic(); mLiveLinkMicPresenter.onAnchorAcceptLinkMic();
} }

View File

@ -313,6 +313,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
* 所有人收到连麦观众发过来的播流地址的回调 * 所有人收到连麦观众发过来的播流地址的回调
*/ */
public void onAudienceSendLinkMicUrl(String uid, String uname, String playUrl) { public void onAudienceSendLinkMicUrl(String uid, String uname, String playUrl) {
L.eSw("onAudienceSendLinkMicUrl,主播同意");
if (TextUtils.isEmpty(uid)) { if (TextUtils.isEmpty(uid)) {
return; return;
} }

View File

@ -522,26 +522,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
if (livePushRyViewHolder != null) { if (livePushRyViewHolder != null) {
livePushRyViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1); livePushRyViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1);
} }
HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", CommonAppConfig.getInstance().getUid()).execute(new HttpCallback() { dRjoinOtherRoom(u);
@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;
}
}
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
}
dRjoinOtherRoom(drPkbeans);
}
}
});
} }
/** /**
@ -1076,7 +1057,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
} }
dRjoinOtherRoom(drPkbeans); 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);
@ -1219,17 +1200,54 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
} }
public void setMyDrPkDetailsView(){
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
textGrade1 = detailsView1.findViewById(R.id.text_grade1);
textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
livePushRyViewHolder.dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
}
boolean isShow = false;
//多人PK接受申请画 加入副房间 //多人PK接受申请画 加入副房间
public void dRjoinOtherRoom(List<DrPkbean> drPkbeanList) { public void dRjoinOtherRoom(UserBean u) {
L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList)); if(!isShow){
if (drPkbeanList.size() == 1) { setMyDrPkDetailsView();
String uid = String.valueOf(drPkbeanList.get(0).getId()); isShow = true;
//设置多人PK数据 }
LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() { HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", u.getId()).execute(new HttpCallback() {
@Override @Override
public void onSuccess(LiveInfoModel data) { public void onSuccess(int code, String msg, String[] info) {
if(detailsView2!=null){ 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;
}
}
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
}
setDrPkUserInfoView(drPkbeans);
}
}
});
}
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); livePushRyViewHolder.dr2_preview.removeView(detailsView2);
} }
detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
@ -1238,77 +1256,13 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
textPkName2 = detailsView2.findViewById(R.id.text_pk_name2); textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
imageGrade2 = detailsView2.findViewById(R.id.image_grade2); imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
textGrade2 = detailsView2.findViewById(R.id.text_grade2); textGrade2 = detailsView2.findViewById(R.id.text_grade2);
imageGrade2.setTag(uid); imageGrade2.setTag(String.valueOf(drPkbeanList.get(0).getId()));
textPkName2.setText(data.getUserNicename()); textPkName2.setText(drPkbeanList.get(0).getUser_nicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2); livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE); detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE); linearGrade2.setVisibility(View.GONE);
} } else if (j == 1) {
if (detailsView4 != null) {
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
textGrade1 = detailsView1.findViewById(R.id.text_grade1);
textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
livePushRyViewHolder.dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
Log.e("ry", "多人接受成功" + uid);
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
} else if (drPkbeanList.size() == 2) {
String uid1 = String.valueOf(drPkbeanList.get(0).getId());
String uid2 = String.valueOf(drPkbeanList.get(1).getId());
//设置多人PK数据
LiveNetManager.get(mContext).getLiveInfo(uid1, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
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(uid1);
textPkName2.setText(data.getUserNicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
textGrade1 = detailsView1.findViewById(R.id.text_grade1);
textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
livePushRyViewHolder.dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
LiveNetManager.get(mContext).getLiveInfo(uid2, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView4!=null){
livePushRyViewHolder.dr4_preview.removeView(detailsView4); livePushRyViewHolder.dr4_preview.removeView(detailsView4);
} }
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
@ -1317,67 +1271,14 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4); textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4); imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4); textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(uid2); imageGrade4.setTag(String.valueOf(drPkbeanList.get(1).getId()));
textPkName4.setText(data.getUserNicename()); textPkName4.setText(drPkbeanList.get(1).getUser_nicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4); livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE); detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE);
L.eSw("第三个主播的名称 数据加载完成"+detailsLinearLayout4.getVisibility()); } else if (j == 2) {
L.eSw("detailsLinearLayout4.getVisibility()"+detailsLinearLayout4.getVisibility());
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
} else if (drPkbeanList.size() == 3) {
String uid1 = String.valueOf(drPkbeanList.get(0).getId());
String uid2 = String.valueOf(drPkbeanList.get(1).getId());
String uid3 = String.valueOf(drPkbeanList.get(2).getId());
//设置多人PK数据 //设置多人PK数据
LiveNetManager.get(mContext).getLiveInfo(uid1, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() { if (detailsView3 != null) {
@Override
public void onSuccess(LiveInfoModel data) {
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(uid1);
textPkName2.setText(data.getUserNicename());
livePushRyViewHolder.dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
L.eSw("detailsLinearLayout2.getVisibility()"+detailsLinearLayout2.getVisibility());
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
textGrade1 = detailsView1.findViewById(R.id.text_grade1);
textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
livePushRyViewHolder.dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
LiveNetManager.get(mContext).getLiveInfo(uid2, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView2!=null){
livePushRyViewHolder.dr3_preview.removeView(detailsView3); livePushRyViewHolder.dr3_preview.removeView(detailsView3);
} }
detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
@ -1386,24 +1287,13 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
textPkName3 = detailsView3.findViewById(R.id.text_pk_name3); textPkName3 = detailsView3.findViewById(R.id.text_pk_name3);
imageGrade3 = detailsView3.findViewById(R.id.image_grade3); imageGrade3 = detailsView3.findViewById(R.id.image_grade3);
textGrade3 = detailsView3.findViewById(R.id.text_grade3); textGrade3 = detailsView3.findViewById(R.id.text_grade3);
imageGrade3.setTag(uid2); imageGrade3.setTag(String.valueOf(drPkbeanList.get(1).getId()));
textPkName3.setText(data.getUserNicename()); textPkName3.setText(drPkbeanList.get(1).getUser_nicename());
livePushRyViewHolder.dr3_preview.addView(detailsView3); livePushRyViewHolder.dr3_preview.addView(detailsView3);
detailsLinearLayout3.setVisibility(View.VISIBLE); detailsLinearLayout3.setVisibility(View.VISIBLE);
linearGrade3.setVisibility(View.GONE); linearGrade3.setVisibility(View.GONE);
L.eSw("detailsLinearLayout3.getVisibility()"+detailsLinearLayout3.getVisibility());
L.eSw("第三个主播的名称 数据加载完成");
}
@Override if (detailsView4 != null) {
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
LiveNetManager.get(mContext).getLiveInfo(uid3, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
if(detailsView4!=null){
livePushRyViewHolder.dr4_preview.removeView(detailsView4); livePushRyViewHolder.dr4_preview.removeView(detailsView4);
} }
detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
@ -1412,26 +1302,19 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
textPkName4 = detailsView4.findViewById(R.id.text_pk_name4); textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
imageGrade4 = detailsView4.findViewById(R.id.image_grade4); imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
textGrade4 = detailsView4.findViewById(R.id.text_grade4); textGrade4 = detailsView4.findViewById(R.id.text_grade4);
imageGrade4.setTag(uid3); imageGrade4.setTag(String.valueOf(drPkbeanList.get(2).getId()));
textPkName4.setText(data.getUserNicename()); textPkName4.setText(drPkbeanList.get(2).getUser_nicename());
livePushRyViewHolder.dr4_preview.addView(detailsView4); livePushRyViewHolder.dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE); detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE);
L.eSw("detailsLinearLayout4.getVisibility()"+detailsLinearLayout4.getVisibility());
L.eSw("第四个主播的名称 数据加载完成");
}
@Override
public void onError(String error) {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
}
});
Log.e("ry", "多人接受成功" + mApplyUid);
ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success"); ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
} }
} }
L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList));
}
/** /**
* 多人PK PK主播发过来的已经接受 * 多人PK PK主播发过来的已经接受
@ -1448,7 +1331,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
* @group 房间管理 * @group 房间管理
*/ */
RCRTCEngine.getInstance().joinOtherRoom(u, new IRCRTCResultDataCallback<RCRTCOtherRoom>() { /*RCRTCEngine.getInstance().joinOtherRoom(u, new IRCRTCResultDataCallback<RCRTCOtherRoom>() {
@Override @Override
public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) { public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) {
rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener); rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener);
@ -1622,7 +1505,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void onFailed(RTCErrorCode rtcErrorCode) { public void onFailed(RTCErrorCode rtcErrorCode) {
Log.i("ry", "加入其他房间失败 " + rtcErrorCode.getReason()); Log.i("ry", "加入其他房间失败 " + rtcErrorCode.getReason());
} }
}); });*/
} }

View File

@ -196,6 +196,7 @@ public class SocketRyClient {
//用户连麦 //用户连麦
case Constants.LIAN_MAI: case Constants.LIAN_MAI:
int actions = map.getIntValue("action"); int actions = map.getIntValue("action");
L.eSw("用户连麦:actions"+actions);
//主播邀请用户连麦消息 //主播邀请用户连麦消息
if (actions == 1) { if (actions == 1) {
EventBus.getDefault().post("inviteMic"); EventBus.getDefault().post("inviteMic");
@ -215,6 +216,8 @@ 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 {
@ -449,7 +452,7 @@ public class SocketRyClient {
case Constants.SOCKET_BUY_GUARD://购买守护 case Constants.SOCKET_BUY_GUARD://购买守护
buyGuardInSameRoom(map); buyGuardInSameRoom(map);
break; break;
case Constants.SOCKET_LINK_MIC://连麦 case Constants.SOCKET_LINK_MIC://连麦-old
processLinkMic(map); processLinkMic(map);
break; break;
case Constants.SOCKET_LINK_MIC_ANCHOR://主播连麦 case Constants.SOCKET_LINK_MIC_ANCHOR://主播连麦

View File

@ -280,6 +280,29 @@ boolean isAdd = true;
swAuManager.updateMyChannelView((FrameLayout) ry_view, Integer.parseInt(liveUid)); swAuManager.updateMyChannelView((FrameLayout) ry_view, Integer.parseInt(liveUid));
} }
/**
* 将用户设置成主播,与主播连麦
*/
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);
}
}
});
}
private void endLiveMic() {
L.eSw("endLiveMic");
swAuManager.setMicAn(false);
}
@Override @Override
public void hideCover() { public void hideCover() {
// if (mCover != null) { // if (mCover != null) {
@ -767,8 +790,10 @@ boolean isAdd = true;
LiveAudienceActivity.mProcessResultUtil.requestPermissions(permissions, new Runnable() { LiveAudienceActivity.mProcessResultUtil.requestPermissions(permissions, new Runnable() {
@Override @Override
public void run() { public void run() {
UsertoRY(); //UsertoRY();
//将自己设置成给主播,和主播连麦
L.eSw("将自己设置成给主播,和主播连麦");
joinLiveMic();
} }
}); });
} }
@ -776,75 +801,10 @@ boolean isAdd = true;
builder.build().show(); builder.build().show();
} else if ("endMic".equals(str)) { } else if ("endMic".equals(str)) {
if (rcrtcRoom != null) { L.eSw("endMic.equals(str))"+str);
// 开始切换为观众身份 // 开始切换为观众身份
RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() { //声网-将用户身份切换只观众
endLiveMic();
/**
* 当切换失败且SDK处于无法回退状态时回调该角色已经无法使用当前角色继续进行音视频
* SDK内部会退出房间并清理所有资源该用户只能重新加入房间才能继续音视频
*/
@Override
public void onKicked() {
}
@Override
public void onSuccess() {
Log.e("ry", "下麦成功");
// 该用户切换为观众成功可以以观众身份进行音视频
//退出rtc播放
leaveRoom();
}
/**
* 当切换失败且不影响当前角色继续音视频时回调
* @param errorCode 失败错误码
*/
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "下麦失败" + errorCode);
leaveRoom();
}
private void leaveRoom() {
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onSuccess() {
userJoinLinkMic = false;
Log.e("ry", "退出多人房间成功");
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
if (WordUtil.isNewZh()) {
ToastUtil.show("已成功退出語音連麥");
} else {
ToastUtil.show("You have successfully exited the voice connection");
}
ry_view.removeAllViews();
ry_view.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
onPrepared();
rcrtcRoom = null;
MicStatusManager.getInstance().clear();
resumePlay();
if (onMicCallback != null) {
onMicCallback.onMikUpdate();
}
}
});
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", errorCode + "退出多人房间成功");
userJoinLinkMic = false;
}
});
}
});
}
} else if ("Debug".equals(str)) { } else if ("Debug".equals(str)) {
if (EasyFloat.isShow("Debug")) { if (EasyFloat.isShow("Debug")) {
EasyFloat.dismiss("Debug"); EasyFloat.dismiss("Debug");

View File

@ -605,6 +605,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
private String drpkUid3 = ""; private String drpkUid3 = "";
public int setAnDrPkRtc(String uid, int position) { public int setAnDrPkRtc(String uid, int position) {
L.eSw("setAnDrPkRtc uid"+uid+" position"+position);
FrameLayout frameLayout = null; FrameLayout frameLayout = null;
int temp= -1; int temp= -1;
if (swManager != null && !StringUtil.isEmpty(uid)) { if (swManager != null && !StringUtil.isEmpty(uid)) {
@ -630,7 +631,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
break; break;
case 4: case 4:
dr3_preview.setVisibility(View.VISIBLE); dr3_preview.setVisibility(View.VISIBLE);
//先退出这个主播的直播间在进入该直播间视图问题暂时找不到解决方案 //先退出这个主播的直播间在进入该直播间视图问题暂时這樣處理
swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drpkUid3); swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drpkUid3);
swManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3)); swManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3));

View File

@ -51,6 +51,7 @@ import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.target.Target;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup; import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView; import com.makeramen.roundedimageview.RoundedImageView;
import com.ms.banner.Banner; import com.ms.banner.Banner;
@ -124,6 +125,7 @@ import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter; import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
@ -5272,8 +5274,10 @@ 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));
isShowGif = true; 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); 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);
textTime = detailsView.findViewById(R.id.text_time); textTime = detailsView.findViewById(R.id.text_time);
@ -5293,6 +5297,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
imageGrade2 = detailsView.findViewById(R.id.image_grade2); imageGrade2 = detailsView.findViewById(R.id.image_grade2);
imageGrade3 = detailsView.findViewById(R.id.image_grade3); imageGrade3 = detailsView.findViewById(R.id.image_grade3);
imageGrade4 = detailsView.findViewById(R.id.image_grade4); imageGrade4 = detailsView.findViewById(R.id.image_grade4);
//暂时关闭
linearGrade1.setVisibility(View.GONE); linearGrade1.setVisibility(View.GONE);
linearGrade2.setVisibility(View.GONE); linearGrade2.setVisibility(View.GONE);
linearGrade3.setVisibility(View.GONE); linearGrade3.setVisibility(View.GONE);
@ -5311,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

@ -641,11 +641,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");
//mLivePlayViewHolder.setViewUP(1); //判断是否是多人连麦
if(array!=null){//多人連麥
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);
}
}
}else{//单人连麦
mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid()); mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid());
} }
}
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = false; mLiveRoomViewHolder.pkHandler = false;
} }
@ -1478,7 +1489,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override @Override
public void onAudienceApplyLinkMic(UserBean u) { public void onAudienceApplyLinkMic(UserBean u) {
L.eSw("onAudienceApplyLinkMic(2)");
} }
@Override @Override
@ -2162,7 +2173,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* @param time * @param time
*/ */
public void upDataPkScore(JSONArray pkScores, int time) { public void upDataPkScore(JSONArray pkScores, int time) {
L.eSw("upDataPkScore"+time);
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
String liveId = mLiveBean.getUid(); String liveId = mLiveBean.getUid();
JSONObject liveModel = null; JSONObject liveModel = null;