diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java index 28877628d..86fe52473 100644 --- a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java +++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java @@ -90,7 +90,6 @@ public class SWAuManager extends BaseCacheManager { mRtcEngine.setupRemoteVideo(videoCanvas); } - /** * 加入房间 */ @@ -155,6 +154,65 @@ public class SWAuManager extends BaseCacheManager { }); } + /** + * PK-加入对方主播直播间 + * @param strUid + * @param token + * @param toUid + * @param channelName + */ + public void joinChannelDrEx(FrameLayout frameLayout,String strUid, String token, String toUid, String channelName) { + int tempUid; + if (StringUtil.isEmpty(strUid)) { + tempUid = 0; + } else { + tempUid = Integer.parseInt(strUid); + } + + // 创建 ChannelMediaOptions 对象,并进行配置 + ChannelMediaOptions options = new ChannelMediaOptions(); + // 根据场景将用户角色设置为 AUDIENCE (观众) + options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; + options.autoSubscribeVideo = true; + options.autoSubscribeAudio = true; + options.publishMicrophoneTrack = false; + options.publishCameraTrack = false; + + RtcConnection rtcConnection = new RtcConnection(); + rtcConnection.channelId = channelName; //對方主播的頻道 + rtcConnection.localUid = tempUid;//自己的ID + L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName); + mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() { + @Override + public void onJoinChannelSuccess(String channel, int scUid, int elapsed) { + super.onJoinChannelSuccess(channel, scUid, elapsed); + L.eSw("onJoinChannelSuccess:" + channel + " uid " + scUid + " elapsed: " + elapsed); + mContext.runOnUiThread(new Runnable() { + @Override + public void run() { + SurfaceView surfaceView = new SurfaceView(mContext); + surfaceView.setZOrderMediaOverlay(true); + frameLayout.addView(surfaceView); + VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT,Integer.parseInt(toUid)); + mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); + } + }); + } + + @Override + public void onLeaveChannel(RtcStats stats) { + super.onLeaveChannel(stats); + } + + @Override + public void onError(int err) { + super.onError(err); + L.eSw("onError:" + err); + } + }); + } + + /** * 退出对方直播间 * @param uid 自己的ID diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java index 31228560f..98c2124ab 100644 --- a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java +++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java @@ -134,6 +134,8 @@ public class SWManager extends BaseCacheManager { faceUnityBeautyAPI.setupLocalVideo(surfaceView, Constants.RENDER_MODE_HIDDEN); //faceUnityBeautyAPI.updateCameraConfig(new CameraConfig(MirrorMode.MIRROR_NONE,MirrorMode.MIRROR_NONE)); //mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid)); + setEnableBeauty(true); //默认开启美颜 + } public void setEnableBeauty(boolean flag){ @@ -279,26 +281,6 @@ public class SWManager extends BaseCacheManager { }); } - /** - * 更新主播视图 - * @param frameLayout - * @param channelName 對方直播間通道 - * @param toUid 對方主播uid - */ - public void updateDrChannelView(FrameLayout frameLayout,String channelName,String toUid) { - mRtcEngine.setupLocalVideo(null); - - RtcConnection rtcConnection = new RtcConnection(); - rtcConnection.channelId = channelName; //對方主播的頻道 - rtcConnection.localUid = Integer.parseInt(CommonAppConfig.getInstance().getUid());//自己的ID - - SurfaceView surfaceView = new SurfaceView(mContext); - surfaceView.setZOrderMediaOverlay(true); - frameLayout.addView(surfaceView); - VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT,Integer.parseInt(toUid)); - mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); - } - /** * PK-加入对方主播直播间 diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java index 9a2484077..48a769c5f 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java @@ -1000,6 +1000,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic //多人PK接受 @Override public void onLinkDRMicPkApplyOk(UserBean u) { + L.eSw("onLinkDRMicPkApplyOk(UserBean u)"); if (mLiveLinkMicPkPresenter != null) { mLiveLinkMicPkPresenter.onLinkDRMicPkApplyOk(u); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 953ed3fe1..e52c6e360 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -31,6 +31,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; import com.facebook.appevents.AppEventsLogger; +import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BasePopupView; import com.lxj.xpopup.enums.PopupPosition; @@ -566,7 +567,9 @@ public class LiveAudienceActivity extends LiveActivity { @Override public void onLinkDRMicPkApplyOk(UserBean u) { - + L.eSw("onLinkDRMicPkApplyOk:"+u.getId()); + //多人PK 连麦 + manager.getmLivePlayViewHolder().setDrMicInfo(u); } @Override @@ -1446,7 +1449,7 @@ public class LiveAudienceActivity extends LiveActivity { if (manager.getmLivePlayViewHolder() != null) { manager.getmLivePlayViewHolder().setPkEndview(); manager.setPkStatus(false); - + manager.mLivePlayViewHolder.endPk(); } if (manager != null) { manager.removeDetailView(); diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 170ade09c..6d3b6f6af 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -222,27 +222,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl Bus.getOn(this); Intent intent = getIntent(); initFaceManager(); - RCRTCEngine.getInstance().registerStatusReportListener(new IRCRTCStatusReportListener() { - - @Override - public void onConnectionStats(StatusReport statusReport) { - //视频发送信息 - for (Map.Entry entry : statusReport.statusVideoSends.entrySet()) { - StatusBean statusBean = entry.getValue(); - //获取userID - String userId = statusBean.uid; - //获取视频 宽x高@帧率 - String resolution = statusBean.frameWidth + "x" + statusBean.frameHeight + "@" + statusBean.frameRate; - //获取码率 - long bitRate = statusBean.bitRate; - //丢包率 - long lossRate = statusBean.packetLostRate; - //带宽 - String googAvailableSendBandwidth = statusReport.googAvailableSendBandwidth; -// Log.e("网速和内存", "获取视频:" + resolution + " 丢包率:" + lossRate + " 带宽:" + googAvailableSendBandwidth); - } - } - }); leave_img = findViewById(R.id.leave_img); mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY); mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG); @@ -1452,6 +1431,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl //多人PK接受 @Override public void onLinkDRMicPkApplyOk(UserBean u) { + L.eSw("onLinkDRMicPkApplyOk111111"); if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.onLinkDRMicPkApplyOk(u); } @@ -1712,7 +1692,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl break; case DISCONNEXT_PK_TIME: if (mLivePushViewHolder != null) { - mLivePushViewHolder.changeToBig(); + //mLivePushViewHolder.changeToBig(); + mLivePushViewHolder.anchorClose(); mLiveRyLinkMicPkPresenter.leaveDRRoom(); } break; diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java index dd9aeb4c0..851145c90 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java @@ -29,6 +29,7 @@ import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; 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; @@ -357,6 +358,8 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener { */ public void onLinkDRMicPkApplyOk(UserBean u) { + L.eSw("public void onLinkDRMicPkApplyOk(UserBean u) {"); + user.add(u); Log.i("1111", "12222222a" + user.size()); mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud(); 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 003fc065d..2f69d8575 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -29,6 +29,7 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; @@ -99,6 +100,7 @@ import cn.rongcloud.rtc.base.RCRTCMediaType; import cn.rongcloud.rtc.base.RCRTCRoomType; import cn.rongcloud.rtc.base.RCRTCStream; import cn.rongcloud.rtc.base.RTCErrorCode; +import io.agora.beautyapi.faceunity.agora.SWManager; import io.rong.imlib.IRongCallback; import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; @@ -515,9 +517,31 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { * 主播与主播PK 主播收到其他主播发过来的多人PK申请同意了的回调 */ public void onLinkDRMicPkApplyOk(UserBean u) { - if(livePushRyViewHolder!=null){ - livePushRyViewHolder.setAnDrPkRtc(String.valueOf(u.getId()),-1); + L.eSw("onLinkDRMicPkApplyOk(UserBean u) " + u.getUserNiceName()); + int index = 0; + if (livePushRyViewHolder != null) { + livePushRyViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1); } + HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", CommonAppConfig.getInstance().getUid()).execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if(info.length>0){ + JSONObject obj = JSONObject.parseObject(info[0]); + drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class); + int removeIndex = -1; + for (int i = 0; i < drPkbeans.size(); i++) { + if (CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) { + removeIndex = i; + } + } + if (removeIndex != -1) { + drPkbeans.remove(removeIndex); + L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans)); + } + dRjoinOtherRoom(drPkbeans); + } + } + }); } /** @@ -815,79 +839,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { } } }); - - for (int i = 0; i < inputStreamList.size(); i++) { - Log.e("ry", "退出多人ID" + inputStreamList.get(i).getUserId()); - //退出副房间 - RCRTCEngine.getInstance().leaveOtherRoom(inputStreamList.get(i).getUserId(), true, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "退出多人成功"); - - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - Log.e("ry", "退出多人失败" + rtcErrorCode); - - } - }); - } - - - RCRTCMixConfig config = new RCRTCMixConfig(); - RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig(); - config.setMediaConfig(mediaConfig); -//视频输出配置 - RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig(); - mediaConfig.setVideoConfig(videoConfig); -//大流视频的输出参数 - RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout(); - videoConfig.setVideoLayout(normal); -//推荐宽、高、帧率参数值可以通过默认视频流的配置获取,也可以根据实际需求来自定义设置 -//如不设置宽高值则服务端将使用默认宽高 360 * 640 -//例:发布的视频分辨率为720 * 1280,如果不设置则观众端看到的视频分辨率为 360 * 640, -//所以如果想让观众端看到的视频分辨率和发布视频分辨率一致,则应从发布的视频流中获取分辨率配置并设置到 mediaConfig 中 - RCRTCVideoStreamConfig defaultVideoConfig = RCRTCEngine.getInstance().getDefaultVideoStream().getVideoConfig(); - int fps = defaultVideoConfig.getVideoFps().getFps(); - int width = 720; - int height = 1280; - normal.setWidth(width); //视频宽 - normal.setHeight(height); //视频高 - normal.setFps(fps); //视频帧率 - - //2. 合流画布设置 - //(请参照画布和声音配置示例代码) - //3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准),设置每个视频流小窗口的坐标及宽高 - ArrayList list = new ArrayList<>(); - config.setCustomLayouts(list); - //user1的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - list.add(videoLayout1); - videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video - videoLayout1.setX(0); //X 坐标 - videoLayout1.setY(0); //Y 坐标 - videoLayout1.setWidth(720); // 视频窗口的宽 - videoLayout1.setHeight(1280); // 视频窗口的高 - //2. 合流画布设置 - if (rcrtcLiveInfo != null) { - rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "混成功15"); - } - - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", "混失败" + errorCode); - - } - }); - - } - - leaveHandler.post(leaveRunnable); - + livePushRyViewHolder.exitChannelDrPk(drPkbeans); + leaveHandler.removeCallbacks(leaveRunnable); } private Handler leaveHandler = new Handler(Looper.getMainLooper()); @@ -895,15 +848,12 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { @Override public void run() { //恢复全屏画面 - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - params.topMargin = 0; - livePushRyViewHolder.camera.setLayoutParams(params); livePushRyViewHolder.dr_pk_view.setVisibility(View.GONE); - inputStreamList.clear(); - inputStreamList1.clear(); //删除之前其他主播的画面 livePushRyViewHolder.dr1_preview.removeAllViews(); + livePushRyViewHolder.dr2_preview.removeAllViews(); livePushRyViewHolder.dr3_preview.removeAllViews(); + livePushRyViewHolder.dr4_preview.removeAllViews(); livePushRyViewHolder.cameraPreview3.removeAllViews(); leaveHandler.removeCallbacks(leaveRunnable); livePushRyViewHolder.timeTitle.setVisibility(View.GONE); @@ -1027,6 +977,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { LiveNetManager.get(mContext).setBanRandomPK(null); } + /** * 显示申请多人PK的弹窗 */ @@ -1072,22 +1023,27 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { @Override public void onSuccess(int code, String msg, String[] info) { - L.eSw("多人PK"+ "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info)); + L.eSw("多人PK" + "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info)); if (info.length == 0) { return; } JSONObject obj = JSONObject.parseObject(info[0]); - drPkbeans = JSONObject.parseArray(obj.getString("userlist"),DrPkbean.class); - for (int i = 0; i - * 1: inviterAutoMix为true时: - * - * 1.1:如果被邀请方在加入邀请方房间之前发布了资源,当被邀请方加入邀请者房间成功后,服务器会把被邀请方流资源合并到邀请方视图 ·(默认仅悬浮布局合流)上。 - * - * 1.2:如果被邀请方在加入邀请方房间之前没有发布过资源,将会在被邀请方发布资源成功后,服务器会把被邀请方流资源合并到邀请方视图(默认仅悬浮布局合流)上。 - * - * 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。 - *

- *//* + * 向指定用户发送跨房间连麦请求 + *

+ * 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() { @@ -1264,57 +1221,217 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { //多人PK接受申请画 加入副房间 - public void dRjoinOtherRoom(String uid, int i) { - Log.e("ry", uid + "洒洒" + i + "VVVV" + i); - mApplyUid = uid; - /*new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - //把多人PK的View显示出来 - if (livePushRyViewHolder.dr_pk_view.getVisibility() == View.GONE) { - livePushRyViewHolder.dr_pk_view.setVisibility(View.VISIBLE); - livePushRyViewHolder.dr1_preview.setVisibility(View.GONE); - livePushRyViewHolder.dr2_preview.setVisibility(View.GONE); - livePushRyViewHolder.dr3_preview.setVisibility(View.GONE); - livePushRyViewHolder.dr4_preview.setVisibility(View.GONE); + public void dRjoinOtherRoom(List drPkbeanList) { + L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList)); + if (drPkbeanList.size() == 1) { + String uid = String.valueOf(drPkbeanList.get(0).getId()); + //设置多人PK数据 + LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveInfoModel data) { + if(detailsView2!=null){ + livePushRyViewHolder.dr2_preview.removeView(detailsView2); + } + detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2); + linearGrade2 = detailsView2.findViewById(R.id.linear_grade2); + textPkName2 = detailsView2.findViewById(R.id.text_pk_name2); + imageGrade2 = detailsView2.findViewById(R.id.image_grade2); + textGrade2 = detailsView2.findViewById(R.id.text_grade2); + imageGrade2.setTag(uid); + textPkName2.setText(data.getUserNicename()); + livePushRyViewHolder.dr2_preview.addView(detailsView2); + detailsLinearLayout2.setVisibility(View.VISIBLE); + linearGrade2.setVisibility(View.GONE); + } + + @Override + public void onError(String error) { + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); + } + }); + detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1); linearGrade1 = detailsView1.findViewById(R.id.linear_grade1); imageGrade1 = detailsView1.findViewById(R.id.image_grade1); textGrade1 = detailsView1.findViewById(R.id.text_grade1); + textPkName1 = detailsView1.findViewById(R.id.text_pk_name1); imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); - livePushRyViewHolder.mPreView.addView(detailsView1); + livePushRyViewHolder.dr1_preview.addView(detailsView1); detailsLinearLayout1.setVisibility(View.VISIBLE); linearGrade1.setVisibility(View.GONE); + + + Log.e("ry", "多人接受成功" + uid); + ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success"); + } else if (drPkbeanList.size() == 2) { + String uid1 = String.valueOf(drPkbeanList.get(0).getId()); + String uid2 = String.valueOf(drPkbeanList.get(1).getId()); + //设置多人PK数据 + LiveNetManager.get(mContext).getLiveInfo(uid1, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveInfoModel data) { + if(detailsView2!=null){ + livePushRyViewHolder.dr2_preview.removeView(detailsView2); + } + detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2); + linearGrade2 = detailsView2.findViewById(R.id.linear_grade2); + textPkName2 = detailsView2.findViewById(R.id.text_pk_name2); + imageGrade2 = detailsView2.findViewById(R.id.image_grade2); + textGrade2 = detailsView2.findViewById(R.id.text_grade2); + imageGrade2.setTag(uid1); + textPkName2.setText(data.getUserNicename()); + livePushRyViewHolder.dr2_preview.addView(detailsView2); + detailsLinearLayout2.setVisibility(View.VISIBLE); + linearGrade2.setVisibility(View.GONE); + } + + @Override + public void onError(String error) { + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); + } + }); + + detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1); + linearGrade1 = detailsView1.findViewById(R.id.linear_grade1); + imageGrade1 = detailsView1.findViewById(R.id.image_grade1); + textGrade1 = detailsView1.findViewById(R.id.text_grade1); + textPkName1 = detailsView1.findViewById(R.id.text_pk_name1); + imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); + livePushRyViewHolder.dr1_preview.addView(detailsView1); + detailsLinearLayout1.setVisibility(View.VISIBLE); + linearGrade1.setVisibility(View.GONE); + + LiveNetManager.get(mContext).getLiveInfo(uid2, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveInfoModel data) { + if(detailsView4!=null){ + livePushRyViewHolder.dr4_preview.removeView(detailsView4); + } + detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4); + linearGrade4 = detailsView4.findViewById(R.id.linear_grade4); + textPkName4 = detailsView4.findViewById(R.id.text_pk_name4); + imageGrade4 = detailsView4.findViewById(R.id.image_grade4); + textGrade4 = detailsView4.findViewById(R.id.text_grade4); + imageGrade4.setTag(uid2); + textPkName4.setText(data.getUserNicename()); + livePushRyViewHolder.dr4_preview.addView(detailsView4); + detailsLinearLayout4.setVisibility(View.VISIBLE); + linearGrade4.setVisibility(View.GONE); + L.eSw("第三个主播的名称 数据加载完成"+detailsLinearLayout4.getVisibility()); + L.eSw("detailsLinearLayout4.getVisibility()"+detailsLinearLayout4.getVisibility()); + } + + @Override + public void onError(String error) { + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); + } + }); + ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success"); + } else if (drPkbeanList.size() == 3) { + String uid1 = String.valueOf(drPkbeanList.get(0).getId()); + String uid2 = String.valueOf(drPkbeanList.get(1).getId()); + String uid3 = String.valueOf(drPkbeanList.get(2).getId()); + //设置多人PK数据 + LiveNetManager.get(mContext).getLiveInfo(uid1, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveInfoModel data) { + if(detailsView2!=null){ + livePushRyViewHolder.dr2_preview.removeView(detailsView2); + } + detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2); + linearGrade2 = detailsView2.findViewById(R.id.linear_grade2); + textPkName2 = detailsView2.findViewById(R.id.text_pk_name2); + imageGrade2 = detailsView2.findViewById(R.id.image_grade2); + textGrade2 = detailsView2.findViewById(R.id.text_grade2); + imageGrade2.setTag(uid1); + textPkName2.setText(data.getUserNicename()); + livePushRyViewHolder.dr2_preview.addView(detailsView2); + detailsLinearLayout2.setVisibility(View.VISIBLE); + linearGrade2.setVisibility(View.GONE); + L.eSw("detailsLinearLayout2.getVisibility()"+detailsLinearLayout2.getVisibility()); + } + + @Override + public void onError(String error) { + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); + } + }); + + detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1); + linearGrade1 = detailsView1.findViewById(R.id.linear_grade1); + imageGrade1 = detailsView1.findViewById(R.id.image_grade1); + textGrade1 = detailsView1.findViewById(R.id.text_grade1); + textPkName1 = detailsView1.findViewById(R.id.text_pk_name1); + imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); + livePushRyViewHolder.dr1_preview.addView(detailsView1); + detailsLinearLayout1.setVisibility(View.VISIBLE); + linearGrade1.setVisibility(View.GONE); + + LiveNetManager.get(mContext).getLiveInfo(uid2, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveInfoModel data) { + if(detailsView2!=null){ + livePushRyViewHolder.dr3_preview.removeView(detailsView3); + } + detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3); + linearGrade3 = detailsView3.findViewById(R.id.linear_grade3); + textPkName3 = detailsView3.findViewById(R.id.text_pk_name3); + imageGrade3 = detailsView3.findViewById(R.id.image_grade3); + textGrade3 = detailsView3.findViewById(R.id.text_grade3); + imageGrade3.setTag(uid2); + textPkName3.setText(data.getUserNicename()); + livePushRyViewHolder.dr3_preview.addView(detailsView3); + detailsLinearLayout3.setVisibility(View.VISIBLE); + linearGrade3.setVisibility(View.GONE); + L.eSw("detailsLinearLayout3.getVisibility()"+detailsLinearLayout3.getVisibility()); + L.eSw("第三个主播的名称 数据加载完成"); + } + + @Override + public void onError(String error) { + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); + } + }); + LiveNetManager.get(mContext).getLiveInfo(uid3, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveInfoModel data) { + if(detailsView4!=null){ + livePushRyViewHolder.dr4_preview.removeView(detailsView4); + } + detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4); + linearGrade4 = detailsView4.findViewById(R.id.linear_grade4); + textPkName4 = detailsView4.findViewById(R.id.text_pk_name4); + imageGrade4 = detailsView4.findViewById(R.id.image_grade4); + textGrade4 = detailsView4.findViewById(R.id.text_grade4); + imageGrade4.setTag(uid3); + textPkName4.setText(data.getUserNicename()); + livePushRyViewHolder.dr4_preview.addView(detailsView4); + detailsLinearLayout4.setVisibility(View.VISIBLE); + linearGrade4.setVisibility(View.GONE); + L.eSw("detailsLinearLayout4.getVisibility()"+detailsLinearLayout4.getVisibility()); + L.eSw("第四个主播的名称 数据加载完成"); + } + + @Override + public void onError(String error) { + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); + } + }); + + Log.e("ry", "多人接受成功" + mApplyUid); + ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success"); + } - - //设置多人PK数据 - LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(LiveInfoModel data) { - 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(uid)); - textPkName2.setText(data.getUserNicename()); - livePushRyViewHolder.dr1_preview.addView(detailsView2); - detailsLinearLayout2.setVisibility(View.VISIBLE); - linearGrade2.setVisibility(View.GONE); - } - - @Override - public void onError(String error) { - ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); - } - }); - - Log.e("ry", "多人接受成功" + mApplyUid); - ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success"); - } - });*/ - } + } /** * 多人PK PK主播发过来的已经接受 @@ -2008,6 +2125,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { * 更新Pk分数 */ public void upDataPkScore(JSONArray pkScores, String uid, int time) { + L.eSw("更新Pk分数 upDataPkScore time:" + time + " " + pkScores); String userID1 = (String) imageGrade1.getTag(); String userID2 = (String) imageGrade2.getTag(); String userID4 = (String) imageGrade4.getTag(); @@ -2025,7 +2143,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1)); mHandler.sendEmptyMessage(WHAT_PK_TIME2); } - } int pkScoreSize = pkScores.size(); if (pkScoreSize == 3) { 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 4705298e8..f24cfaa6f 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -312,6 +312,7 @@ public class SocketRyClient { UserBean u = new UserBean(); // u.setUserNiceName(map.getString("uname")); u.setId(map.getString("uid")); + L.eSw("action3 == 2:"+u.getId()); mListener.onLinkDRMicPkApplyOk(u); } else if (action3 == 6) {//开始Pk if (LiveRoomViewHolder.mHandler != null) { @@ -334,7 +335,6 @@ public class SocketRyClient { } else { // LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview(); Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW)); - } //創建了多人房間 } else if (action3 == 3) { diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java index 4dc373b50..a379ef3e7 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java @@ -11,15 +11,25 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.RelativeLayout; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; import com.tencent.live2.V2TXLiveDef; import com.tencent.live2.V2TXLivePlayer; import com.tencent.live2.impl.V2TXLivePlayerImpl; import com.tencent.rtmp.ui.TXCloudVideoView; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.HttpClient; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.live.R; +import com.yunbao.live.bean.DrPkbean; + +import java.util.ArrayList; +import java.util.List; /** * Created by cxf on 2018/10/10. @@ -48,7 +58,6 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder { public static int landscape; //1h 2s public static Context contexts; - int screenWidth; // 屏幕宽(像素,如:480px) int screenHeight; // 屏幕高(像素,如:800p) @@ -254,6 +263,10 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder { } } + @Override + public void setDrMicInfo(UserBean u) { + } + @Override public void setLiveBeanLandscape(int landscape) { LivePlayKsyViewHolder.landscape =landscape; 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 d9f6c0793..9ec0ac5e7 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -19,13 +19,16 @@ import android.view.ViewGroup; import android.view.ViewParent; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; +import com.alibaba.fastjson.JSONObject; import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.ui.StyledPlayerView; import com.google.android.exoplayer2.video.VideoSize; +import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BasePopupView; import com.lxj.xpopup.interfaces.XPopupCallback; @@ -33,6 +36,7 @@ import com.lzf.easyfloat.EasyFloat; import com.lzy.okserver.OkDownload; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.bean.EnterRoomNewModel; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.LiveFontSizeSettingDialog; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; @@ -51,6 +55,7 @@ import com.yunbao.common.views.LiveClarityCustomPopup; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.bean.DrPkbean; import com.yunbao.live.event.LiveAudienceEvent; import org.greenrobot.eventbus.EventBus; @@ -130,6 +135,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { SWAuManager swAuManager; String liveUid; + private LinearLayout dr_pk_view; + private FrameLayout dr1_preview; + private FrameLayout dr2_preview; + private FrameLayout dr3_preview; + private FrameLayout dr4_preview; + public int getLandscape() { return landscape; } @@ -175,6 +186,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { debugView = new TextView(mContext); debugView.setBackgroundColor(Color.WHITE); + + dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view); + dr1_preview = (FrameLayout) findViewById(R.id.dr1_preview); + dr2_preview = (FrameLayout) findViewById(R.id.dr2_preview); + dr3_preview = (FrameLayout) findViewById(R.id.dr3_preview); + dr4_preview = (FrameLayout) findViewById(R.id.dr4_preview); + dr_pk_view.setVisibility(View.GONE); } public void initSwEngine(String liveUid) { @@ -188,6 +206,80 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(liveUid)); } + /** + * 开启单人PK + * @param Uid + */ + public void setPkView(String Uid) { + swAuManager.updateMyChannelView((FrameLayout) mLeftContainer, Integer.parseInt(liveUid)); + ry_view.removeAllViews(); + //加入对方主播房间 + swAuManager.setPkContainer1((FrameLayout) mRightContainer); + swAuManager.joinExRoomEx(Integer.parseInt(Uid), CommonAppConfig.SWToken, SWAuManager.getChannelName(Uid)); + } + List drMicUserList = new ArrayList<>(); + +boolean isAdd = true; + + @Override + public void setDrMicInfo(UserBean u) { + L.eSw("setDrMicInfo:"+u.getId()+" drMicUserList:"+new Gson().toJson(drMicUserList)); + for (int i = 0; i drPkbeanList){ + for (int i = 0; i f4 f4->f3 - dr3_preview.removeAllViews(); - swManager.updateDrChannelView(dr3_preview,SWAuManager.getChannelName(drpkUid3),drpkUid3); + //先退出这个主播的直播间,在进入该直播间,(视图问题暂时找不到解决方案) + swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),drpkUid3); + swManager.joinChannelDrEx(dr3_preview,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3)); - dr4_preview.removeAllViews(); frameLayout = dr4_preview; break; } @@ -635,18 +643,23 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX mBigContainer.removeAllViews(); } swManager.joinChannelDrEx(frameLayout,CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid)); - btn_close.setVisibility(View.VISIBLE); dr_pk_view.setVisibility(View.VISIBLE); currentPosition = temp; } + return currentPosition; } + public void anchorClose(){ + swManager.updateMyChannelView((FrameLayout) mBigContainer); //用户主动断开连麦再退出画面 + } public void onLinkMicAnchorClose() { - swManager.updateMyChannelView((FrameLayout) mBigContainer); - LivePushRyViewHolder.btn_close.setVisibility(View.GONE); + //swManager.updateMyChannelView((FrameLayout) mBigContainer); 用户主动断开连麦再退出画面 + //LivePushRyViewHolder.btn_close.setVisibility(View.GONE); } + + public void onLinkDRMicPkApply(UserBean userBean) { if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java index 440030882..0cbe9709e 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java @@ -6,6 +6,7 @@ import android.view.ViewGroup; import com.alibaba.fastjson.JSONArray; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.AbsViewHolder; import com.yunbao.live.interfaces.ILiveLinkMicViewHolder; @@ -70,6 +71,8 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL public abstract void setPkEndview(); + public abstract void setDrMicInfo(UserBean u); + public abstract void setLiveBeanLandscape(int landscape); public void setLiveBean(LiveBean data) { @@ -79,6 +82,17 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL public void setViewUP(int i) { } + public void setViewPkMic(int uid) { + } + + public void setViewPk() { + } + + public void setViewDrMic() { + } + public void setViewDrPk() { + } + public OnMicCallback getOnMicCallback() { return onMicCallback; } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 9554d80c4..57698f5dc 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -73,6 +73,7 @@ import com.yunbao.common.manager.OpenAdManager; import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.L; import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.RandomUtil; import com.yunbao.common.utils.RouteUtil; @@ -84,6 +85,7 @@ import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.bean.DrPkbean; import com.yunbao.live.bean.LiveBuyGuardMsgBean; import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.bean.LiveDanMuBean; @@ -150,7 +152,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //侧滑布局 // private DrawerLayout drawerLayout; //直播间拆分布局 - private LivePlayRyViewHolder mLivePlayViewHolder; + public LivePlayRyViewHolder mLivePlayViewHolder; //头部布局 public LiveRoomViewHolder mLiveRoomViewHolder; //底部布局 @@ -641,16 +643,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } if (mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) { - - mLivePlayViewHolder.setViewUP(1); - + //mLivePlayViewHolder.setViewUP(1); + mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid()); } if (mLiveRoomViewHolder != null) { mLiveRoomViewHolder.pkHandler = false; } if (mLivePlayViewHolder != null && pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了 - mLivePlayViewHolder.setViewUP(2); + mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid()); //pk排名数据 LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class); @@ -662,7 +663,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe if (mLiveRoomViewHolder != null && pkInfo != null && pkInfo.containsKey("pkuid") && pkInfo.containsKey("pkuimg") && pkInfo.containsKey("pkuname")) { mLiveRoomViewHolder.setOtherInfo(pkInfo.getString("pkuid"), pkInfo.getString("pkuimg"), pkInfo.getString("pkuname")); } - } }; linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000); @@ -676,7 +676,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.initPkRank(null); } if (mLivePlayViewHolder != null) { - mLivePlayViewHolder.setViewUP(3); + //mLivePlayViewHolder.setViewUP(3); + mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid()); } //pk排名数据 @@ -693,7 +694,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.initPkRank(null); } if (mLivePlayViewHolder != null) { - mLivePlayViewHolder.setViewUP(4); + JSONArray array = pkInfo.getJSONArray("userlist"); + for (int j = 0; j < array.size(); j++) { + UserBean drPkbean = new UserBean(); + JSONObject da = array.getJSONObject(j); + drPkbean.setId(String.valueOf(da.getIntValue("id"))); + mLivePlayViewHolder.setDrMicInfo(drPkbean); + } } upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time")); @@ -1561,7 +1568,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onLinkDRMicPkApplyOk(UserBean u) { - + L.eSw("onLinkDRMicPkApplyOk(UserBean u)PortraitLiveManager"); + mLivePlayViewHolder.setDrMicInfo(u); } @@ -1627,6 +1635,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } if (mLiveRoomViewHolder != null) { mLivePlayViewHolder.setLiveBeanLandscape(landscape); + mLivePlayViewHolder.endpk(mPkUid); } if (mContext instanceof LiveAudienceActivity) { ((LiveAudienceActivity) mContext).setPkStatus(false); @@ -2153,6 +2162,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe * @param time */ public void upDataPkScore(JSONArray pkScores, int time) { + if (mLiveRoomViewHolder != null) { String liveId = mLiveBean.getUid(); JSONObject liveModel = null; 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 5830a365b..7cbf9004a 100644 --- a/live/src/main/res/layout/view_live_play_ksy.xml +++ b/live/src/main/res/layout/view_live_play_ksy.xml @@ -1,6 +1,7 @@ + + + + + + + + + + + + + + + + + + + android:visibility="gone"> - - + />