add[声望升级-多人PK]

This commit is contained in:
Martin 2024-05-06 08:51:18 +08:00
parent b4adf4c77c
commit d78055cdd9
12 changed files with 337 additions and 52 deletions

View File

@ -192,7 +192,7 @@ public class SWAuManager extends BaseCacheManager {
// 创建 ChannelMediaOptions 对象并进行配置
ChannelMediaOptions options = new ChannelMediaOptions();
// 根据场景将用户角色设置为 AUDIENCE (观众)
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
options.autoSubscribeVideo = true;
options.autoSubscribeAudio = true;
options.publishMicrophoneTrack = false;
@ -213,7 +213,7 @@ public class SWAuManager 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);
}
});
@ -244,6 +244,13 @@ public class SWAuManager extends BaseCacheManager {
mRtcEngine.leaveChannelEx(rtcConnection);
}
/**
* 退出所有的直播间
*/
public void exitChannelAll(){
mRtcEngine.leaveChannel();
}
public static String getChannelName(String liveUid) {
if(liveUid.contains("g")){
return liveUid;

View File

@ -300,7 +300,7 @@ public class SWManager extends BaseCacheManager {
// 创建 ChannelMediaOptions 对象并进行配置
ChannelMediaOptions options = new ChannelMediaOptions();
// 根据场景将用户角色设置为 AUDIENCE (观众)
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
options.autoSubscribeVideo = true;
options.autoSubscribeAudio = true;
options.publishMicrophoneTrack = false;

View File

@ -997,6 +997,11 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
}
}
@Override
public void onLinkDRMicPKToUser(UserBean u) {
}
//多人PK接受
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {

View File

@ -565,11 +565,16 @@ public class LiveAudienceActivity extends LiveActivity {
}
@Override
public void onLinkDRMicPKToUser(UserBean u) {
//manager.getmLivePlayViewHolder().setDrMicInfo(u);
}
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
L.eSw("onLinkDRMicPkApplyOk:"+u.getId());
//多人PK 连麦
manager.getmLivePlayViewHolder().setDrMicInfo(u);
//manager.getmLivePlayViewHolder().setDrMicInfo(u);
}
@Override

View File

@ -1429,6 +1429,11 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
}
@Override
public void onLinkDRMicPKToUser(UserBean u) {
}
//多人PK接受
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {

View File

@ -512,7 +512,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
showDRApplyDialog(u);
}
/**
* 主播与主播PK 主播收到其他主播发过来的多人PK申请同意了的回调
*/
@ -522,6 +521,37 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
if (livePushRyViewHolder != null) {
livePushRyViewHolder.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());
msg1.create();
String targetId = "g" + CommonAppConfig.getInstance().getUid();
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) {
}
@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);
}
});
dRjoinOtherRoom(u);
}
@ -600,7 +630,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/*---------------------------------------------------------------- */
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 2) //回复PK申请 2
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("uid", CommonAppConfig.getInstance().getUid()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", bean.getId()).param("uid", CommonAppConfig.getInstance().getUid()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create();
System.out.println("PK回执 = " + msg1.toString());
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
@ -817,6 +847,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void run() {
if (btn_close != null) {
btn_close.setVisibility(View.GONE);
livePushRyViewHolder.timeTitle.setVisibility(View.GONE);
}
}
});
@ -1029,28 +1060,20 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
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);
}
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("type", 2)
.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;
String targetId = String.valueOf(drPkbeans.get(i).getId());
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(targetId, conversationType, messageContent);
@ -1062,9 +1085,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
@Override
@ -1075,8 +1095,76 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
});
//
int index = livePushRyViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1);
L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 " + u.getUserNiceName());
L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 1 " + u.getUserNiceName());
L.eSw("發送action = 2");
}
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("type", 3)
.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) {
}
@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(!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("type", 3)
.param("uid", drPkbeans.get(i).getId())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create();
String targetId = "g" + CommonAppConfig.getInstance().getUid();
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) {
}
@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);
}
});
}
}
dRjoinOtherRoom(u);
@ -1226,7 +1314,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
}
public void setMyDrPkDetailsView(){
public void setMyDrPkDetailsView() {
if (detailsView1 != null) {
livePushRyViewHolder.dr1_preview.removeView(detailsView1);
}
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);
@ -1239,14 +1330,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
linearGrade1.setVisibility(View.GONE);
}
boolean isShow = false;
//多人PK接受申请画 加入副房间
public void dRjoinOtherRoom(UserBean u) {
if(!isShow){
setMyDrPkDetailsView();
isShow = true;
}
setMyDrPkDetailsView();
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) {
@ -1269,13 +1356,13 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
private void setDrPkUserInfoView(List<DrPkbean> drPkbeanList) {
L.eSw("setDrPkUserInfoView"+new Gson().toJson(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) {
L.eSw("j == 0"+j);
L.eSw("j == 0" + j);
//设置多人PK数据
if (detailsView2 != null) {
livePushRyViewHolder.dr2_preview.removeView(detailsView2);
@ -1292,7 +1379,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
} else if (j == 1) {
L.eSw("j == 1"+j);
L.eSw("j == 1" + j);
if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
}
@ -1308,7 +1395,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
} else if (j == 2) {
L.eSw("j == 2"+j);
L.eSw("j == 2" + j);
if (detailsView4 != null) {
livePushRyViewHolder.dr4_preview.removeView(detailsView4);
@ -1346,7 +1433,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
}
}
},1000);
}, 2000);
L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList));
}

