add[声望升级-多人PK]

This commit is contained in:
Martin 2024-04-19 18:27:56 +08:00
parent 583740e866
commit 4147e3c5f5
11 changed files with 306 additions and 338 deletions

View File

@ -76,6 +76,21 @@ public class SWAuManager extends BaseCacheManager {
//mRtcEngine.startPreview(); //mRtcEngine.startPreview();
} }
/**
* 更新主播视图
* @param frameLayout
*/
public void updateMyChannelView(FrameLayout frameLayout,int uid) {
mRtcEngine.setupLocalVideo(null);
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
frameLayout.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid);
mRtcEngine.setupRemoteVideo(videoCanvas);
}
/** /**
* 加入房间 * 加入房间
*/ */
@ -101,14 +116,7 @@ public class SWAuManager extends BaseCacheManager {
} }
public void joinExRoomEx(String strUid, String token, String channelName) { public void joinExRoomEx(int strUid, String token, String channelName) {
int uid;
if (StringUtil.isEmpty(strUid)) {
uid = 0;
} else {
uid = Integer.parseInt(strUid);
}
// 创建 ChannelMediaOptions 对象并进行配置 // 创建 ChannelMediaOptions 对象并进行配置
ChannelMediaOptions options = new ChannelMediaOptions(); ChannelMediaOptions options = new ChannelMediaOptions();
// 根据场景将用户角色设置为 AUDIENCE (观众) // 根据场景将用户角色设置为 AUDIENCE (观众)
@ -119,23 +127,24 @@ public class SWAuManager extends BaseCacheManager {
options.autoSubscribeAudio = true; options.autoSubscribeAudio = true;
RtcConnection rtcConnection = new RtcConnection(); RtcConnection rtcConnection = new RtcConnection();
rtcConnection.channelId = "g99411"; //對方主播的頻道 rtcConnection.channelId = channelName; //對方主播的頻道
rtcConnection.localUid = 99412;//自己的ID rtcConnection.localUid = Integer.parseInt(CommonAppConfig.getInstance().getUid());//自己的ID
mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() { mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
@Override @Override
public void onJoinChannelSuccess(String channel, int uid, int elapsed) { public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
super.onJoinChannelSuccess(channel, uid, elapsed); super.onJoinChannelSuccess(channel, uid, elapsed);
L.eSw("onJoinChannelSuccess:" + channel + " uid " +uid+ " elapsed: " + elapsed); mContext.runOnUiThread(new Runnable() {
@Override
SurfaceView surfaceView = new SurfaceView(mContext); public void run() {
surfaceView.setZOrderMediaOverlay(true); L.eSw("onJoinChannelSuccess:" + channel + " uid " +uid+ " elapsed: " + elapsed);
pkContainer1.addView(surfaceView); SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, 99411); pkContainer1.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, strUid);
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
}
});
} }
@Override @Override
@ -146,6 +155,18 @@ public class SWAuManager extends BaseCacheManager {
}); });
} }
/**
* 退出对方直播间
* @param uid 自己的ID
* @param liveUid 对方直播间号
*/
public void exitChannelToUid(int uid, String liveUid){
RtcConnection rtcConnection = new RtcConnection();
rtcConnection.channelId = getChannelName(liveUid); //對方主播的頻道
rtcConnection.localUid = uid;//自己的ID
mRtcEngine.leaveChannelEx(rtcConnection);
}
public static String getChannelName(String liveUid) { public static String getChannelName(String liveUid) {
return CommonAppConfig.SWChannelPrefix + liveUid; return CommonAppConfig.SWChannelPrefix + liveUid;
} }

View File

