list = JSON.parseArray(obj.getString("userlist"), DrPkbean.class);
for (int ii = 0, size = list.size(); ii < size; ii++) {
@@ -786,31 +766,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
}
for (int i = 0, size = list.size(); i < size; i++) {
if (!String.valueOf(list.get(i).getId()).equals(CommonAppConfig.getInstance().getUid())) {
- Log.i("tsss11", list.size() + "啊啊啊" + list.get(i).getId() + "");
- mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
- mTRTCParams1 = new TRTCCloudDef.TRTCParams();
- mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID;
- mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk";
- mTRTCParams1.roomId = list.get(i).getId();
- mTRTCParams1.userSig = GenerateTestUserSig.genTestUserSig(mTRTCParams1.userId);
- mTRTCParams1.role = TRTCCloudDef.TRTCRoleAudience;
- if (i == 1) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr1_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- } else if (i == 2) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr2_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- } else if (i == 3) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr3_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- } else if (i == 4) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr4_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- }
Log.i("ssxcs", list.get(i).getId() + "");
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_DRPK)
@@ -842,8 +797,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
}
});
-
-
}
}
});
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java
index cd382ddeb..41a6a268a 100644
--- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java
@@ -1243,99 +1243,90 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
agree = false;
}
boolean finalAgree = agree;
- IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, agree, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- if (finalAgree == true) {
- HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
- .params("uid", CommonAppConfig.getInstance().getUid())
- .params("roomid", u.getId())
- .execute(new HttpCallback() {
+ if (finalAgree) {
+ HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
+ .params("uid", CommonAppConfig.getInstance().getUid())
+ .params("roomid", u.getId())
+ .execute(new HttpCallback() {
+
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ Log.i("多人PK", "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
+
+ final SocketSendBean msg1 = new SocketSendBean()
+ .param("_method_", SOCKET_LIVE_DRPK)
+ .param("action", 10)
+ .param("uid", CommonAppConfig.getInstance().getUid());
+ 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(int code, String msg, String[] info) {
- Log.i("多人PK", "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
-
- final SocketSendBean msg1 = new SocketSendBean()
- .param("_method_", SOCKET_LIVE_DRPK)
- .param("action", 10)
- .param("uid", CommonAppConfig.getInstance().getUid());
- 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) {
- Log.e("ry", "发送成功");
- 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("ry", "发送失敗");
- }
- });
- if (info.length == 0) {
- return;
- }
- JSONObject obj = JSONObject.parseObject(info[0]);
- JSONArray users = obj.getJSONArray("userlist");
-
- //添加水印
-// RCRTCRect rect = new RCRTCRect(0.5f, 0.5f, 0.2f);
-// RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(fromText(50, mNameText), rect);
- dRjoinOtherRoom(u.getId(), 1);
-
- for (int i = 0; i < users.size(); i++) {
- JSONObject user = users.getJSONObject(i);
- Log.e("ry", mApplyUid + "VS" + user.getString("id") + "列表");
- if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) {
- if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) {
- /**
- * 向指定用户发送跨房间连麦请求
- *
- * 1: inviterAutoMix为true时:
- *
- * 1.1:如果被邀请方在加入邀请方房间之前发布了资源,当被邀请方加入邀请者房间成功后,服务器会把被邀请方流资源合并到邀请方视图 ·(默认仅悬浮布局合流)上。
- *
- * 1.2:如果被邀请方在加入邀请方房间之前没有发布过资源,将会在被邀请方发布资源成功后,服务器会把被邀请方流资源合并到邀请方视图(默认仅悬浮布局合流)上。
- *
- * 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。
- *
- */
- IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
- });
- }
- }
+ public void onSuccess(io.rong.imlib.model.Message message) {
+ Log.e("ry", "发送成功");
+ if (SocketRyClient.mSocketHandler != null) {
+ SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
- });
- }
- }
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- ToastUtil.show("接受失败");
- }
- });
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("ry", "发送失敗");
+ }
+ });
+ if (info.length == 0) {
+ return;
+ }
+ JSONObject obj = JSONObject.parseObject(info[0]);
+ JSONArray users = obj.getJSONArray("userlist");
+
+ //添加水印
+// RCRTCRect rect = new RCRTCRect(0.5f, 0.5f, 0.2f);
+// RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(fromText(50, mNameText), rect);
+ dRjoinOtherRoom(u.getId(), 1);
+ livePushRyViewHolder.setAnDrPkRtc(u.getId());
+
+ for (int i = 0; i < users.size(); i++) {
+ JSONObject user = users.getJSONObject(i);
+ Log.e("ry", mApplyUid + "VS" + user.getString("id") + "列表");
+ if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) {
+ if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) {
+ /**
+ * 向指定用户发送跨房间连麦请求
+ *
+ * 1: inviterAutoMix为true时:
+ *
+ * 1.1:如果被邀请方在加入邀请方房间之前发布了资源,当被邀请方加入邀请者房间成功后,服务器会把被邀请方流资源合并到邀请方视图 ·(默认仅悬浮布局合流)上。
+ *
+ * 1.2:如果被邀请方在加入邀请方房间之前没有发布过资源,将会在被邀请方发布资源成功后,服务器会把被邀请方流资源合并到邀请方视图(默认仅悬浮布局合流)上。
+ *
+ * 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。
+ *
+ */
+ IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+
+ }
+ });
+ }
+ }
+ }
+ }
+ });
+ }
} else {
ToastUtil.show(msg);
}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
index c76564e77..f5c30219f 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
@@ -309,10 +309,10 @@ public class SocketRyClient {
}
//收到对方同意多人PK邀请
else if (action3 == 2) {
-// UserBean u = new UserBean();
-//// u.setUserNiceName(map.getString("uname"));
-// u.setId(map.getString("uid"));
-// mListener.onLinkDRMicPkApplyOk(u);
+ UserBean u = new UserBean();
+// u.setUserNiceName(map.getString("uname"));
+ u.setId(map.getString("uid"));
+ mListener.onLinkDRMicPkApplyOk(u);
} else if (action3 == 6) {//开始Pk
if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
@@ -1307,7 +1307,7 @@ public class SocketRyClient {
break;
case 9://pk结束的回调
mListener.onLinkMicPkEnd(map.getString("win_uid"));
- EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_END));
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_END).setObject(map.getString("uid")));
if (livePushRyViewHolder != null) {
livePushRyViewHolder.onLinkMicAnchorClose();
}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
index df57ab96b..d9f6c0793 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
@@ -96,7 +96,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private ViewGroup mSmallContainer;
private ViewGroup mLeftContainer;
private ViewGroup mRightContainer;
- private RelativeLayout mPkContainer;
+ private ViewGroup mPkContainer;
public StyledPlayerView mVideoView;
private FrameLayout playFrameLayout;
@@ -158,7 +158,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
- mPkContainer = (RelativeLayout) findViewById(R.id.pk_container);
+ mPkContainer = (FrameLayout) findViewById(R.id.pk_container);
mVideoView = (StyledPlayerView) findViewById(R.id.video_view);
ry_view = (FrameLayout) findViewById(R.id.ry_view);
leave = (ImageView) findViewById(R.id.leave);
@@ -179,15 +179,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void initSwEngine(String liveUid) {
this.liveUid = liveUid;
+ //初始化声网SDK
swAuManager = SWAuManager.get();
swAuManager.setAudienceContainer(ry_view);
swAuManager.initRtcEngine((Activity) mContext);
swAuManager.setupRemoteVideo(Integer.parseInt(liveUid));
+ //进入主播房间
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(liveUid));
-
- //测试-模拟PK场景,加入第二个主播视图
- swAuManager.setPkContainer1(playFrameLayout1);
- swAuManager.joinExRoomEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(liveUid));
}
@Override
@@ -232,11 +230,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ /* RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params1.topMargin = 0;
ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
+ ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params2.topMargin = 0;
@@ -252,12 +250,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight;
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
+ ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120);
@@ -373,12 +371,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ /* RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
+ ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120);
@@ -422,11 +420,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight;
params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
- ry_view.requestLayout();
+ ry_view.requestLayout();*/
isPk = true;
}
@@ -453,11 +451,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = height;
params1.topMargin = 0;
ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
+ ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height;
params2.topMargin = 0;
@@ -475,7 +473,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = height;
params1.topMargin = 0;
params1.addRule(RelativeLayout.ALIGN_TOP);
@@ -483,7 +481,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
}
ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
+ ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height;
params2.topMargin = DpUtil.dp2px(120);
@@ -668,37 +666,24 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
confirm = "accept";
cancel = "cancel";
}
- DialogUitl.Builder builder = new DialogUitl.Builder(mContext)
- .setContent(content)
- .setTitle(mLiveBean.getUserNiceName())
- .setConfirmString(confirm)
- .setCancelString(cancel)
- .setView(R.layout.dialog_live_mic_invite)
- .setClickCallback(new DialogUitl.SimpleCallback() {
+ DialogUitl.Builder builder = new DialogUitl.Builder(mContext).setContent(content).setTitle(mLiveBean.getUserNiceName()).setConfirmString(confirm).setCancelString(cancel).setView(R.layout.dialog_live_mic_invite).setClickCallback(new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ String[] permissions;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ permissions = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.RECORD_AUDIO};
+ } else {
+ permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO};
+ }
+ LiveAudienceActivity.mProcessResultUtil.requestPermissions(permissions, new Runnable() {
@Override
- public void onConfirmClick(Dialog dialog, String content) {
- String[] permissions;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
- permissions = new String[]{
- Manifest.permission.READ_MEDIA_IMAGES,
- Manifest.permission.RECORD_AUDIO
- };
- } else {
- permissions = new String[]{
- Manifest.permission.READ_EXTERNAL_STORAGE,
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- Manifest.permission.RECORD_AUDIO
- };
- }
- LiveAudienceActivity.mProcessResultUtil.requestPermissions(permissions, new Runnable() {
- @Override
- public void run() {
- UsertoRY();
+ public void run() {
+ UsertoRY();
- }
- });
}
});
+ }
+ });
builder.build().show();
} else if ("endMic".equals(str)) {
@@ -776,11 +761,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
EasyFloat.dismiss("Debug");
return;
}
- EasyFloat.with(mContext)
- .setDragEnable(true)
- .setTag("Debug")
- .setLayout(debugView)
- .show();
+ EasyFloat.with(mContext).setDragEnable(true).setTag("Debug").setLayout(debugView).show();
}
}
@@ -798,79 +779,71 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
break;
}
- LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext,
- IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR),
- ban,
- true);
- new XPopup.Builder(mContext)
- .setPopupCallback(new XPopupCallback() {
- @Override
- public void onCreated(BasePopupView popupView) {
+ LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR), ban, true);
+ new XPopup.Builder(mContext).setPopupCallback(new XPopupCallback() {
+ @Override
+ public void onCreated(BasePopupView popupView) {
- }
+ }
- @Override
- public void beforeShow(BasePopupView popupView) {
+ @Override
+ public void beforeShow(BasePopupView popupView) {
- }
+ }
- @Override
- public void onShow(BasePopupView popupView) {
+ @Override
+ public void onShow(BasePopupView popupView) {
- }
+ }
- @Override
- public void onDismiss(BasePopupView popupView) {
- int selectClarity = liveClarityCustomPopup.getSelectClarity();
- if (selectClarity == PLAY_MODEL || selectClarity == IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR))
- return;
- if (selectClarity == PLAY_MODEL_ANCHOR) {
- switchStream(srcUrl, PLAY_MODEL_DEF);
- setAudiencePlayModel(selectClarity);
- } else {
- switchStream(srcUrl, selectClarity);
- }
- IMLoginManager.get(mContext).put(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, selectClarity);
- showToast();
- }
+ @Override
+ public void onDismiss(BasePopupView popupView) {
+ int selectClarity = liveClarityCustomPopup.getSelectClarity();
+ if (selectClarity == PLAY_MODEL || selectClarity == IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR))
+ return;
+ if (selectClarity == PLAY_MODEL_ANCHOR) {
+ switchStream(srcUrl, PLAY_MODEL_DEF);
+ setAudiencePlayModel(selectClarity);
+ } else {
+ switchStream(srcUrl, selectClarity);
+ }
+ IMLoginManager.get(mContext).put(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, selectClarity);
+ showToast();
+ }
- private void showToast() {
- if (WordUtil.isNewZh()) {
- DialogUitl.showToast(mContext, "設置成功\n" +
- "正在為你轉換中", 3000);
- } else {
- DialogUitl.showToast(mContext, "successful\n" +
- "It's being converted for you", 3000);
- }
- }
+ private void showToast() {
+ if (WordUtil.isNewZh()) {
+ DialogUitl.showToast(mContext, "設置成功\n" + "正在為你轉換中", 3000);
+ } else {
+ DialogUitl.showToast(mContext, "successful\n" + "It's being converted for you", 3000);
+ }
+ }
- @Override
- public void beforeDismiss(BasePopupView popupView) {
+ @Override
+ public void beforeDismiss(BasePopupView popupView) {
- }
+ }
- @Override
- public boolean onBackPressed(BasePopupView popupView) {
- return false;
- }
+ @Override
+ public boolean onBackPressed(BasePopupView popupView) {
+ return false;
+ }
- @Override
- public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
+ @Override
+ public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
- }
+ }
- @Override
- public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
+ @Override
+ public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
- }
+ }
- @Override
- public void onClickOutside(BasePopupView popupView) {
+ @Override
+ public void onClickOutside(BasePopupView popupView) {
- }
- })
- .asCustom(liveClarityCustomPopup)
- .show();
+ }
+ }).asCustom(liveClarityCustomPopup).show();
} else if (event.getType() == LiveAudienceEvent.LiveAudienceType.FONT_SIZE) {
int fount = 0;
try {
@@ -881,11 +854,24 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
new LiveFontSizeSettingDialog(mContext, fount).setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(Integer bean, int position) {
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setNums(bean)
- .setType(LiveAudienceEvent.LiveAudienceType.LIVE_FONT_SIZE));
+ EventBus.getDefault().post(new LiveAudienceEvent().setNums(bean).setType(LiveAudienceEvent.LiveAudienceType.LIVE_FONT_SIZE));
}
}).showDialog();
+ } else if (event.getType() == LiveAudienceEvent.LiveAudienceType.PK_TWO_START) {
+ //将当前主播画面换个画布展示
+ swAuManager.updateMyChannelView((FrameLayout) mLeftContainer, Integer.parseInt(liveUid));
+ ry_view.removeAllViews();
+
+ //加入对方主播房间
+ swAuManager.setPkContainer1((FrameLayout) mRightContainer);
+ String pkUid = (String) event.getObject();
+ swAuManager.joinExRoomEx(Integer.parseInt(pkUid), CommonAppConfig.SWToken, SWAuManager.getChannelName(pkUid));
+ } else if (event.getType() == LiveAudienceEvent.LiveAudienceType.LIVE_PK_END) {
+ String pkUid = (String) event.getObject();
+ swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid));
+ swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid));
+ mLeftContainer.removeAllViews();
+ mRightContainer.removeAllViews();
}
}
@@ -904,9 +890,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
}
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
// 根据实际场景,选择音视频直播:LIVE_AUDIO_VIDEO 或音频直播:LIVE_AUDIO
- .setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO)
- .setLiveRole(RCRTCLiveRole.AUDIENCE)
- .build();
+ .setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO).setLiveRole(RCRTCLiveRole.AUDIENCE).build();
RCRTCEngine.getInstance().joinRoom(LiveActivity.mLiveUid, roomConfig, new IRCRTCResultDataCallback() {
@@ -1088,8 +1072,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
break;
}
// 示例代码使用480x640分辨率演示
- RCRTCVideoStreamConfig config = RCRTCVideoStreamConfig
- .Builder.create()
+ RCRTCVideoStreamConfig config = RCRTCVideoStreamConfig.Builder.create()
//设置分辨率
.setVideoResolution(rcrtcVideoResolution)
//设置帧率
@@ -1097,8 +1080,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
//设置最小码率,480P下推荐200
.setMinRate(minRate)
//设置最大码率,480P下推荐900
- .setMaxRate(maxRate)
- .build();
+ .setMaxRate(maxRate).build();
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);
// 创建视图渲染视图
// RCRTCVideoView videoView = new RCRTCVideoView(contexts);
@@ -1156,11 +1138,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
((RCRTCVideoInputStream) stream).setVideoFrameListener(new IRCRTCVideoInputFrameListener() {
@Override
public void onFrame(RCRTCRemoteVideoFrame videoFrame) {
- String debugText = " 2、安卓主播开播, 安卓用户申请连麦后 ,安卓用户这边底部画面不全 :" + videoFrame.getFrameType().name() + "\n" +
- "rotation:" + videoFrame.getRotation() + "\n" +
- "timestampNs:" + videoFrame.getTimestampNs() + "\n" +
- "分辨率:" + videoFrame.getBuffer().getHeight() + "x" + videoFrame.getBuffer().getWidth() + "\n" +
- "当前时间:" + new SimpleDateFormat("HH:mm:ss", Locale.CHINA).format(new Date()) + "\n";
+ String debugText = " 2、安卓主播开播, 安卓用户申请连麦后 ,安卓用户这边底部画面不全 :" + videoFrame.getFrameType().name() + "\n" + "rotation:" + videoFrame.getRotation() + "\n" + "timestampNs:" + videoFrame.getTimestampNs() + "\n" + "分辨率:" + videoFrame.getBuffer().getHeight() + "x" + videoFrame.getBuffer().getWidth() + "\n" + "当前时间:" + new SimpleDateFormat("HH:mm:ss", Locale.CHINA).format(new Date()) + "\n";
//Log.d("ry", "onFrame: " + debugText);
new Handler(Looper.getMainLooper()).post(() -> {
debugView.setText(debugText);
@@ -1190,14 +1168,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.setSpeakerphoneOn(true);
- HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm")
- .params("roomid", LiveActivity.mLiveUid)
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- Log.e("ry", code + "热热热");
- }
- });
+ HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm").params("roomid", LiveActivity.mLiveUid).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ Log.e("ry", code + "热热热");
+ }
+ });
}
@Override
@@ -1232,16 +1208,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private void showLoadingDialog() {
if (PLAY_MODEL == PLAY_MODEL_480) return;
- new DialogUitl.Builder(mContext)
- .setTitle("網絡提示")
- .setContent("系統監測到您的網絡不穩定,對此將清晰度變成了流暢,您可以在側邊菜單中的「清晰度」選擇調回。")
- .setView(R.layout.dialog_simple_tip)
- .setClickCallback(new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- dialog.dismiss();
- }
- }).build().show();
+ new DialogUitl.Builder(mContext).setTitle("網絡提示").setContent("系統監測到您的網絡不穩定,對此將清晰度變成了流暢,您可以在側邊菜單中的「清晰度」選擇調回。").setView(R.layout.dialog_simple_tip).setClickCallback(new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ dialog.dismiss();
+ }
+ }).build().show();
PLAY_MODEL = PLAY_MODEL_480;
String url = srcUrl;
if (videoLandscape == VIDEO_VERTICAL) {
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
index d9f2c2e11..80d2795c7 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
@@ -50,6 +50,7 @@ import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
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;
@@ -83,6 +84,7 @@ import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.agora.beautyapi.faceunity.agora.SWManager;
+import io.rong.imkit.userinfo.db.model.User;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
@@ -228,7 +230,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
UserBean userBean = new UserBean();
userBean.setId(inviterRoomId);
//收到邀请这个时候正在PK或连麦中 自动拒绝对方
- if (isPking() == true) {
+ if (isPking()) {
rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), false, false, "extra", new IRCRTCResultCallback() {
@@ -615,18 +617,43 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
//清除 mBigContainer 中的渲染
mBigContainer.removeAllViews();
-
+ btn_close.setVisibility(View.VISIBLE);
//设置对方主播的渲染视图 设置到 rightContainer
swManager.setPkContainer1(mRightContainer);
swManager.joinChannelEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,u.getId(), SWAuManager.getChannelName(u.getId()));
}
}
+ public void setAnDrPkRtc(String uid) {
+ if (swManager != null && StringUtil.isEmpty(uid)) {
+ L.eSw("设置对方主播的视图 setAnDrPkRtc" + uid);
+
+ //将自己的渲染视图设置到 leftContainer
+ swManager.updateMyChannelView((FrameLayout) mLeftContainer);
+
+ //清除 mBigContainer 中的渲染
+ mBigContainer.removeAllViews();
+ btn_close.setVisibility(View.VISIBLE);
+ //设置对方主播的渲染视图 设置到 rightContainer
+ swManager.setPkContainer1(mRightContainer);
+ swManager.joinChannelEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,uid, SWAuManager.getChannelName(uid));
+ }
+ }
+
+
public void onLinkMicAnchorClose(){
swManager.updateMyChannelView((FrameLayout) mBigContainer);
LivePushRyViewHolder.btn_close.setVisibility(View.GONE);
}
+ public void onLinkDRMicPkApply(UserBean userBean){
+ if (mLiveRyLinkMicPkPresenter != null) {
+ mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
+ }
+ }
+
+
+
@Override
public void changeToLeft() {
if (mPreView != null) {
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
index d2be9d442..828916dd6 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
@@ -130,7 +130,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
public void onClick(View view) {
if (pk_nub <= 0) return;
//開始多人PK
- HttpClient.getInstance().post("live.startDRPK", "live.startDRPK")
+ HttpClient.getInstance().get("live.startDRPK", "live.startDRPK")
.params("roomid", CommonAppConfig.getInstance().getUid())
.execute(new HttpCallback() {
@Override
diff --git a/live/src/main/res/layout/view_live_play_ksy.xml b/live/src/main/res/layout/view_live_play_ksy.xml
index 4eea26aeb..5830a365b 100644
--- a/live/src/main/res/layout/view_live_play_ksy.xml
+++ b/live/src/main/res/layout/view_live_play_ksy.xml
@@ -45,12 +45,11 @@
android:src="@mipmap/zslk"
android:visibility="gone" />
-
-
+ android:layout_width="match_parent"
+ android:layout_height="270dp"
+ android:layout_marginTop="130dp">
-
+