View File

@ -242,6 +242,8 @@ public interface SocketMessageListener {
//多人PK
void onLinkDRMicPkApply(UserBean u);
void onLinkDRMicPKToUser(UserBean u);
//接受多人PK
void onLinkDRMicPkApplyOk(UserBean u);

View File

@ -3,6 +3,7 @@ package com.yunbao.live.socket;
import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
import static com.blankj.utilcode.util.ViewUtils.runOnUiThread;
import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER;
import static com.yunbao.common.Constants.isAnchor;
import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
@ -54,6 +55,7 @@ import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.manager.RandomPkManager;
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;
import com.yunbao.live.R;
@ -317,6 +319,7 @@ public class SocketRyClient {
// u.setUserNiceName(map.getString("uname"));
u.setId(map.getString("pkuid"));
L.eSw("action3 == 2:"+u.getId());
L.eSw("收到对方同意多人PK邀请");
mListener.onLinkDRMicPkApplyOk(u);
} else if (action3 == 6) {//开始Pk
if (LiveRoomViewHolder.mHandler != null) {
@ -342,9 +345,21 @@ public class SocketRyClient {
}
//創建了多人房間
} else if (action3 == 3) {
L.eSw("創建了多人房間action3 == 3");
/* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
}*/
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())){
return;
}
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) {

View File

@ -14,6 +14,7 @@ import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@ -75,7 +76,6 @@ import cn.rongcloud.rtc.api.RCRTCRoomConfig;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleDataCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCVideoInputFrameListener;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
@ -141,6 +141,14 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private FrameLayout dr3_preview;
private FrameLayout dr4_preview;
private View detailsView1, detailsView2, detailsView3, detailsView4;
private LinearLayout detailsLinearLayout1, detailsLinearLayout2, detailsLinearLayout3, detailsLinearLayout4;
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
private TextView textPkName1, textPkName2, textPkName3, textPkName4;
private TextView textGrade1, textGrade2, textGrade3, textGrade4;
private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
public int getLandscape() {
return landscape;
}
@ -227,12 +235,14 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void setDrMicInfo(UserBean u) {
L.eSw("setDrMicInfo:-----------------" + u.getId());
isAdd = true;
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())) {
if (u.getId().equals(drMicUserList.get(i).getId())||u.getId().equals(liveUid)) {
isAdd = false;
}
}
L.eSw("setDrMicInfo:---------------isAdd--"+isAdd );
//加载多人PK(连麦)主播视图
if (isAdd) {
dr_pk_view.setVisibility(View.VISIBLE);
@ -258,14 +268,142 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
swAuManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drMicUserList.get(2).getId(), SWAuManager.getChannelName(drMicUserList.get(2).getId()));
}
}
HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", liveUid).execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (info.length > 0) {
JSONObject obj = JSONObject.parseObject(info[0]);
List<DrPkbean> drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
int removeIndex = -1;
for (int i = 0; i < drPkbeans.size(); i++) {
if (liveUid.equals(String.valueOf(drPkbeans.get(i).getId()))) {
removeIndex = i;
}
}
if (removeIndex != -1) {
drPkbeans.remove(removeIndex);
}
setDrPkView(drPkbeans);
}
}
});
}
public void claerDrPkInfoView() {
if (detailsView1 != null) {
dr1_preview.removeView(detailsView1);
}
if (detailsView2 != null) {
dr2_preview.removeView(detailsView2);
}
if (detailsView3 != null) {
dr3_preview.removeView(detailsView3);
}
if (detailsView4 != null) {
dr4_preview.removeView(detailsView4);
}
}
public void setDrPkView(List<DrPkbean> drPkbeanList){
if (detailsView1 != null) {
dr1_preview.removeView(detailsView1);
}
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()));
dr1_preview.addView(detailsView1);
detailsLinearLayout1.setVisibility(View.VISIBLE);
linearGrade1.setVisibility(View.GONE);
new Handler().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) {
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());
dr2_preview.addView(detailsView2);
detailsLinearLayout2.setVisibility(View.VISIBLE);
linearGrade2.setVisibility(View.GONE);
} else if (j == 1) {
L.eSw("j == 1" + j);
if (detailsView4 != null) {
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());
dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
} else if (j == 2) {
L.eSw("j == 2" + j);
if (detailsView4 != null) {
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());
dr4_preview.addView(detailsView4);
detailsLinearLayout4.setVisibility(View.VISIBLE);
linearGrade4.setVisibility(View.GONE);
if (detailsView3 != null) {
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());
dr3_preview.addView(detailsView3);
detailsLinearLayout3.setVisibility(View.VISIBLE);
linearGrade3.setVisibility(View.GONE);
}
}
}
}, 2000);
}
/**
* 退出单人pk
*
* @param pkUid
*/
public void endpk(String pkUid) {
L.eSw("endpk "+pkUid);
mPkContainer.setVisibility(View.GONE);
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid));
swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid));
@ -290,6 +428,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
for (int i = 0; i < drMicUserList.size(); i++) {
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drMicUserList.get(i).getId());
}
drMicUserList =new ArrayList<>();
//將當前主播畫面放大
swAuManager.updateMyChannelView((FrameLayout) ry_view, Integer.parseInt(liveUid));
}
@ -517,6 +656,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mStarted = false;
Bus.getOff(this);
EventBus.getDefault().unregister(this);
swAuManager.exitChannelAll();
L.e(TAG, "release------->");
}
@ -1276,7 +1416,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL_480] + videoFps[0] + ".flv");
}
}
private class ExoPlayerListener implements Player.Listener {
String TAG = "播放流";

View File

@ -589,7 +589,10 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
public void setAnPkRtc(UserBean u) {
if (swManager != null && u != null) {
//将多人pk画面屏蔽
dr_pk_view.setVisibility(View.GONE);
L.eSw("设置对方主播的视图setAnPkRtc" + u);
pkUid1 = u.getId();
mPkContainer.setVisibility(View.VISIBLE);
//将自己的渲染视图设置到 leftContainer
swManager.updateMyChannelView((FrameLayout) mLeftContainer);
@ -608,7 +611,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
private String drpkUid3 = "";
public int setAnDrPkRtc(String uid, int position) {
L.eSw("setAnDrPkRtc uid"+uid+" position"+position);
FrameLayout frameLayout = null;
int temp= -1;
if (swManager != null && !StringUtil.isEmpty(uid)) {
L.eSw("设置对方主播的视图 setAnDrPkRtc" + uid + "position:" + position);
@ -622,13 +624,17 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
}
switch (temp) {
case 2:
frameLayout = dr2_preview;
swManager.joinChannelDrEx(dr2_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid));
swManager.updateMyChannelView(dr1_preview);
mBigContainer.removeAllViews();
dr3_preview.setVisibility(View.GONE);
dr4_preview.setVisibility(View.GONE);
break;
case 3:
drpkUid3 = uid;
frameLayout = dr4_preview;
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:
@ -637,15 +643,9 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drpkUid3);
swManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3));
frameLayout = dr4_preview;
swManager.joinChannelDrEx(dr4_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid));
break;
}
if (temp == 2) {
swManager.updateMyChannelView(dr1_preview);
mBigContainer.removeAllViews();
}
swManager.joinChannelDrEx(frameLayout,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid));
dr_pk_view.setVisibility(View.VISIBLE);
currentPosition = temp;
}