@ -123,7 +123,7 @@ public class SWManager extends BaseCacheManager {
anchorContainer.addView(surfaceView); anchorContainer.addView(surfaceView);
Config config = new Config(mContext, mRtcEngine, FURenderer.INSTANCE.mFURenderKit, null, CaptureMode.Agora, 0, false, new CameraConfig(MirrorMode.MIRROR_NONE,MirrorMode.MIRROR_NONE)); Config config = new Config(mContext, mRtcEngine, FURenderer.INSTANCE.mFURenderKit, null, CaptureMode.Agora, 0, false, new CameraConfig(MirrorMode.MIRROR_NONE,MirrorMode.MIRROR_NONE));
faceUnityBeautyAPI.initialize(config); faceUnityBeautyAPI.initialize(config);
faceUnityBeautyAPI.enable(true); faceUnityBeautyAPI.enable(false);
faceUnityBeautyAPI.setBeautyPreset(BeautyPreset.CUSTOM); faceUnityBeautyAPI.setBeautyPreset(BeautyPreset.CUSTOM);
//FaceUnityBeautyManage.getInstance().mFURenderKit.setFaceBeauty(); //FaceUnityBeautyManage.getInstance().mFURenderKit.setFaceBeauty();

View File

@ -315,7 +315,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
private void initFaceManager() { private void initFaceManager() {
manager = new FaceManager(); manager = new FaceManager();
manager.initFURender(mContext); manager.initFURender(mContext);
manager.drawRongFrame(mContext); //暂时去掉
//manager.drawRongFrame(mContext);
} }
public boolean isStartPreview() { public boolean isStartPreview() {
@ -1353,34 +1354,39 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
if (obj != null) { if (obj != null) {
if (obj.getString("ispk").equals("0")) { if (obj.getString("ispk").equals("0")) {
IMRTCManager.getInstance().requestJoinOtherRoom(pkUid, true, extra, new IRCRTCResultCallback() { // TODO: 2024/4/19 邀请主播进行多人连麦
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LIVE_DRPK)
.param("action", 1)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("pkuid", pkUid)
.param("uid", CommonAppConfig.getInstance().getUid())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create();
String targetId = "g" + pkUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override @Override
public void onSuccess() { public void onAttached(Message message) {
if (!extra.equals(SOCKET_LIVE_DRPK_RANDOM)) {
if (WordUtil.isNewZh()) {
ToastUtil.show("邀请 " + pkUid + " 发送成功");
} else {
ToastUtil.show("invite " + pkUid + " successful");
}
}
runOnUiThread(new Runnable() {
@Override
public void run() {
dismiss();
}
});
} }
@Override @Override
public void onFailed(RTCErrorCode rtcErrorCode) { public void onSuccess(Message message) {
runOnUiThread(new Runnable() { if (SocketRyClient.mSocketHandler != null) {
@Override SocketRyClient.mSocketHandler.processBroadcast(message.toString() + "");
public void run() { }
dismiss(); }
}
}); @Override
//todo 安卓端状态码说明文档https://docs.rongcloud.cn/v4/views/rtc/call/code/android.html public void onError(Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", rtcErrorCode + "aaaaaa" + CommonAppConfig.getInstance().getUid() + "VDSSSS" + pkUid); Log.e("tx", "aaa" + errorCode.toString());
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
} }
}); });
} else { } else {

View File

@ -490,7 +490,6 @@ public class LiveAudienceEvent extends BaseModel {
SUD_GAME_CREATE_ROOM(75, "主播创建sud游戏"), SUD_GAME_CREATE_ROOM(75, "主播创建sud游戏"),
PK_RANK_START(76, "PK排位赛开始"), PK_RANK_START(76, "PK排位赛开始"),
GuardSpecialEffect(77, "PK排位赛开始"); GuardSpecialEffect(77, "PK排位赛开始");
private int type; private int type;
private String name; private String name;

View File

@ -387,7 +387,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
//接受PK回调 //接受PK回调
private void pkAccept() { private void pkAccept() {
mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud(); /*mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
mTRTCParams1 = new TRTCCloudDef.TRTCParams(); mTRTCParams1 = new TRTCCloudDef.TRTCParams();
mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID; mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID;
mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk"; mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk";
@ -396,7 +396,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mTRTCParams1.role = TRTCCloudDef.TRTCRoleAudience; mTRTCParams1.role = TRTCCloudDef.TRTCRoleAudience;
mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE); mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
mTRTCCloud1.startRemoteView(mApplyUid, LivePushTxViewHolder.mPreView1); mTRTCCloud1.startRemoteView(mApplyUid, LivePushTxViewHolder.mPreView1);
mTRTCCloud1.setListener(new TRTCCloudImplListener(mContext)); mTRTCCloud1.setListener(new TRTCCloudImplListener(mContext));*/
LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE); LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE);
SocketLinkMicPkUtil.linkMicPkAccept(mSocketClient, mApplyUid, mApplyUrl, mApplyNmae); SocketLinkMicPkUtil.linkMicPkAccept(mSocketClient, mApplyUid, mApplyUrl, mApplyNmae);
onLinkMicPkStart(mApplyUid, mApplyUrl, mApplyNmae); onLinkMicPkStart(mApplyUid, mApplyUrl, mApplyNmae);
@ -734,19 +734,9 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE); mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
} }
if (mAcceptPk) { if (mAcceptPk) {
LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE); LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE);
//把画面设置成九宫格 //把画面设置成九宫格
dr_pk_view.setVisibility(View.VISIBLE); dr_pk_view.setVisibility(View.VISIBLE);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mPreView.getLayoutParams();
params.width = mPreView.getWidth() / 2;
params.height = DpUtil.dp2px(250);
params.topMargin = DpUtil.dp2px(130);
mPreView.setLayoutParams(params);
HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive") HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive")
.params("uid", CommonAppConfig.getInstance().getUid()) .params("uid", CommonAppConfig.getInstance().getUid())
@ -757,7 +747,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
@Override @Override
public void onSuccess(int code, String msgs, String[] info) { public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) { if (code == 0) {
HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom") HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
.params("uid", CommonAppConfig.getInstance().getUid()) .params("uid", CommonAppConfig.getInstance().getUid())
.params("roomid", u.getId()) .params("roomid", u.getId())
@ -768,15 +757,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
public void onSuccess(int code, String msgs, String[] info) { public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) { if (code == 0) {
JSONObject obj = JSON.parseObject(info[0]); JSONObject obj = JSON.parseObject(info[0]);
if (LiveLinkMicPkPresenter.mTRTCCloud1 != null && LivePushTxViewHolder.mTRTCCloud != null) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mContext.getResources().getDimensionPixelOffset(R.dimen.live_view));
params.weight = 1;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
LivePushTxViewHolder.mPreView.setLayoutParams(params);
LivePushTxViewHolder.mPreView1.setLayoutParams(params);
}
List<DrPkbean> list = JSON.parseArray(obj.getString("userlist"), DrPkbean.class); List<DrPkbean> list = JSON.parseArray(obj.getString("userlist"), DrPkbean.class);
for (int ii = 0, size = list.size(); ii < size; ii++) { 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++) { for (int i = 0, size = list.size(); i < size; i++) {
if (!String.valueOf(list.get(i).getId()).equals(CommonAppConfig.getInstance().getUid())) { 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() + ""); Log.i("ssxcs", list.get(i).getId() + "");
final SocketSendBean msg = new SocketSendBean() final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_DRPK) .param("_method_", Constants.SOCKET_LIVE_DRPK)
@ -842,8 +797,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
} }
}); });
} }
} }
}); });