View File

@ -647,14 +647,20 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//判断是否是多人连麦
if(array.size()>0){//多人連麥
if (mLivePlayViewHolder != null) {
List<DrPkbean> drPkbeans = new ArrayList<>();
for (int j = 0; j < array.size(); j++) {
UserBean drPkbean = new UserBean();
DrPkbean drPkbean1 = new DrPkbean();
JSONObject da = array.getJSONObject(j);
if(!String.valueOf(da.getIntValue("id")).equals(String.valueOf(data.getLiveInfo().getUid()))){
drPkbean.setId(String.valueOf(da.getIntValue("id")));
drPkbean1.setId(da.getIntValue("id"));
drPkbean1.setUser_nicename(da.getString("user_nicename"));
drPkbeans.add(drPkbean1);
mLivePlayViewHolder.setDrMicInfo(drPkbean);
}
}
mLivePlayViewHolder.setDrPkView(drPkbeans);
}
}else{//单人连麦
LivePkMicModel connection_info = data.getEnterRoomInfo().getConnectionInfo();
@ -712,14 +718,20 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
if (mLivePlayViewHolder != null) {
JSONArray array = pkInfo.getJSONArray("userlist");
List<DrPkbean> drPkbeans = new ArrayList<>();
for (int j = 0; j < array.size(); j++) {
UserBean drPkbean = new UserBean();
UserBean userBean = new UserBean();
DrPkbean drPkbean = new DrPkbean();
JSONObject da = array.getJSONObject(j);
if(!String.valueOf(da.getIntValue("id")).equals(data.getLiveInfo().getUid())){
drPkbean.setId(String.valueOf(da.getIntValue("id")));
mLivePlayViewHolder.setDrMicInfo(drPkbean);
userBean.setId(String.valueOf(da.getIntValue("id")));
drPkbean.setId(da.getIntValue("id"));
drPkbean.setUser_nicename(da.getString("user_nicename"));
drPkbeans.add(drPkbean);
mLivePlayViewHolder.setDrMicInfo(userBean);
}
}
mLivePlayViewHolder.setDrPkView(drPkbeans);
}
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
@ -1585,10 +1597,17 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
@Override
public void onLinkDRMicPKToUser(UserBean u) {
L.eSw("onLinkDRMicPKToUser(UserBean u)PortraitLiveManager");
mLivePlayViewHolder.setDrMicInfo(u);
}
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
L.eSw("onLinkDRMicPkApplyOk(UserBean u)PortraitLiveManager");
mLivePlayViewHolder.setDrMicInfo(u);
//mLivePlayViewHolder.setDrMicInfo(u);
}
@ -2197,6 +2216,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
pkScores.remove(index);
pkScores.add(0, liveModel);
mLiveRoomViewHolder.upDataPkScore(pkScores, time);
mLivePlayViewHolder.claerDrPkInfoView();
setPkStatus(true);
}
//通知心愿单位置换地方

View File

@ -69,7 +69,7 @@
<LinearLayout
android:id="@+id/dr_pk_view"
android:layout_width="match_parent"
android:layout_height="270dp"
android:layout_height="290dp"
android:layout_marginTop="130dp"
android:orientation="horizontal"
android:visibility="gone">