View File

@ -1243,99 +1243,90 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
agree = false; agree = false;
} }
boolean finalAgree = agree; boolean finalAgree = agree;
IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, agree, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() { if (finalAgree) {
@Override HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
public void onSuccess() { .params("uid", CommonAppConfig.getInstance().getUid())
if (finalAgree == true) { .params("roomid", u.getId())
HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom") .execute(new HttpCallback() {
.params("uid", CommonAppConfig.getInstance().getUid())
.params("roomid", u.getId()) @Override
.execute(new HttpCallback() { 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 @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(io.rong.imlib.model.Message message) {
Log.i("多人PK", "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info)); Log.e("ry", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
final SocketSendBean msg1 = new SocketSendBean() SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
.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())) {
/**
* 向指定用户发送跨房间连麦请求
* <P>
* 1: inviterAutoMix为true时
*
* 1.1如果被邀请方在加入邀请方房间之前发布了资源当被邀请方加入邀请者房间成功后服务器会把被邀请方流资源合并到邀请方视图 ·默认仅悬浮布局合流
*
* 1.2如果被邀请方在加入邀请方房间之前没有发布过资源将会在被邀请方发布资源成功后服务器会把被邀请方流资源合并到邀请方视图默认仅悬浮布局合流
*
* 2:无论为true或false双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
* <P/>
*/
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(RTCErrorCode errorCode) {
}
});
}
}
} }
} }
});
}
}
@Override @Override
public void onFailed(RTCErrorCode errorCode) { public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
ToastUtil.show("接受失败"); 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())) {
/**
* 向指定用户发送跨房间连麦请求
* <P>
* 1: inviterAutoMix为true时
*
* 1.1如果被邀请方在加入邀请方房间之前发布了资源当被邀请方加入邀请者房间成功后服务器会把被邀请方流资源合并到邀请方视图 ·默认仅悬浮布局合流
*
* 1.2如果被邀请方在加入邀请方房间之前没有发布过资源将会在被邀请方发布资源成功后服务器会把被邀请方流资源合并到邀请方视图默认仅悬浮布局合流
*
* 2:无论为true或false双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
* <P/>
*/
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(RTCErrorCode errorCode) {
}
});
}
}
}
}
});
}
} else { } else {
ToastUtil.show(msg); ToastUtil.show(msg);
} }

View File

@ -309,10 +309,10 @@ public class SocketRyClient {
} }
//收到对方同意多人PK邀请 //收到对方同意多人PK邀请
else if (action3 == 2) { else if (action3 == 2) {
// UserBean u = new UserBean(); UserBean u = new UserBean();
//// u.setUserNiceName(map.getString("uname")); // u.setUserNiceName(map.getString("uname"));
// u.setId(map.getString("uid")); u.setId(map.getString("uid"));
// mListener.onLinkDRMicPkApplyOk(u); mListener.onLinkDRMicPkApplyOk(u);
} else if (action3 == 6) {//开始Pk } else if (action3 == 6) {//开始Pk
if (LiveRoomViewHolder.mHandler != null) { if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
@ -1307,7 +1307,7 @@ public class SocketRyClient {
break; break;
case 9://pk结束的回调 case 9://pk结束的回调
mListener.onLinkMicPkEnd(map.getString("win_uid")); 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) { if (livePushRyViewHolder != null) {
livePushRyViewHolder.onLinkMicAnchorClose(); livePushRyViewHolder.onLinkMicAnchorClose();
} }

View File

@ -96,7 +96,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private ViewGroup mSmallContainer; private ViewGroup mSmallContainer;
private ViewGroup mLeftContainer; private ViewGroup mLeftContainer;
private ViewGroup mRightContainer; private ViewGroup mRightContainer;
private RelativeLayout mPkContainer; private ViewGroup mPkContainer;
public StyledPlayerView mVideoView; public StyledPlayerView mVideoView;
private FrameLayout playFrameLayout; private FrameLayout playFrameLayout;
@ -158,7 +158,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mSmallContainer = (ViewGroup) findViewById(R.id.small_container); mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
mLeftContainer = (ViewGroup) findViewById(R.id.left_container); mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
mRightContainer = (ViewGroup) findViewById(R.id.right_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); mVideoView = (StyledPlayerView) findViewById(R.id.video_view);
ry_view = (FrameLayout) findViewById(R.id.ry_view); ry_view = (FrameLayout) findViewById(R.id.ry_view);
leave = (ImageView) findViewById(R.id.leave); leave = (ImageView) findViewById(R.id.leave);
@ -179,15 +179,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void initSwEngine(String liveUid) { public void initSwEngine(String liveUid) {
this.liveUid = liveUid; this.liveUid = liveUid;
//初始化声网SDK
swAuManager = SWAuManager.get(); swAuManager = SWAuManager.get();
swAuManager.setAudienceContainer(ry_view); swAuManager.setAudienceContainer(ry_view);
swAuManager.initRtcEngine((Activity) mContext); swAuManager.initRtcEngine((Activity) mContext);
swAuManager.setupRemoteVideo(Integer.parseInt(liveUid)); swAuManager.setupRemoteVideo(Integer.parseInt(liveUid));
//进入主播房间
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(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 @Override
@ -232,11 +230,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params); mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); 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.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params1.topMargin = 0; params1.topMargin = 0;
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = RelativeLayout.LayoutParams.MATCH_PARENT; params2.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params2.topMargin = 0; params2.topMargin = 0;
@ -252,12 +250,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params); mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); mVideoView.requestLayout();
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight; params1.height = vHeight;
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP); params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270); params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120); params2.topMargin = DpUtil.dp2px(120);
@ -373,12 +371,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params); mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); 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.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP); params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270); params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120); params2.topMargin = DpUtil.dp2px(120);
@ -422,11 +420,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params.addRule(RelativeLayout.ALIGN_TOP); params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout(); mVideoView.requestLayout();
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight; params1.height = vHeight;
params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP); params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.requestLayout(); ry_view.requestLayout();*/
isPk = true; isPk = true;
} }
@ -453,11 +451,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params); mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); mVideoView.requestLayout();
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = height; params1.height = height;
params1.topMargin = 0; params1.topMargin = 0;
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height; params2.height = height;
params2.topMargin = 0; params2.topMargin = 0;
@ -475,7 +473,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mVideoView.setLayoutParams(params); mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); mVideoView.requestLayout();
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = height; params1.height = height;
params1.topMargin = 0; params1.topMargin = 0;
params1.addRule(RelativeLayout.ALIGN_TOP); params1.addRule(RelativeLayout.ALIGN_TOP);
@ -483,7 +481,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
} }
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height; params2.height = height;
params2.topMargin = DpUtil.dp2px(120); params2.topMargin = DpUtil.dp2px(120);
@ -668,37 +666,24 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
confirm = "accept"; confirm = "accept";
cancel = "cancel"; cancel = "cancel";
} }
DialogUitl.Builder builder = new DialogUitl.Builder(mContext) 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() {
.setContent(content) @Override
.setTitle(mLiveBean.getUserNiceName()) public void onConfirmClick(Dialog dialog, String content) {
.setConfirmString(confirm) String[] permissions;
.setCancelString(cancel) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
.setView(R.layout.dialog_live_mic_invite) permissions = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.RECORD_AUDIO};
.setClickCallback(new DialogUitl.SimpleCallback() { } 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 @Override
public void onConfirmClick(Dialog dialog, String content) { public void run() {
String[] permissions; UsertoRY();
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();
}
});
} }
}); });
}
});
builder.build().show(); builder.build().show();
} else if ("endMic".equals(str)) { } else if ("endMic".equals(str)) {
@ -776,11 +761,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
EasyFloat.dismiss("Debug"); EasyFloat.dismiss("Debug");
return; return;
} }
EasyFloat.with(mContext) EasyFloat.with(mContext).setDragEnable(true).setTag("Debug").setLayout(debugView).show();
.setDragEnable(true)
.setTag("Debug")
.setLayout(debugView)
.show();
} }
} }
@ -798,79 +779,71 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
break; break;
} }
LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR), ban, true);
IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR), new XPopup.Builder(mContext).setPopupCallback(new XPopupCallback() {
ban, @Override
true); public void onCreated(BasePopupView popupView) {
new XPopup.Builder(mContext)
.setPopupCallback(new XPopupCallback() {
@Override
public void onCreated(BasePopupView popupView) {
} }
@Override @Override
public void beforeShow(BasePopupView popupView) { public void beforeShow(BasePopupView popupView) {
} }
@Override @Override
public void onShow(BasePopupView popupView) { public void onShow(BasePopupView popupView) {
} }
@Override @Override
public void onDismiss(BasePopupView popupView) { public void onDismiss(BasePopupView popupView) {
int selectClarity = liveClarityCustomPopup.getSelectClarity(); int selectClarity = liveClarityCustomPopup.getSelectClarity();
if (selectClarity == PLAY_MODEL || selectClarity == IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR)) if (selectClarity == PLAY_MODEL || selectClarity == IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR))
return; return;
if (selectClarity == PLAY_MODEL_ANCHOR) { if (selectClarity == PLAY_MODEL_ANCHOR) {
switchStream(srcUrl, PLAY_MODEL_DEF); switchStream(srcUrl, PLAY_MODEL_DEF);
setAudiencePlayModel(selectClarity); setAudiencePlayModel(selectClarity);
} else { } else {
switchStream(srcUrl, selectClarity); switchStream(srcUrl, selectClarity);
} }
IMLoginManager.get(mContext).put(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, selectClarity); IMLoginManager.get(mContext).put(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, selectClarity);
showToast(); showToast();
} }
private void showToast() { private void showToast() {
if (WordUtil.isNewZh()) { if (WordUtil.isNewZh()) {
DialogUitl.showToast(mContext, "設置成功\n" + DialogUitl.showToast(mContext, "設置成功\n" + "正在為你轉換中", 3000);
"正在為你轉換中", 3000); } else {
} else { DialogUitl.showToast(mContext, "successful\n" + "It's being converted for you", 3000);
DialogUitl.showToast(mContext, "successful\n" + }
"It's being converted for you", 3000); }
}
}
@Override @Override
public void beforeDismiss(BasePopupView popupView) { public void beforeDismiss(BasePopupView popupView) {
} }
@Override @Override
public boolean onBackPressed(BasePopupView popupView) { public boolean onBackPressed(BasePopupView popupView) {
return false; return false;
} }
@Override @Override
public void onKeyBoardStateChanged(BasePopupView popupView, int height) { public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
} }
@Override @Override
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) { public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
} }
@Override @Override
public void onClickOutside(BasePopupView popupView) { public void onClickOutside(BasePopupView popupView) {
} }
}) }).asCustom(liveClarityCustomPopup).show();
.asCustom(liveClarityCustomPopup)
.show();
} else if (event.getType() == LiveAudienceEvent.LiveAudienceType.FONT_SIZE) { } else if (event.getType() == LiveAudienceEvent.LiveAudienceType.FONT_SIZE) {
int fount = 0; int fount = 0;
try { try {
@ -881,11 +854,24 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
new LiveFontSizeSettingDialog(mContext, fount).setOnItemClickListener(new OnItemClickListener<Integer>() { new LiveFontSizeSettingDialog(mContext, fount).setOnItemClickListener(new OnItemClickListener<Integer>() {
@Override @Override
public void onItemClick(Integer bean, int position) { public void onItemClick(Integer bean, int position) {
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setNums(bean).setType(LiveAudienceEvent.LiveAudienceType.LIVE_FONT_SIZE));
.setNums(bean)
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_FONT_SIZE));
} }
}).showDialog(); }).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() RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
// 根据实际场景选择音视频直播LIVE_AUDIO_VIDEO 或音频直播LIVE_AUDIO // 根据实际场景选择音视频直播LIVE_AUDIO_VIDEO 或音频直播LIVE_AUDIO
.setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO) .setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO).setLiveRole(RCRTCLiveRole.AUDIENCE).build();
.setLiveRole(RCRTCLiveRole.AUDIENCE)
.build();
RCRTCEngine.getInstance().joinRoom(LiveActivity.mLiveUid, roomConfig, new IRCRTCResultDataCallback<RCRTCRoom>() { RCRTCEngine.getInstance().joinRoom(LiveActivity.mLiveUid, roomConfig, new IRCRTCResultDataCallback<RCRTCRoom>() {
@ -1088,8 +1072,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
break; break;
} }
// 示例代码使用480x640分辨率演示 // 示例代码使用480x640分辨率演示
RCRTCVideoStreamConfig config = RCRTCVideoStreamConfig RCRTCVideoStreamConfig config = RCRTCVideoStreamConfig.Builder.create()
.Builder.create()
//设置分辨率 //设置分辨率
.setVideoResolution(rcrtcVideoResolution) .setVideoResolution(rcrtcVideoResolution)
//设置帧率 //设置帧率
@ -1097,8 +1080,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
//设置最小码率480P下推荐200 //设置最小码率480P下推荐200
.setMinRate(minRate) .setMinRate(minRate)
//设置最大码率480P下推荐900 //设置最大码率480P下推荐900
.setMaxRate(maxRate) .setMaxRate(maxRate).build();
.build();
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config); RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);
// 创建视图渲染视图 // 创建视图渲染视图
// RCRTCVideoView videoView = new RCRTCVideoView(contexts); // RCRTCVideoView videoView = new RCRTCVideoView(contexts);
@ -1156,11 +1138,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
((RCRTCVideoInputStream) stream).setVideoFrameListener(new IRCRTCVideoInputFrameListener() { ((RCRTCVideoInputStream) stream).setVideoFrameListener(new IRCRTCVideoInputFrameListener() {
@Override @Override
public void onFrame(RCRTCRemoteVideoFrame videoFrame) { public void onFrame(RCRTCRemoteVideoFrame videoFrame) {
String debugText = " 2、安卓主播开播 安卓用户申请连麦后 ,安卓用户这边底部画面不全 :" + videoFrame.getFrameType().name() + "\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";
"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); //Log.d("ry", "onFrame: " + debugText);
new Handler(Looper.getMainLooper()).post(() -> { new Handler(Looper.getMainLooper()).post(() -> {
debugView.setText(debugText); debugView.setText(debugText);
@ -1190,14 +1168,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.setSpeakerphoneOn(true); audioManager.setSpeakerphoneOn(true);
HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm") HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm").params("roomid", LiveActivity.mLiveUid).execute(new HttpCallback() {
.params("roomid", LiveActivity.mLiveUid) @Override
.execute(new HttpCallback() { public void onSuccess(int code, String msg, String[] info) {
@Override Log.e("ry", code + "热热热");
public void onSuccess(int code, String msg, String[] info) { }
Log.e("ry", code + "热热热"); });
}
});
} }
@Override @Override
@ -1232,16 +1208,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private void showLoadingDialog() { private void showLoadingDialog() {
if (PLAY_MODEL == PLAY_MODEL_480) return; if (PLAY_MODEL == PLAY_MODEL_480) return;
new DialogUitl.Builder(mContext) new DialogUitl.Builder(mContext).setTitle("網絡提示").setContent("系統監測到您的網絡不穩定,對此將清晰度變成了流暢,您可以在側邊菜單中的「清晰度」選擇調回。").setView(R.layout.dialog_simple_tip).setClickCallback(new DialogUitl.SimpleCallback() {
.setTitle("網絡提示") @Override
.setContent("系統監測到您的網絡不穩定,對此將清晰度變成了流暢,您可以在側邊菜單中的「清晰度」選擇調回。") public void onConfirmClick(Dialog dialog, String content) {
.setView(R.layout.dialog_simple_tip) dialog.dismiss();
.setClickCallback(new DialogUitl.SimpleCallback() { }
@Override }).build().show();
public void onConfirmClick(Dialog dialog, String content) {
dialog.dismiss();
}
}).build().show();
PLAY_MODEL = PLAY_MODEL_480; PLAY_MODEL = PLAY_MODEL_480;
String url = srcUrl; String url = srcUrl;
if (videoLandscape == VIDEO_VERTICAL) { if (videoLandscape == VIDEO_VERTICAL) {

View File

@ -50,6 +50,7 @@ import com.yunbao.common.utils.Bus;
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.L;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
@ -83,6 +84,7 @@ import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RTCErrorCode; import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWAuManager; import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.agora.beautyapi.faceunity.agora.SWManager; import io.agora.beautyapi.faceunity.agora.SWManager;
import io.rong.imkit.userinfo.db.model.User;
import io.rong.imlib.IRongCallback; import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient; import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Conversation;
@ -228,7 +230,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
UserBean userBean = new UserBean(); UserBean userBean = new UserBean();
userBean.setId(inviterRoomId); userBean.setId(inviterRoomId);
//收到邀请这个时候正在PK或连麦中 自动拒绝对方 //收到邀请这个时候正在PK或连麦中 自动拒绝对方
if (isPking() == true) { if (isPking()) {
rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), false, false, "extra", new IRCRTCResultCallback() { 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 中的渲染
mBigContainer.removeAllViews(); mBigContainer.removeAllViews();
btn_close.setVisibility(View.VISIBLE);
//设置对方主播的渲染视图 设置到 rightContainer //设置对方主播的渲染视图 设置到 rightContainer
swManager.setPkContainer1(mRightContainer); swManager.setPkContainer1(mRightContainer);
swManager.joinChannelEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,u.getId(), SWAuManager.getChannelName(u.getId())); 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(){ public void onLinkMicAnchorClose(){
swManager.updateMyChannelView((FrameLayout) mBigContainer); swManager.updateMyChannelView((FrameLayout) mBigContainer);
LivePushRyViewHolder.btn_close.setVisibility(View.GONE); LivePushRyViewHolder.btn_close.setVisibility(View.GONE);
} }
public void onLinkDRMicPkApply(UserBean userBean){
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
}
}
@Override @Override
public void changeToLeft() { public void changeToLeft() {
if (mPreView != null) { if (mPreView != null) {

View File

@ -130,7 +130,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
public void onClick(View view) { public void onClick(View view) {
if (pk_nub <= 0) return; if (pk_nub <= 0) return;
//開始多人PK //開始多人PK
HttpClient.getInstance().post("live.startDRPK", "live.startDRPK") HttpClient.getInstance().get("live.startDRPK", "live.startDRPK")
.params("roomid", CommonAppConfig.getInstance().getUid()) .params("roomid", CommonAppConfig.getInstance().getUid())
.execute(new HttpCallback() { .execute(new HttpCallback() {
@Override @Override

View File

@ -45,12 +45,11 @@
android:src="@mipmap/zslk" android:src="@mipmap/zslk"
android:visibility="gone" /> android:visibility="gone" />
<FrameLayout
<RelativeLayout
android:id="@+id/pk_container" android:id="@+id/pk_container"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="270dp"
android:layout_marginTop="@dimen/live_top"> android:layout_marginTop="130dp">
<com.yunbao.live.custom.MyFrameLayout4 <com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/left_container" android:id="@+id/left_container"
@ -65,7 +64,7 @@
android:layout_gravity="right" android:layout_gravity="right"
android:layout_marginBottom="20dp" /> android:layout_marginBottom="20dp" />
</RelativeLayout> </FrameLayout>
<com.yunbao.live.custom.MyFrameLayout3 <com.yunbao.live.custom.MyFrameLayout3