streams = new ArrayList<>();
- streams.add(RCRTCEngine.getInstance().getDefaultVideoStream());
- 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 = 960;
- int height = 720;
- normal.setWidth(width); //视频宽
- normal.setHeight(height); //视频高
- normal.setFps(fps); //视频帧率
-
- //1. 设置自适应合流布局模式
- config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
- //2. 合流画布设置
- rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "混成功14");
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", "混失败" + errorCode);
-
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.i("ry", "订阅资源失败: " + rtcErrorCode);
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
- });
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", mApplyUid + "加入其他房间失败 :" + rtcErrorCode);
- Log.i("ry", mApplyUid + "加入其他房间失败 :" + rtcErrorCode);
- }
- });
-
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.UN_LEAVELIVE));
- LiveRyAnchorActivity.isDRPK = 1;
- LivePushRyViewHolder.btn_close.setVisibility(View.VISIBLE);
- SocketRyLinkMicPkUtil.linkMicPkAccept(mSocketRyClient, mApplyUid, mApplyUrl, mApplyNmae);
- EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UP_PK_TWO).setObject(mApplyUid));
- onLinkMicPkStart(mApplyUid, 2);
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- ToastUtil.show("接受失败");
- }
- });
-
- }
-
- @Override
- protected void onDRPkApply(UserBean u) {
- HttpClient.getInstance().get("xiugaizhiboxinxi", "xiugaizhiboxinxi")
- .params("uid", CommonAppConfig.getInstance().getUid())
- .params("pkuid", u.getId())
- .params("type", "1")
- .params("sign", "1")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msgs, String[] info) {
- if (code == 0) {
- Log.i("多人PK", "1code = " + code + ", msgs = " + msgs + ", info = " + Arrays.deepToString(info) + " mApplyUid = " + mApplyUid);
- HttpClient.getInstance().get("live.getdrnum", "live.getdrnum")
- .execute(new HttpCallback() {
-
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- Log.i(TAG, "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
- if (info.length > 0) {
-
- JSONObject datas = JSONObject.parseObject(info[0]);
- boolean agree = true;
- if (datas.getIntValue("pk_num_day") <= 0) {
- ToastUtil.show("多人PK次数已用完");
- 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() {
-
- @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);
-
- RongcloudIMManager.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) {
-
- }
- });
- }
- }
- }
- //收起整蛊列表
- if(mLiveRoomViewHolder!=null){
- mLiveRoomViewHolder.closePrankView();
- }
- }
- });
- }
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- ToastUtil.show("接受失败");
- }
- });
- } else {
- ToastUtil.show(msg);
- }
- }
-
- });
-
-
- }
- }
- });
-
- /*LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0 && info.length > 0) {
- JSONObject obj = JSON.parseObject(info[0]);
- if (obj != null) {
- if (obj.getString("ispk").equals("0")) {
-
-
- }else{
- ToastUtil.show(mContext.getString(R.string.pking_over));
- }
- }
- }
- }});*/
- }
-
- @Override
- protected void onDRPkTimeout(UserBean u) {
- IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- final SocketSendBean msg1 = new SocketSendBean()
- .param("_method_", SOCKET_LINK_MIC_PK)
- .param("action", 8);
- msg1.create();
-
- String targetId = u.getId();
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
-
- RongcloudIMManager.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", "发送失敗" + mApplyUid);
- }
- });
- }
- });
- }
-
- @Override
- protected void onDRPkRefuse(UserBean u) {
- IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- final SocketSendBean msg1 = new SocketSendBean()
- .param("_method_", SOCKET_LINK_MIC_PK)
- .param("action", 3);
- msg1.create();
-
- String targetId = u.getId();
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
-
- RongcloudIMManager.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", "发送失敗");
- }
- });
- }
- });
- }
-
- @Override
- protected void onPkApply(UserBean u) {
- LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0 && info.length > 0) {
- JSONObject obj = JSON.parseObject(info[0]);
- if (obj != null) {
- if (obj.getString("ispk").equals("0")) {
- isPKTmp(u);
- } else {
- ToastUtil.show(mContext.getString(R.string.pking_over));
- }
- }
- }
- }
- });
- }
-
- @Override
- protected void onPkTimeout(UserBean u) {
- rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- final SocketSendBean msg1 = new SocketSendBean()
- .param("_method_", SOCKET_LINK_MIC_PK)
- .param("action", 8);
- msg1.create();
-
- String targetId = u.getId();
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
-
- RongcloudIMManager.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", "发送失敗" + u.getId());
- }
- });
- }
- });
- }
-
- @Override
- protected void onPkRefuse(UserBean u) {
- onPkTimeoutTmp(u);
- }
-
- //与用户连麦
- public void setUserMic(String liveid) {
- JSONObject msg1 = new JSONObject();
- msg1.put("uid", CommonAppConfig.getInstance().getUid());
- msg1.put("pkuid", CommonAppConfig.getInstance().getUid());
- msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatarThumb());
- msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
-
- rtcRoom.getLocalUser().responseJoinOtherRoom(liveid, liveid, true, true, msg1.toString(), new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- RCRTCEngine.getInstance().joinOtherRoom(liveid, new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) {
- rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener);
- ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
- Log.e("ry", liveid + "来了!!!!" + rcrtcOtherRoom.getRemoteUsers().size());
- for (int i = 0; i < rcrtcOtherRoom.getRemoteUsers().size(); i++) {
- //遍历远端用户发布的资源列表
- for (RCRTCInputStream stream : rcrtcOtherRoom.getRemoteUsers().get(i).getStreams()) {
- Log.e("ry", stream.getMediaType() + "rcrtcOtherRoom成功 :" + rcrtcOtherRoom.getRemoteUsers().size());
- if (stream.getMediaType() == RCRTCMediaType.AUDIO) {
- //音频只需要订阅
- inputStreamList.add(stream);
- }
- }
- }
-
- Log.e("ry", "asa" + inputStreamList.size());
- //开始订阅资源
- rtcRoom.getLocalUser().subscribeStreams(inputStreamList, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
-
-
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", "订阅资源失败: " + rtcErrorCode);
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
- });
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", liveid + "加入其他房间失败 :" + rtcErrorCode);
- Log.i("ry", liveid + "加入其他房间失败 :" + rtcErrorCode);
- }
- });
-
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- ToastUtil.show("接受失败");
- }
- });
- }
-
- /**
- * 显示申请PK的弹窗
- */
- @Override
- protected void showApplyDialog(UserBean u) {
- mIsApplyDialogShow = true;
- mAcceptPk = false;
- View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null);
- mLinkMicWaitProgress = v.findViewById(R.id.pk_wait_progress);
- v.findViewById(R.id.btn_refuse).setOnClickListener(this);
- v.findViewById(R.id.btn_accept).setOnClickListener(this);
- mPkWaitCount = LINK_MIC_COUNT_MAX;
- mPkPopWindow = new PopupWindow(v, DpUtil.dp2px(280), ViewGroup.LayoutParams.WRAP_CONTENT, true);
- mPkPopWindow.setBackgroundDrawable(new ColorDrawable());
- mPkPopWindow.setOutsideTouchable(true);
- mPkPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- if (mHandler != null) {
- mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
- }
- if (mAcceptPk) {
- onPkApplyTmp(u);
- } else {
- if (mPkWaitCount < 0) {
- onPkTimeoutTmp(u);
-
- }
- mApplyUid = null;
- mApplyStream = null;
- }
- mIsApplyDialogShow = false;
- mLinkMicWaitProgress = null;
- mPkPopWindow = null;
- }
- });
- mPkPopWindow.showAtLocation(mRoot, Gravity.CENTER, 0, 0);
- if (mHandler != null) {
- mHandler.sendEmptyMessageAtTime(WHAT_PK_WAIT_RECEIVE, getNextSecondTime());
- }
- }
-
-
- public static Bitmap fromText(float textSize, String text) {
- Paint paint = new Paint();
- paint.setTextSize(textSize);
- paint.setTextAlign(Paint.Align.LEFT);
- paint.setColor(Color.BLACK);
-
- Paint.FontMetricsInt fm = paint.getFontMetricsInt();
- int width = (int) paint.measureText(text);
- int height = fm.descent - fm.ascent;
-
- Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- canvas.drawText(text, 0, fm.leading - fm.ascent, paint);
- canvas.save();
-
- return bitmap;
- }
-
- private String TAG = "多人PK";
-
- /**
- * 退出多人PK
- */
- public void leaveDRRoom() {
- //清理PK上面对方的头像
- EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
- Log.e("ry", "退出多人OKKK" + inputStreamList.size());
- isDRPK = 0;
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (btn_close != null) {
- btn_close.setVisibility(View.GONE);
- }
- }
- });
-
- 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);
-
- }
-
- private Handler leaveHandler = new Handler(Looper.getMainLooper());
- private Runnable leaveRunnable = new Runnable() {
- @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.dr3_preview.removeAllViews();
- livePushRyViewHolder.cameraPreview3.removeAllViews();
- leaveHandler.removeCallbacks(leaveRunnable);
- livePushRyViewHolder.timeTitle.setVisibility(View.GONE);
- livePushRyViewHolder.mPreView.removeView(detailsView1);
- livePushRyViewHolder.cameraPreview3.setVisibility(View.GONE);
- }
- };
-
- /**
- * 随机PK拒绝对话框
- */
- @Override
- protected void showPkDialog(UserBean u) {
- new DialogUitl.Builder(mContext)
- .setHtmlCode(Html.fromHtml(
- "有人向您发起PK请求。
" +
- "若拒绝PK,将会10分钟内不会再收到任何随机PK请求。"
- ))
- .setConfirmString("接受")
- .setCancelString("拒絕")
- .setView(R.layout.dialog_live_random_pk)
- .setSimpleCallbackView(new DialogUitl.SimpleCallbackView() {
- boolean clickCancel = false;
- String titleVal;
- TimerTask task;
-
- @Override
- public void onShow(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
- task = new TimerTask() {
- int time = 11;
- final Handler handler = new Handler(Looper.getMainLooper());
-
- @Override
- public void run() {
- if (titleVal == null) {
- titleVal = ((TextView) title).getText().toString();
- }
- handler.post(() -> ((TextView) title).setText(titleVal + " " + time));
- if (time-- == 0) {
- handler.post(() -> showClose(dialog, title, context, confirmBtn, cancelBtn));
- cancel();
- }
- }
- };
- new Timer().schedule(task, 1000, 1000);
- }
-
- @Override
- public void onConfirmClick(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
- dialog.dismiss();
- task.cancel();
- apply();
- }
-
- @Override
- public void onCancel(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
- if (!clickCancel) {
- titleVal = "拒絕PK提示";
- ((TextView) context).setText(Html.fromHtml(
- "若拒絕PK,將會關閉你的隨機PK開關。" +
- "並且10分鍾不會收到任何隨機PK請求。"
- ));
- ((TextView) cancelBtn).setText("堅持拒絕");
- clickCancel = true;
- return;
- }
- showClose(dialog, title, context, confirmBtn, cancelBtn);
- }
-
- void showClose(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
- task.cancel();
- String title1="您因拒絕隨機PK,被限制關閉中";
- String content="隨機PK可打開時間:";
- if(!WordUtil.isNewZh()){
- title1="Can't start a PK for now due to the earlier rejection of other pk";
- content="Available again at:";
- }
- ((TextView) title).setText(title1);
- ((TextView) confirmBtn).setText(WordUtil.isNewZh()?"确定":"Sure");
- ((TextView) context).setText(content + new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(new Date(System.currentTimeMillis() + 7200000)));//7200000ms=120m=2h
- ((TextView) context).setTextSize(12);
- ((TextView) context).setTextColor(Color.parseColor("#999999"));
- refusePk(u);
- cancelBtn.setVisibility(View.GONE);
- confirmBtn.setOnClickListener(v -> {
- dialog.dismiss();
- });
- }
-
-
- void apply() {
- isPKTmp(u);
- }
- })
- .build().show();
- }
-
- private void refusePk(UserBean u) {
- IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- final SocketSendBean msg1 = new SocketSendBean()
- .param("_method_", SOCKET_LINK_MIC_PK)
- // .param("randomPk",u.isRandomPk()+"")
- .param("action", 3);
- msg1.create();
-
- String targetId = u.getId();
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
-
- RongcloudIMManager.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", "发送失敗" + u.getId());
- }
- });
- }
- });
-
- LiveNetManager.get(mContext).setBanRandomPK(null);
- }
-
- /**
- * 显示申请多人PK的弹窗
- */
- @Override
- protected void showDRApplyDialog(UserBean u) {
- mApplyUid = u.getId();
- mIsApplyDialogShow = true;
- mAcceptPk = false;
- View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null);
- mLinkMicWaitProgress = v.findViewById(R.id.pk_wait_progress);
- v.findViewById(R.id.btn_refuse).setOnClickListener(this);
- v.findViewById(R.id.btn_accept).setOnClickListener(this);
- mPkWaitCount = LINK_MIC_COUNT_MAX;
- mPkPopWindow = new PopupWindow(v, DpUtil.dp2px(280), ViewGroup.LayoutParams.WRAP_CONTENT, true);
- mPkPopWindow.setBackgroundDrawable(new ColorDrawable());
- mPkPopWindow.setOutsideTouchable(true);
- mPkPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- if (mHandler != null) {
- mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
- }
- if (mAcceptPk) {
- onDRPkApplyTmp(u);
-
- } else {
- if (mPkWaitCount < 0) {
- onDRPkTimeoutTmp(u);
-
- } else {
- onDRPkRefuseTmp(u);
- }
- mApplyUid = null;
- mApplyStream = null;
- }
- mIsApplyDialogShow = false;
- mLinkMicWaitProgress = null;
- mPkPopWindow = null;
- }
- });
- mPkPopWindow.showAtLocation(mRoot, Gravity.CENTER, 0, 0);
- if (mHandler != null) {
- mHandler.sendEmptyMessageAtTime(WHAT_PK_WAIT_RECEIVE, getNextSecondTime());
- }
- }
-
-
- //多人PK接受申请画 加入副房间
- public void dRjoinOtherRoom(String uid, int i) {
- Log.e("ry", uid + "洒洒" + i + "VVVV" + i);
- mApplyUid = uid;
- RCRTCEngine.getInstance().joinOtherRoom(mApplyUid, new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) {
- rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener);
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
- //把多人PK的View显示出来
- if (livePushRyViewHolder.dr_pk_view.getVisibility() == View.GONE) {
- ScreenDimenUtil util = ScreenDimenUtil.getInstance();
- int mScreenWdith = util.getScreenWdith();
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
- params.weight = 1;
- params.topMargin = DpUtil.dp2px(123);
- livePushRyViewHolder.dr_pk_view.setLayoutParams(params);
- livePushRyViewHolder.camera.setLayoutParams(params);
- 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);
- 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);
- imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
- livePushRyViewHolder.mPreView.addView(detailsView1);
- detailsLinearLayout1.setVisibility(View.VISIBLE);
- linearGrade1.setVisibility(View.GONE);
- }
-
- Log.e("ry", "多人接受成功" + mApplyUid);
- ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
- //遍历远端用户列表
- for (int i = 0; i < rcrtcOtherRoom.getRemoteUsers().size(); i++) {
- Log.e("ry", rcrtcOtherRoom.getRemoteUsers().get(i).getUserId() + "收到rcrtcOtherRoom" + rcrtcOtherRoom.getRemoteUsers().size());
- //遍历远端用户发布的资源列表
- for (RCRTCInputStream stream : rcrtcOtherRoom.getRemoteUsers().get(i).getStreams()) {
- Log.e("ry", i + "收到" + stream.getMediaType() + "实打实打算" + rcrtcOtherRoom.getRemoteUsers().get(i).getUserId());
- if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
- if (inputStreamList.size() == 0) {
- livePushRyViewHolder.dr1_preview.setVisibility(View.VISIBLE);
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(mContext);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- //todo 本demo只演示添加1个远端用户的视图
- livePushRyViewHolder.dr1_preview.removeAllViews();
- remoteView.setScalingType(SCALE_ASPECT_FILL);
- livePushRyViewHolder.dr1_preview.addView(remoteView);
-
-
- 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");
- }
- });
-
- } else if (inputStreamList.size() == 1) {
- livePushRyViewHolder.dr3_preview.setVisibility(View.VISIBLE);
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(mContext);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- //todo 本demo只演示添加1个远端用户的视图
- livePushRyViewHolder.dr3_preview.removeAllViews();
- remoteView.setScalingType(SCALE_ASPECT_FILL);
- livePushRyViewHolder.dr3_preview.addView(remoteView);
- LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(LiveInfoModel data) {
- 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(uid);
- textPkName4.setText(data.getUserNicename());
- livePushRyViewHolder.dr3_preview.addView(detailsView4);
- detailsLinearLayout4.setVisibility(View.VISIBLE);
- linearGrade4.setVisibility(View.GONE);
- }
-
- @Override
- public void onError(String error) {
-
- }
- });
- } else if (inputStreamList.size() == 2) {
- livePushRyViewHolder.cameraPreview3.setVisibility(View.VISIBLE);
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(mContext);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- //todo 本demo只演示添加1个远端用户的视图
- livePushRyViewHolder.cameraPreview3.removeAllViews();
- remoteView.setScalingType(SCALE_ASPECT_FILL);
- livePushRyViewHolder.cameraPreview3.addView(remoteView);
-
- LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(LiveInfoModel data) {
- 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(uid);
- textPkName3.setText(data.getUserNicename());
- livePushRyViewHolder.cameraPreview3.addView(detailsView3);
- detailsLinearLayout3.setVisibility(View.VISIBLE);
- linearGrade3.setVisibility(View.GONE);
- }
-
- @Override
- public void onError(String error) {
-
- }
- });
- }
- inputStreamList.add(stream);
- }
- inputStreamList1.add(stream);
- }
- }
- //开始订阅资源
- rtcRoom.getLocalUser().subscribeStreams(inputStreamList1, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.i("ry", "订阅资源成功");
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.i("ry", "订阅资源失败: " + rtcErrorCode.getReason());
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
- });
- //2. 合流画布设置
- rcrtcLiveInfo.setMixConfig(create_Custom_MixConfig(false, inputStreamList), new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "222混成功");
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", "混失败" + errorCode);
-
- }
- });
- //收起整蛊列表
- if(mLiveRoomViewHolder!=null){
- mLiveRoomViewHolder.closePrankView();
- }
-
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", mApplyUid + "加入其他房间失败 :" + rtcErrorCode);
- Log.i("ry", mApplyUid + "加入其他房间失败 :" + rtcErrorCode);
- }
- });
- }
-
- /**
- * 多人PK PK主播发过来的已经接受
- */
- public void onDRLinkMicToPk(String u) {
- Log.e("eve", u + "");
- /**
- * 加入副房间
- *
- * 前提必须已经 通过 {@link RCRTCEngine#joinRoom(String, RCRTCRoomType, IRCRTCResultDataCallback)} 或 {@link RCRTCEngine#joinRoom(String, IRCRTCResultDataCallback)} 加入了主房间
- *
- * @param roomId 房间 ID ,长度 64 个字符,可包含:`A-Z`、`a-z`、`0-9`、`+`、`=`、`-`、`_`
- * @param callBack 加入房间回调
- * @group 房间管理
- */
-
- RCRTCEngine.getInstance().joinOtherRoom(u, new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) {
- rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener);
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
-
- if (livePushRyViewHolder.dr_pk_view.getVisibility() == View.GONE) {
- ScreenDimenUtil util = ScreenDimenUtil.getInstance();
- int mScreenWdith = util.getScreenWdith();
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
- params.weight = 1;
- params.topMargin = DpUtil.dp2px(123);
- livePushRyViewHolder.dr_pk_view.setLayoutParams(params);
- livePushRyViewHolder.camera.setLayoutParams(params);
- 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);
- 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);
- imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
- livePushRyViewHolder.mPreView.addView(detailsView1);
- detailsLinearLayout1.setVisibility(View.VISIBLE);
- linearGrade1.setVisibility(View.GONE);
- }
-
- //遍历远端用户列表
- for (int i = 0; i < rcrtcOtherRoom.getRemoteUsers().size(); i++) {
- //遍历远端用户发布的资源列表
- for (RCRTCInputStream stream : rcrtcOtherRoom.getRemoteUsers().get(i).getStreams()) {
- Log.e("ry111", stream.getMediaType() + "");
- if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
- if (inputStreamList.size() == 0) {
- livePushRyViewHolder.dr1_preview.setVisibility(View.VISIBLE);
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- //todo 本demo只演示添加1个远端用户的视图
- livePushRyViewHolder.dr1_preview.removeAllViews();
- remoteView.setScalingType(SCALE_ASPECT_FILL);
- livePushRyViewHolder.dr1_preview.addView(remoteView);
- LiveNetManager.get(mContext).getLiveInfo(u, 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(u));
- textPkName2.setText(data.getUserNicename());
- livePushRyViewHolder.dr1_preview.addView(detailsView2);
- detailsLinearLayout2.setVisibility(View.VISIBLE);
- linearGrade2.setVisibility(View.GONE);
- }
-
- @Override
- public void onError(String error) {
-
- }
- });
- } else if (inputStreamList.size() == 1) {
- livePushRyViewHolder.dr3_preview.setVisibility(View.VISIBLE);
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- //todo 本demo只演示添加1个远端用户的视图
- livePushRyViewHolder.dr3_preview.removeAllViews();
- remoteView.setScalingType(SCALE_ASPECT_FILL);
- livePushRyViewHolder.dr3_preview.addView(remoteView);
- LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(LiveInfoModel data) {
- 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(u);
- textPkName4.setText(data.getUserNicename());
- livePushRyViewHolder.dr3_preview.addView(detailsView4);
- detailsLinearLayout4.setVisibility(View.VISIBLE);
- linearGrade4.setVisibility(View.GONE);
- }
-
- @Override
- public void onError(String error) {
-
- }
- });
- } else if (inputStreamList.size() == 2) {
- livePushRyViewHolder.cameraPreview3.setVisibility(View.VISIBLE);
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- //todo 本demo只演示添加1个远端用户的视图
- livePushRyViewHolder.cameraPreview3.removeAllViews();
- remoteView.setScalingType(SCALE_ASPECT_FILL);
- livePushRyViewHolder.cameraPreview3.addView(remoteView);
-
- LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(LiveInfoModel data) {
- 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(u);
- textPkName3.setText(data.getUserNicename());
- livePushRyViewHolder.cameraPreview3.addView(detailsView3);
- detailsLinearLayout3.setVisibility(View.VISIBLE);
- linearGrade3.setVisibility(View.GONE);
- }
-
- @Override
- public void onError(String error) {
-
- }
- });
- }
- inputStreamList.add(stream);
-
- }
- inputStreamList1.add(stream);
-
-
- }
-
- //开始订阅资源
- rtcRoom.getLocalUser().subscribeStreams(inputStreamList1, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.i("ry", "订阅资源成功");
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.i("ry", "订阅资源失败: " + rtcErrorCode.getReason());
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
- });
-
- //2. 合流画布设置
- rcrtcLiveInfo.setMixConfig(create_Custom_MixConfig(false, inputStreamList), new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", inputStreamList.size() + "混成功" + u);
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", "混失败" + errorCode);
-
- }
- });
- }
-
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.i("ry", "加入其他房间失败 :" + rtcErrorCode.getReason());
- }
- });
-
- }
-
-
- /**
- * 创建自定义合流布局配置
- *
- * @param isCrop 是否裁减画布
- * @param streams 必须为视频流列表
- * @return
- */
- private RCRTCMixConfig create_Custom_MixConfig(boolean isCrop, List streams) {
- Log.e("视频合流", streams.toString());
- Log.e("视频合流", "视频长度:" + streams.size());
- RCRTCMixConfig config = new RCRTCMixConfig();
- //1. 设置自定义合流布局模式
- config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.CUSTOM);
- 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 = 960;
- int height = 720;
- normal.setWidth(width); //视频宽
- normal.setHeight(height); //视频高
- normal.setFps(fps); //视频帧率
-
- //2. 合流画布设置
- //(请参照画布和声音配置示例代码)
- //3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准),设置每个视频流小窗口的坐标及宽高
- ArrayList list = new ArrayList<>();
-
- if (streams.size() == 1) {
- //user1的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video
- videoLayout1.setX(0); //X 坐标
- videoLayout1.setY(0); //Y 坐标
- videoLayout1.setWidth(480); // 视频窗口的宽
- videoLayout1.setHeight(720); // 视频窗口的高
- list.add(videoLayout1);
-
- //user2的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video
- videoLayout2.setX(480); //X 坐标
- videoLayout2.setY(0); //Y 坐标
- videoLayout2.setWidth(480); // 视频窗口的宽
- videoLayout2.setHeight(720); // 视频窗口的高
- list.add(videoLayout2);
-
- } else if (streams.size() == 2) {
- //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(480); // 视频窗口的宽
- videoLayout1.setHeight(720); // 视频窗口的高
-
- //user2的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video
- videoLayout2.setX(480); //X 坐标
- videoLayout2.setY(0); //Y 坐标
- videoLayout2.setWidth(480); // 视频窗口的宽
- videoLayout2.setHeight(360); // 视频窗口的高
- list.add(videoLayout2);
-
- //user3的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout3 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout3.setVideoStream(streams.get(1)); // RCRTCStream#MediaType 必须是Video
- videoLayout3.setX(480); //X 坐标
- videoLayout3.setY(360); //Y 坐标
- videoLayout3.setWidth(480); // 视频窗口的宽
- videoLayout3.setHeight(360); // 视频窗口的高
- list.add(videoLayout3);
-
- } else if (streams.size() == 3) {
- //user1的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video
- videoLayout1.setX(0); //X 坐标
- videoLayout1.setY(0); //Y 坐标
- videoLayout1.setWidth(480); // 视频窗口的宽
- videoLayout1.setHeight(720); // 视频窗口的高
- list.add(videoLayout1);
-
- //user2的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video
- videoLayout2.setX(480); //X 坐标
- videoLayout2.setY(0); //Y 坐标
- videoLayout2.setWidth(480); // 视频窗口的宽
- videoLayout2.setHeight(360); // 视频窗口的高
- list.add(videoLayout2);
-
- //user3的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout3 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout3.setVideoStream(streams.get(1)); // RCRTCStream#MediaType 必须是Video
- videoLayout3.setX(480); //X 坐标
- videoLayout3.setY(360); //Y 坐标
- videoLayout3.setWidth(480); // 视频窗口的宽
- videoLayout3.setHeight(360); // 视频窗口的高
- list.add(videoLayout3);
-
- //user3的视频流
- RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout4 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
- videoLayout4.setVideoStream(streams.get(2)); // RCRTCStream#MediaType 必须是Video
- videoLayout4.setX(0); //X 坐标
- videoLayout4.setY(360); //Y 坐标
- videoLayout4.setWidth(480); // 视频窗口的宽
- videoLayout4.setHeight(360); // 视频窗口的高
- list.add(videoLayout4);
- }
- config.setCustomLayouts(list);
- return config;
- }
-
- @Override
- public void onClick(View v) {
- int i = v.getId();
- if (i == R.id.btn_refuse) {
- refuseLinkMic();
-
- } else if (i == R.id.btn_accept) {
- acceptLinkMic();
-
- }
- }
-
- /**
- * 拒绝PK
- */
- private void refuseLinkMic() {
- if (mPkPopWindow != null) {
- mPkPopWindow.dismiss();
- }
- }
-
- /**
- * 接受PK
- */
- private void acceptLinkMic() {
- mAcceptPk = true;
- if (mPkPopWindow != null) {
- mPkPopWindow.dismiss();
- }
- }
-
- /**
- * pk 进度发送变化
- *
- * @param leftGift
- * @param rightGift
- */
- public void onPkProgressChanged(long leftGift, long rightGift, LivePKUserListBean bean) {
- if (mLiveLinkMicPkViewHolder != null) {
- mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean);
- }
- }
-
- /**
- * 进房间的时候PK开始
- */
- public void onEnterRoomPkStart(String pkUid, long leftGift, long rightGift, int pkTime, LivePKUserListBean bean) {
- mIsPk = true;
- mIsPkEnd = false;
- mPkUid = pkUid;
- mApplyUid = null;
- mApplyStream = null;
- if (mLiveLinkMicPkViewHolder == null) {
- mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
- mLiveLinkMicPkViewHolder.addToParent();
- mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
-
- }
- mLiveLinkMicPkViewHolder.showTime();
- mLiveLinkMicPkViewHolder.onEnterRoomPkStart();
- mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean);
- mPkTimeCount = pkTime;
- Log.d("mPkTimeCount1", "" + mPkTimeCount + ";mPkTimeFromServer=" + mPkTimeFromServer);
- mPkTimeFromServer = pkTime;
- nextPkTimeCountDown(2);
- }
-
- /**
- * 修改最终PK数据
- *
- * @param leftGift 左边数据
- * @param rightGift 右边数据
- * @param bean 排位数据
- */
- public void onPkProgressEnd(long leftGift, long rightGift, LivePKUserListBean bean) {
- if (mLiveLinkMicPkViewHolder != null) {
- mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean, true);
- }
- }
-
-
- /**
- * 进房间的时候懲罰开始
- */
- public void onEnterRoomCFStart(String pkUid, long leftGift, long rightGift, int pkTime, LivePKUserListBean bean) {
- mIsPk = true;
- mIsPkEnd = true;
- mPkUid = pkUid;
- mApplyUid = null;
- mApplyStream = null;
- if (mLiveLinkMicPkViewHolder == null) {
- mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
- mLiveLinkMicPkViewHolder.addToParent();
- mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
-
- }
- mLiveLinkMicPkViewHolder.showTime();
-// -1自己的主播输 0平 1自己的主播赢
- int p = 0;
- if (leftGift < rightGift) {
- p = -1;
- } else if (leftGift > rightGift) {
- p = 1;
- } else if (leftGift == rightGift) {
- p = 0;
- }
- mLiveLinkMicPkViewHolder.new_end(p);
-
- mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean);
- mPkTimeCount = pkTime;
- Log.d("mPkTimeCount1", "" + mPkTimeCount + ";mPkTimeFromServer=" + mPkTimeFromServer);
-// mPkTimeFromServer=pkTime;
- //恢复播放画面
- nextPkTimeCountDown(3);
- }
-
-
- /**
- * 主播与主播PK 所有人收到PK开始的回调
- */
- public void onLinkMicPkStart(String pkUid, int i) {
- Log.d("tag", i + "mPkTimeCount2");
- mIsPk = true;
- hideSendPkWait();
- mIsPkEnd = false;
- oldmPkUid = pkUid;
- mPkUid = pkUid;
- mApplyUid = null;
- mApplyStream = null;
- if (mLiveLinkMicPkViewHolder == null) {
- mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
- mLiveLinkMicPkViewHolder.addToParent();
- mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
- if (mContext instanceof LiveAudienceActivity) {
- ((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkview();
- }
-
- }
- mLiveLinkMicPkViewHolder.startAnim();
- EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_START).setObject(pkUid));
- mLiveLinkMicPkViewHolder.showTime();
- mPkTimeCount = 100;
- nextPkTimeCountDown(2);
- if (mIsAnchor) {
- ((LiveRyAnchorActivity) mContext).setPkBtnVisible(false);
- mPkTimeCount = PK_TIME_MAX;
-
- } else {
-// mPkTimeCount=mPkTimeFromServer;
- mPkTimeCount = PK_TIME_MAX;
- }
- Log.d("mPkTimeCount2", "" + mPkTimeCount + ";mPkTimeFromServer=" + mPkTimeFromServer);
- }
-
-
- /**
- * 主播与主播PK PK结果的回调
- */
- int s1 = 0;
-
- public void onLinkMicPkEnd(String winUid) {
- Log.i("收", "9");
-
- if (mIsPkEnd) {
- return;
- }
- mIsPkEnd = true;
- if (mHandler != null) {
- mHandler.removeMessages(WHAT_PK_TIME);
- }
- if (mLiveLinkMicPkViewHolder != null) {
- if (!TextUtils.isEmpty(winUid)) {
- if ("0".equals(winUid)) {
- mLiveLinkMicPkViewHolder.end(0);
- mLiveLinkMicPkViewHolder.hideTime();
- if (mHandler != null) {
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- onLinkMicPkClose(0);
- if (mIsAnchor) {
- ((LiveRyAnchorActivity) mContext).setPkBtnVisible(true);
- }
- }
- }, 3000);
- }
- } else {
- Log.e("ry1", winUid + "result");
- if (winUid.equals(mLiveUid)) {
- mLiveLinkMicPkViewHolder.end(1);
- } else {
- mLiveLinkMicPkViewHolder.end(-1);
- }
- mPkTimeCount = PK_TIME_MAX_2;//进入惩罚时间
- nextPkTimeCountDown(5);
- }
- }
-
- }
- }
-
- /**
- * 主播与主播PK 断开连麦PK的回调
- */
- public void onLinkMicPkClose(int i) {
- Log.e("ry", mPkUid + "aaaaqwqw" + i);
-
- PKing = false;
- LiveRyAnchorActivity.isDRPK = 0;
-
-// //恢复播放画面
- if (i == 1) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (btn_close != null) {
- btn_close.setVisibility(View.GONE);
- }
- }
- });
-// inputStreamList.clear();
- 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); //视频帧率
-
- //1. 设置自适应合流布局模式
- config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
- //2. 合流画布设置
- if (rcrtcLiveInfo != null) {
- rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "混成功16");
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", "混失败" + errorCode);
-
- }
- });
- }
-
- runOnUiThread(new Runnable() {
- public void run() {
-// try {
-// Thread.sleep(4000);
- if (mContext instanceof LiveAudienceActivity && LiveAudienceActivity.getmLivePlayViewHolder() != null) {
- LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
- }
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
- }
- });
-
- }
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- if (mPkPopWindow != null) {
- mPkPopWindow.dismiss();
- }
- mPkPopWindow = null;
- mIsPk = false;
- mIsPkEnd = false;
- hideSendPkWait();
- mPkUid = null;
- mApplyUid = null;
- mApplyStream = null;
- if (mLiveLinkMicPkViewHolder != null) {
- mLiveLinkMicPkViewHolder.removeFromParent();
- mLiveLinkMicPkViewHolder.release();
- }
- mLiveLinkMicPkViewHolder = null;
- }
-
- /**
- * 主播与主播Pk 对方主播拒绝Pk的回调
- */
- public void onLinkMicPkRefuse() {
- hideSendPkWait();
- if (mIsAnchor) {
- ((LiveRyAnchorActivity) mContext).setPkBtnVisible(true);
- }
- ToastUtil.show(mContext.getString(R.string.link_mic_refuse_pk));
- }
-
- /**
- * 主播与主播Pk 对方主播无响应的回调
- */
- public void onLinkMicPkNotResponse() {
- hideSendPkWait();
- if (mIsAnchor) {
- ((LiveRyAnchorActivity) mContext).setPkBtnVisible(true);
- }
- ToastUtil.show(mContext.getString(R.string.link_mic_anchor_not_response_2));
- }
-
- /**
- * 主播与主播Pk 对方主播正在忙的回调
- */
- public void onLinkMicPkBusy() {
- hideSendPkWait();
- if (mIsAnchor) {
- ((LiveRyAnchorActivity) mContext).setPkBtnVisible(true);
- }
- ToastUtil.show(mContext.getString(R.string.link_mic_anchor_busy_2));
- }
-
-
- public void release() {
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- mHandler = null;
- mSocketRyClient = null;
- if (mLiveLinkMicPkViewHolder != null) {
- mLiveLinkMicPkViewHolder.release();
- }
- mLiveLinkMicPkViewHolder = null;
- }
-
-
- public void clearData() {
- mIsApplyDialogShow = false;
- mAcceptPk = false;
- mIsPk = false;
- mApplyUid = null;
- mApplyStream = null;
- mLiveUid = null;
- mPkUid = null;
- mPkWaitCount = 0;
- mPkTimeCount = 0;
- mIsPkEnd = false;
- mPkSend = false;
- mPkSendWaitCount = 0;
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- if (mLiveLinkMicPkViewHolder != null) {
- mLiveLinkMicPkViewHolder.release();
- mLiveLinkMicPkViewHolder.removeFromParent();
- }
- mLiveLinkMicPkViewHolder = null;
- }
-
-
- public void setSelfStream(String selfStream) {
- mSelfStream = selfStream;
- }
-
- /**
- * 更新Pk分数
- */
- public void upDataPkScore(JSONArray pkScores, String uid, int time) {
- String userID1 = (String) imageGrade1.getTag();
- String userID2 = (String) imageGrade2.getTag();
- String userID4 = (String) imageGrade4.getTag();
- if (livePushRyViewHolder.timeTitle.getVisibility() == View.GONE) {
- mHandler.removeMessages(WHAT_PK_TIME2);
- RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) livePushRyViewHolder.timeTitle.getLayoutParams();
- layoutParams.topMargin = DpUtil.dp2px(123);
- livePushRyViewHolder.timeTitle.setLayoutParams(layoutParams);
- livePushRyViewHolder.timeTitle.setVisibility(View.VISIBLE);
- String pkTime = StringUtil.getDurationText(time * 1000);
- livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), pkTime));
- mPkTimeCount = time;
- if (time > 0) {
- String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
- livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
- mHandler.sendEmptyMessage(WHAT_PK_TIME2);
- }
-
- }
- int pkScoreSize = pkScores.size();
- if (pkScoreSize == 3) {
- linearGrade1.setVisibility(View.VISIBLE);
- linearGrade2.setVisibility(View.VISIBLE);
- linearGrade4.setVisibility(View.VISIBLE);
- //拿到原始数据
- for (int i = 0; i < pkScores.size(); i++) {
- JSONObject score = pkScores.getJSONObject(i);
- String userID = score.getString("id");
- long userScore = score.getLong("score");
- if (TextUtils.equals(userID, userID1)) {
- textGrade1.setText(String.valueOf(userScore));
- if (!score.containsKey("paiming")) {
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade1);
- } else {
- int ranking = score.getIntValue("paiming");
- switch (ranking) {
- case 1:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade1);
- break;
- case 2:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade1);
- break;
- case 3:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade1);
- break;
- case 4:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade1);
- break;
- }
- }
- } else if (TextUtils.equals(userID, userID2)) {
- textGrade2.setText(String.valueOf(userScore));
- if (!score.containsKey("paiming")) {
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade2);
- } else {
- int ranking = score.getIntValue("paiming");
- switch (ranking) {
- case 1:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade2);
- break;
- case 2:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade2);
- break;
- case 3:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade2);
- break;
- case 4:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade2);
- break;
- }
- }
- } else if (TextUtils.equals(userID, userID4)) {
- textGrade4.setText(String.valueOf(userScore));
- if (!score.containsKey("paiming")) {
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade4);
- } else {
- int ranking = score.getIntValue("paiming");
- switch (ranking) {
- case 1:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade4);
- break;
- case 2:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade4);
- break;
- case 3:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade4);
- break;
- case 4:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade4);
- break;
- }
- }
- }
- }
- } else {
- String userID3 = (String) imageGrade3.getTag();
- linearGrade1.setVisibility(View.VISIBLE);
- linearGrade2.setVisibility(View.VISIBLE);
- linearGrade3.setVisibility(View.VISIBLE);
- linearGrade4.setVisibility(View.VISIBLE);
- //拿到原始数据
- for (int i = 0; i < pkScores.size(); i++) {
- JSONObject score = pkScores.getJSONObject(i);
- String userID = score.getString("id");
- long userScore = score.getLong("score");
- if (TextUtils.equals(userID, userID1)) {
- textGrade1.setText(String.valueOf(userScore));
- if (!score.containsKey("paiming")) {
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade1);
- } else {
- int ranking = score.getIntValue("paiming");
- switch (ranking) {
- case 1:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade1);
- break;
- case 2:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade1);
- break;
- case 3:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade1);
- break;
- case 4:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade1);
- break;
- }
- }
- } else if (TextUtils.equals(userID, userID2)) {
- textGrade2.setText(String.valueOf(userScore));
- if (!score.containsKey("paiming")) {
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade2);
- } else {
- int ranking = score.getIntValue("paiming");
- switch (ranking) {
- case 1:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade2);
- break;
- case 2:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade2);
- break;
- case 3:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade2);
- break;
- case 4:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade2);
- break;
- }
- }
- } else if (TextUtils.equals(userID, userID4)) {
- textGrade4.setText(String.valueOf(userScore));
- if (!score.containsKey("paiming")) {
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade4);
- } else {
- int ranking = score.getIntValue("paiming");
- switch (ranking) {
- case 1:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade4);
- break;
- case 2:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade4);
- break;
- case 3:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade4);
- break;
- case 4:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade4);
- break;
- }
- }
- } else if (TextUtils.equals(userID, userID3)) {
- textGrade3.setText(String.valueOf(userScore));
- if (!score.containsKey("paiming")) {
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade3);
- } else {
- int ranking = score.getIntValue("paiming");
- switch (ranking) {
- case 1:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade3);
- break;
- case 2:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade3);
- break;
- case 3:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade3);
- break;
- case 4:
- ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade3);
- break;
- }
- }
- }
-
- }
- }
-
- }
-
-
- /**
- * PK倒计时
- */
- private void pkCountdownTimer() {
-
- mPkTimeCount--;
- if (mPkTimeCount > 0) {//
- if (mHandler != null) {
- String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
- livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
- mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME2, getNextSecondTime());
- }
- } else {
- livePushRyViewHolder.timeTitle.setVisibility(View.GONE);
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
-// endDRGif();
- if (DRInitiator) {
- LiveNetManager.get(mContext).jieshuDRPK("" + IMLoginManager.get(mContext).getUserInfo().getId());
- }
- }
- }
-
-
-}
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java
index ac7863546..7f25cb194 100644
--- a/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java
@@ -8,7 +8,6 @@ import static com.yunbao.live.activity.LiveSwAnchorActivity.PKing;
import static com.yunbao.live.activity.LiveSwAnchorActivity.isDRPK;
import static com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder;
import static com.yunbao.live.views.LivePushSwViewHolder.btn_close;
-import static com.yunbao.live.views.LivePushSwViewHolder.rtcRoom;
import android.app.Dialog;
import android.content.Context;
@@ -35,21 +34,14 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
-import com.tencent.imsdk.v2.V2TIMManager;
-import com.tencent.imsdk.v2.V2TIMMessage;
-import com.tencent.imsdk.v2.V2TIMSendCallback;
-import com.tencent.trtc.TRTCCloud;
import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.AnchorInfoEvent;
-import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
-import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
@@ -79,21 +71,11 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.RCRTCMixConfig;
-import cn.rongcloud.rtc.api.RCRTCOtherRoom;
-import cn.rongcloud.rtc.api.RCRTCRemoteUser;
-import cn.rongcloud.rtc.api.callback.IRCRTCOtherRoomEventsListener;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
-import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
-import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
@@ -141,7 +123,6 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
private int mPkSendWaitCount;//发送pk请求后的等待时间
private String mSelfStream;
private int mPkTimeFromServer;
- public static TRTCCloud mTRTCCloud1;
private View detailsView1, detailsView2, detailsView3, detailsView4;
private LinearLayout detailsLinearLayout1, detailsLinearLayout2, detailsLinearLayout3, detailsLinearLayout4;
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
@@ -151,8 +132,8 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
public LivePushSwViewHolder livePushSwViewHolder;
- public static List inputStreamList = new ArrayList<>();
- public static List inputStreamList1 = new ArrayList<>();
+// public static List inputStreamList = new ArrayList<>();
+// public static List inputStreamList1 = new ArrayList<>();
private boolean DRInitiator = false;//是否是duorenPK发起人
private List drPkbeans = new ArrayList<>();
@@ -337,15 +318,6 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
s1 = "00:00";
i = 0;
}
- if (rtcRoom != null) {
- ScreenDimenUtil util = ScreenDimenUtil.getInstance();
- int mScreenWdith = util.getScreenWdith();
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
- params.weight = 1;
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- livePushSwViewHolder.camera.setLayoutParams(params);
- livePushSwViewHolder.mPreView1.setLayoutParams(params);
- }
Log.i("tts2", s1);
mLiveLinkMicPkViewHolder.setTime(s + " " + s1);
@@ -863,86 +835,10 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
@Override
protected void onDRPkTimeout(UserBean u) {
- IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 8);
- msg1.create();
-
- String targetId = u.getId();
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
-
- 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 (SocketSwClient.mSocketHandler != null) {
- SocketSwClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
- }
- }
-
- @Override
- public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
- Log.e("ry", "发送失敗" + mApplyUid);
- }
- });
- }
- });
}
@Override
protected void onDRPkRefuse(UserBean u) {
- IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 3);
- msg1.create();
-
- String targetId = u.getId();
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
-
- 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 (SocketSwClient.mSocketHandler != null) {
- SocketSwClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
- }
- }
-
- @Override
- public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
- Log.e("ry", "发送失敗");
- }
- });
- }
- });
}
@Override
@@ -1054,7 +950,6 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
public void leaveDRRoom() {
//清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
- Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0;
DRPKing = -1;
runOnUiThread(new Runnable() {
@@ -1169,7 +1064,7 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
}
private void refusePk(UserBean u) {
- IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
+ /*IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
@@ -1208,7 +1103,7 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
}
});
}
- });
+ });*/
LiveNetManager.get(mContext).setBanRandomPK(null);
}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketChatUtil.java
deleted file mode 100644
index d7ecbf13e..000000000
--- a/live/src/main/java/com/yunbao/live/socket/SocketChatUtil.java
+++ /dev/null
@@ -1,671 +0,0 @@
-package com.yunbao.live.socket;
-
-import android.util.Log;
-
-import com.tencent.imsdk.v2.V2TIMCallback;
-import com.tencent.imsdk.v2.V2TIMManager;
-import com.tencent.imsdk.v2.V2TIMMessage;
-import com.tencent.imsdk.v2.V2TIMSendCallback;
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.CommonAppContext;
-import com.yunbao.common.Constants;
-import com.yunbao.common.bean.UserBean;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.http.LiveHttpUtil;
-import com.yunbao.live.R;
-
-/**
- * Created by cxf on 2018/10/9.
- * 直播间发言
- */
-
-public class SocketChatUtil {
-
- //关闭直播
- public static void closeLive(final String mLiveUid, SocketClient client) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_LIVE_END)
- .param("action", 18)
- .param("msgtype", 1)
- .param("equipment", "app")
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("roomnum", u.getId())
- .param("ct", "直播关闭");
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- V2TIMManager.getInstance().dismissGroup("g" + mLiveUid, new V2TIMCallback() {
- @Override
- public void onSuccess() {
- Log.i("tx", "解散成功");
-
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "解散失败" + desc);
- }
- });
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败1" + desc);
-
- }
- });
- }
-
- /**
- * 发言
- */
- public static void sendChatMessage(String mLiveUid, String content, boolean isAnchor, int userType, int guardType) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-
- final SocketSendBean msg =
- new SocketSendBean()
- .param("_method_", Constants.SOCKET_SEND_MSG)
- .param("action", 0)
- .param("msgtype", 2)
- .param("usertype", userType)
- .param("isAnchor", isAnchor ? 1 : 0)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("bubble", u.getDress().getBubble())
- .param("medal_honor", u.getMedal_no_display_src())
- .param("medal", u.getDress().getMedal())
- .param("medal_new", u.getDress().getMedal_new())
- .param("uid", u.getId())
- .param("liangname", u.getGoodName())
- .param("vip_type", u.getVip().getType())
- .param("guard_type", guardType)
- .param("medal_name", u.getMedalName())
- .param("medal_level", u.getMedalLevel())
- .param("good_num", u.getGoodnum())
- .param("ct", content);
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
-
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败2" + desc);
-
- }
- });
- }
-
- /**
- * 点亮
- */
- public static void sendLightMessage(final String mLiveUid, int heart, int guardType) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SEND_MSG)
- .param("action", 0)
- .param("msgtype", 2)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("liangname", u.getGoodName())
- .param("vip_type", u.getVip().getType())
- .param("medal_honor", u.getMedal_no_display_src())
- .param("heart", heart)
- .param("bubble", u.getDress().getBubble())
- .param("medal", u.getDress().getMedal())
- .param("medal_new", u.getDress().getMedal_new())
- .param("guard_type", guardType)
- .param("medal_name", u.getMedalName())
- .param("medal_level", u.getMedalLevel())
- .param("good_num", u.getGoodnum())
- .param("ct", CommonAppContext.sInstance.getBaseContext().getString(R.string.live_lighted));
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- LiveHttpUtil.sendZAN(mLiveUid, new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- Log.i("tag", "禮物im");
- }
- });
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
-
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败3" + desc);
-
- }
- });
- }
-
-
- /**
- * 发送弹幕消息
- */
- public static void sendDanmuMessage(String mLiveUid, String danmuToken) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SEND_BARRAGE)
- .param("action", 7)
- .param("msgtype", 1)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("uhead", u.getAvatar())
- .param("ct", danmuToken);
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败4" + desc);
-
- }
- });
-
- }
-
-
- /**
- * 发送礼物消息
- */
- public static void sendGiftMessage(int giftType, String giftToken, String liveUid, int guard_type, String by) {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SEND_GIFT)
- .param("action", 0)
- .param("msgtype", 1)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("uhead", u.getAvatar())
- .param("evensend", giftType)
- .param("liangname", u.getGoodName())
- .param("vip_type", u.getVip().getType())
- .param("ct", giftToken)
- .param("bubble", u.getDress().getBubble())
- .param("medal", u.getDress().getMedal())
- .param("medal_new", u.getDress().getMedal_new())
- .param("medal_name", u.getMedalName())
- .param("medal_level", u.getMedalLevel())
- .param("guard_type", guard_type + "")
- .param("medal_honor", u.getMedal_no_display_src())
- .param("good_num", u.getGoodnum())
- .param("roomnum", liveUid);
-
- msg.create();
- LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- Log.i("tag", "禮物im");
- }
- });
-
- }
-
- /**
- * 发送礼物消息 增加主播名字
- */
- public static void sendGiftMessage(int giftType, String giftToken,
- String liveUid, String ancherName, int guard_type, String by) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SEND_GIFT)
- .param("action", 0)
- .param("msgtype", 1)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("uhead", u.getAvatar())
- .param("evensend", giftType)
- .param("liangname", u.getGoodName())
- .param("vip_type", u.getVip().getType())
- .param("bubble", u.getDress().getBubble())
- .param("medal", u.getDress().getMedal())
- .param("medal_new", u.getDress().getMedal_new())
- .param("ct", giftToken)
- .param("ancherName", ancherName)
- .param("medal_name", u.getMedalName())
- .param("medal_level", u.getMedalLevel())
- .param("guard_type", guard_type + "")
- .param("medal_honor", u.getMedal_no_display_src())
- .param("good_num", u.getGoodnum())
- .param("roomnum", liveUid);
-
- msg.create();
-
- LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- Log.i("tag", "禮物im");
- }
- });
-
- }
-
- /**
- * 主播或管理员 踢人
- */
- public static void sendKickMessage(String mLiveUid, String toUid, String toName) {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_KICK)
- .param("action", 2)
- .param("msgtype", 4)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("touid", toUid)
- .param("toname", toName)
- .param("ct", toName + CommonAppContext.sInstance.getBaseContext().getString(R.string.live_kicked));
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
-
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败5" + desc);
-
- }
- });
- }
-
-
- /**
- * 主播或管理员 禁言
- */
- public static void sendShutUpMessage(String mLiveUid, String toUid, String toName, int type) {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SHUT_UP)
- .param("action", 1)
- .param("msgtype", 4)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("touid", toUid)
- .param("toname", toName)
- .param("ct", toName + (type == 0 ? "被永久禁言(Forbidden forever)" : "被本場禁言(Forbidden by this scene)"));
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败6" + desc);
-
- }
- });
-
- }
-
- /**
- * 设置或取消管理员消息
- */
- public static void sendSetAdminMessage(String mLiveUid, int action, String toUid, String toName) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- String s = action == 1 ? "被設為管理員(Set as Administrator)": "被取消管理員(Cancelled administrator)";
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SET_ADMIN)
- .param("action", action)
- .param("msgtype", 1)
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("touid", toUid)
- .param("toname", toName)
- .param("ct", toName + " " + s);
-
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败7" + desc);
-
- }
- });
-
- }
-
- /**
- * 超管关闭直播间
- */
- public static void superCloseRoom(String mLiveUid) {
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_STOP_LIVE)
- .param("action", 19)
- .param("msgtype", 1)
- .param("ct", "");
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
-
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败7" + desc);
-
- }
- });
- }
-
- /**
- * 发系统消息
- */
- public static void sendSystemMessage(String mLiveUid, String content) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SYSTEM)
- .param("action", 13)
- .param("msgtype", 4)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("ct", content);
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功" + msg.mResult.toString());
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败9" + desc);
-
- }
- });
-
- }
-
-
- /**
- * 获取僵尸粉
- */
- public static void getFakeFans(String mLiveUid) {
-
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_FAKE_FANS)
- .param("action", "")
- .param("msgtype", "");
-
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
-
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败10" + desc);
-
- }
- });
-
- }
-
-
- /**
- * 更新主播映票数
- */
- public static void sendUpdateVotesMessage(String mLiveUid, int votes, int first) {
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_UPDATE_VOTES)
- .param("action", 1)
- .param("msgtype", 26)
- .param("votes", votes)
- .param("uid", CommonAppConfig.getInstance().getUid())
- .param("isfirst", first)
- .param("ct", "");
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败" + desc);
-
- }
- });
-
- }
-
- /**
- * 更新主播映票数
- */
- public static void sendUpdateVotesMessage(String mLiveUid, int votes) {
- sendUpdateVotesMessage(mLiveUid, votes, 0);
- }
-
- /**
- * 发送购买守护成功消息
- */
- public static void sendBuyGuardMessage(String mLiveUid, String votes, int guardNum, int guardType) {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_BUY_GUARD)
- .param("action", 0)
- .param("msgtype", 0)
- .param("uid", u.getId())
- .param("bubble", u.getDress().getBubble())
- .param("medal", u.getDress().getMedal())
- .param("medal_new", u.getDress().getMedal_new())
- .param("uname", u.getUserNiceName())
- .param("uhead", u.getAvatar())
- .param("votestotal", votes)
- .param("guard_nums", guardNum)
- .param("guard_type", guardType);
- msg.create();
-
- }
-
- public static void sendBuyGuardMessage2(String mLiveUid, String votes, int guardNum,
- int guardType, String ancherName, String liveId) {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_BUY_GUARD)
- .param("action", 0)
- .param("msgtype", 0)
- .param("uid", u.getId())
- .param("uname", u.getUserNiceName())
- .param("uhead", u.getAvatar())
- .param("votestotal", votes)
- .param("guard_nums", guardNum)
- .param("ancherName", ancherName)
- .param("liveuid", liveId)
- .param("bubble", u.getDress().getBubble())
- .param("medal", u.getDress().getMedal())
- .param("medal_new", u.getDress().getMedal_new())
- .param("guard_type", guardType);
- msg.create();
- }
-
- /**
- * 发送发红包成功消息
- */
- public static void sendRedPackMessage(String mLiveUid) {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_RED_PACK)
- .param("action", 0)
- .param("msgtype", 0)
- .param("uid", u.getId())
- .param("uname", u.getUserNiceName())
- .param("ct", CommonAppContext.sInstance.getBaseContext().getString(R.string.red_pack_22)
- );
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(), "g" + mLiveUid, V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx", "发送中" + progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx", "发送成功");
- SocketClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx", code + "发送失败" + desc);
-
- }
- });
- }
-
-}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketClient.java b/live/src/main/java/com/yunbao/live/socket/SocketClient.java
index c0c1f9f0d..6a64d6285 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketClient.java
@@ -11,8 +11,6 @@ import android.widget.LinearLayout;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
-import com.tencent.imsdk.v2.V2TIMCallback;
-import com.tencent.imsdk.v2.V2TIMManager;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@@ -57,7 +55,7 @@ public class SocketClient {
public SocketClient(String mLiveUid, SocketMessageListener listener) {
mSocketHandler = new SocketHandler(listener);
mSocketHandler.setLiveUid(mLiveUid);
- V2TIMManager.getInstance().joinGroup("g" + mLiveUid, "", new V2TIMCallback() {
+ /*V2TIMManager.getInstance().joinGroup("g" + mLiveUid, "", new V2TIMCallback() {
@Override
public void onSuccess() {
Log.i("tx", "加入成功");
@@ -67,7 +65,7 @@ public class SocketClient {
public void onError(int code, String desc) {
Log.i("tx", desc + "加入" + "失败" + code);
}
- });
+ });*/
}
public void disConnect() {
@@ -785,7 +783,7 @@ public class SocketClient {
mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));
break;
case 5://PK时候断开连麦的回调
- if (LivePushTxViewHolder.mTRTCCloud != null) {
+ /*if (LivePushTxViewHolder.mTRTCCloud != null) {
if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) {
LiveLinkMicPkPresenter.mTRTCCloud1.stopRemoteView(map.getString("uid"));
LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom();
@@ -804,7 +802,7 @@ public class SocketClient {
}
});
Log.i("zzzv", "1");
- }
+ }*/
mListener.onLinkMicPkClose(1);
break;
case 7://对方主播正在忙的回调
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketGameUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketGameUtil.java
deleted file mode 100644
index 1c38a762a..000000000
--- a/live/src/main/java/com/yunbao/live/socket/SocketGameUtil.java
+++ /dev/null
@@ -1,645 +0,0 @@
-package com.yunbao.live.socket;
-
-import android.util.Log;
-
-import com.tencent.imsdk.v2.V2TIMManager;
-import com.tencent.imsdk.v2.V2TIMMessage;
-import com.tencent.imsdk.v2.V2TIMSendCallback;
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.Constants;
-import com.yunbao.common.bean.UserBean;
-
-/**
- * Created by cxf on 2018/10/31.
- */
-
-public class SocketGameUtil {
-
-
- /**
- * 智勇三张 开启游戏窗口
- */
- public static void zjhShowGameWindow() {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_GAME_ZJH)
-// .param("action", GameConsts.GAME_ACTION_OPEN_WINDOW)
- .param("msgtype", 15)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("ct", "");
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(),"g"+u.getId(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx","发送中"+progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx","发送成功");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx",code+"发送失败"+desc);
-
- }
- });
-
- }
-
- /**
- * 智勇三张 主播创建游戏
- */
- public static void zjhAnchorCreateGame(String gameId) {
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_GAME_ZJH)
-// .param("action", GameConsts.GAME_ACTION_CREATE)
- .param("msgtype", 15)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("gameid", gameId)
- .param("ct", "");
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(),"g"+u.getId(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx","发送中"+progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx","发送成功");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx",code+"发送失败"+desc);
-
- }
- });
-
- }
-
- /**
- * 智勇三张 主播关闭游戏
- */
- public static void zjhAnchorCloseGame() {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_GAME_ZJH)
-// .param("action", GameConsts.GAME_ACTION_CLOSE)
- .param("msgtype", 15)
- .param("level", u.getLevel())
- .param("uname", u.getUserNiceName())
- .param("uid", u.getId())
- .param("ct", "");
- msg.create();
- V2TIMManager.getInstance().sendGroupTextMessage(msg.mResult.toString(),"g"+u.getId(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, new V2TIMSendCallback() {
- @Override
- public void onProgress(int progress) {
- Log.i("tx","发送中"+progress);
-
- }
-
- @Override
- public void onSuccess(V2TIMMessage v2TIMMessage) {
- Log.i("tx","发送成功");
- }
-
- @Override
- public void onError(int code, String desc) {
- Log.i("tx",code+"发送失败"+desc);
-
- }
- });
-
- }
-
- /**
- * 智勇三张 主播通知所有人下注
- * 此时服务器收到该socket后,自动计时,30秒后自动发送显示游戏结果的socket
- */
- public static void zjhAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
-
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_ZJH)
-// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
-// .param("msgtype", 15)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("liveuid", liveUid)
-// .param("gameid", gameId)
-// .param("token", token)
-// .param("time", time)
-// .param("ct", "")
-// );
-// ssss
- }
-
- /**
- * 智勇三张 观众把自己的下注信息广播给所有人
- */
- public static void zjhAudienceBetGame(SocketClient client, int coin, int index) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_ZJH)
-// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
-// .param("msgtype", 15)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("money", coin)
-// .param("type", index)
-// .param("ct", "")
-// );
- }
-
-
- /**
- * 海盗船长 开启游戏窗口
- */
- public static void hdShowGameWindow(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_HD)
-// .param("action", 1)
-// .param("msgtype", 18)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
-
- /**
- * 海盗船长 主播创建游戏
- */
- public static void hdAnchorCreateGame(SocketClient client, String gameId) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_HD)
-// .param("action", GameConsts.GAME_ACTION_CREATE)
-// .param("msgtype", 18)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("gameid", gameId)
-// .param("ct", "")
-// );
- }
-
- /**
- * 海盗船长 主播关闭游戏
- */
- public static void hdAnchorCloseGame(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_HD)
-// .param("action", GameConsts.GAME_ACTION_CLOSE)
-// .param("msgtype", 18)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
-
- /**
- * 海盗船长 主播通知所有人下注
- * 此时服务器收到该socket后,自动计时,30秒后自动发送显示游戏结果的socket
- */
- public static void hdAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_HD)
-// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
-// .param("msgtype", 18)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("liveuid", liveUid)
-// .param("gameid", gameId)
-// .param("token", token)
-// .param("time", time)
-// .param("ct", "")
-// );
- }
-
- /**
- * 海盗船长 观众把自己的下注信息广播给所有人
- */
- public static void hdAudienceBetGame(SocketClient client, int coin, int index) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_HD)
-// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
-// .param("msgtype", 18)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("money", coin)
-// .param("type", index)
-// .param("ct", "")
-// );
- }
-
-
- /**
- * 幸运转盘 开启游戏窗口
- */
- public static void zpShowGameWindow(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_ZP)
-// .param("action", 1)
-// .param("msgtype", 16)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
-
- /**
- * 幸运转盘 主播关闭游戏
- */
- public static void zpAnchorCloseGame(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_ZP)
-// .param("action", GameConsts.GAME_ACTION_CLOSE)
-// .param("msgtype", 16)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
- /**
- * 幸运转盘 主播通知所有人下注
- * 此时服务器收到该socket后,自动计时,30秒后自动发送显示游戏结果的socket
- */
- public static void zpAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_ZP)
-// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
-// .param("msgtype", 16)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("liveuid", liveUid)
-// .param("gameid", gameId)
-// .param("token", token)
-// .param("time", time)
-// .param("ct", "")
-// );
- }
-
- /**
- * 幸运转盘 观众把自己的下注信息广播给所有人
- */
- public static void zpAudienceBetGame(SocketClient client, int coin, int index) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_ZP)
-// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
-// .param("msgtype", 16)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("money", coin)
-// .param("type", index)
-// .param("ct", "")
-// );
- }
-
-
- /**
- * 开心牛仔 开启游戏窗口
- */
- public static void nzShowGameWindow(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_NZ)
-// .param("action", 1)
-// .param("msgtype", 17)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
- /**
- * 开心牛仔 主播创建游戏
- * 本局的庄家信息 服务器用"bankerlist" 这个字段表示 ,其实是一个对象,是一个人的信息
- */
- public static void nzAnchorCreateGame(SocketClient client, String gameId, String bankerInfo) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_NZ)
-// .param("action", GameConsts.GAME_ACTION_CREATE)
-// .param("msgtype", 17)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("gameid", gameId)
-// .param("ct", "")
-// .paramJsonObject("bankerlist", bankerInfo)
-// );
- }
-
- /**
- * 开心牛仔 主播关闭游戏
- */
- public static void nzAnchorCloseGame(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_NZ)
-// .param("action", GameConsts.GAME_ACTION_CLOSE)
-// .param("msgtype", 17)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
- /**
- * 开心牛仔 主播通知所有人下注
- * 此时服务器收到该socket后,自动计时,30秒后自动发送显示游戏结果的socket
- */
- public static void nzAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_NZ)
-// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
-// .param("msgtype", 17)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("liveuid", liveUid)
-// .param("gameid", gameId)
-// .param("token", token)
-// .param("time", time)
-// .param("ct", "")
-// );
- }
-
- /**
- * 开心牛仔 观众把自己的下注信息广播给所有人
- */
- public static void nzAudienceBetGame(SocketClient client, int coin, int index) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_NZ)
-// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
-// .param("msgtype", 17)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("money", coin)
-// .param("type", index)
-// .param("ct", "")
-// );
- }
-
- /**
- * 二八贝 开启游戏窗口
- */
- public static void ebbShowGameWindow(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_EBB)
-// .param("action", 1)
-// .param("msgtype", 15)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
- /**
- * 二八贝 主播创建游戏
- */
- public static void ebbAnchorCreateGame(SocketClient client, String gameId) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_EBB)
-// .param("action", GameConsts.GAME_ACTION_CREATE)
-// .param("msgtype", 19)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("gameid", gameId)
-// .param("ct", "")
-// );
- }
-
- /**
- * 二八贝 主播关闭游戏
- */
- public static void ebbAnchorCloseGame(SocketClient client) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_EBB)
-// .param("action", GameConsts.GAME_ACTION_CLOSE)
-// .param("msgtype", 19)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("ct", "")
-// );
- }
-
-
- /**
- * 二八贝 主播通知所有人下注
- * 此时服务器收到该socket后,自动计时,30秒后自动发送显示游戏结果的socket
- */
- public static void ebbAnchorNotifyGameBet(SocketClient client, String liveUid, String gameId, String token, int time) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_EBB)
-// .param("action", GameConsts.GAME_ACTION_NOTIFY_BET)
-// .param("msgtype", 19)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("liveuid", liveUid)
-// .param("gameid", gameId)
-// .param("token", token)
-// .param("time", time)
-// .param("ct", "")
-// );
- }
-
- /**
- * 二八贝 观众把自己的下注信息广播给所有人
- */
- public static void ebbAudienceBetGame(SocketClient client, int coin, int index) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_GAME_EBB)
-// .param("action", GameConsts.GAME_ACTION_BROADCAST_BET)
-// .param("msgtype", 19)
-// .param("level", u.getLevel())
-// .param("uname", u.getUserNiceName())
-// .param("uid", u.getId())
-// .param("money", coin)
-// .param("type", index)
-// .param("ct", "")
-// );
- }
-
-
-}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java
index 8118f3e67..d08f8d7a0 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java
@@ -2,9 +2,6 @@ package com.yunbao.live.socket;
import android.util.Log;
-import com.tencent.imsdk.v2.V2TIMManager;
-import com.tencent.imsdk.v2.V2TIMMessage;
-import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@@ -69,7 +66,7 @@ public class SocketLinkMicPkUtil {
.param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("name", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg.create();
- V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback() {
+ /* V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback() {
@Override
public void onProgress(int progress) {
@@ -110,7 +107,7 @@ public class SocketLinkMicPkUtil {
ToastUtil.show("发送失败");
}
- });
+ });*/
}
}
});
@@ -152,7 +149,7 @@ public class SocketLinkMicPkUtil {
.param("ct", "");
msg.create();
- V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback() {
+ /* V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback() {
@Override
public void onProgress(int progress) {
@@ -168,7 +165,7 @@ public class SocketLinkMicPkUtil {
ToastUtil.show("发送失败");
}
- });
+ });*/
}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
index 79c8b9310..985596deb 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
@@ -66,8 +66,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null)
- SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ /* if (SocketRyClient.mSocketHandler != null)
+ SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");*/
}
@Override
@@ -131,9 +131,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
- if (SocketRyClient.mSocketHandler != null) {
+ /* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
LiveNetManager.get(CommonAppContext.sInstance)
.addChatCount(LiveActivity.mStream, new com.yunbao.common.http.base.HttpCallback() {
@Override
@@ -218,8 +218,8 @@ public class SocketRyChatUtil {
}
}
});
- if (SocketRyClient.mSocketHandler != null)
- SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ /*if (SocketRyClient.mSocketHandler != null)
+ SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");*/
}
@Override
@@ -267,9 +267,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -406,9 +406,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -476,9 +476,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -523,9 +523,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -560,9 +560,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -603,8 +603,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null)
- SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ /* if (SocketRyClient.mSocketHandler != null)
+ SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");*/
}
@Override
@@ -640,9 +640,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -680,9 +680,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -786,9 +786,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
}
@Override
@@ -834,9 +834,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
- if (SocketRyClient.mSocketHandler != null) {
+ /*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
- }
+ }*/
LiveNetManager.get(CommonAppContext.sInstance)
.addChatCount(LiveActivity.mStream, new com.yunbao.common.http.base.HttpCallback() {
@Override
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
deleted file mode 100644
index c21b65213..000000000
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
+++ /dev/null
@@ -1,1557 +0,0 @@
-package com.yunbao.live.socket;
-
-import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
-import static com.blankj.utilcode.util.ViewUtils.runOnUiThread;
-import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER;
-import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
-import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_ANCHOR_PRANK_GIFT;
-import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Handler;
-import android.os.Message;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.Toast;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.blankj.utilcode.util.GsonUtils;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.CommonAppContext;
-import com.yunbao.common.Constants;
-import com.yunbao.common.bean.AiAutomaticSpeechModel;
-import com.yunbao.common.bean.FansModel;
-import com.yunbao.common.bean.GuardMaturityDateRemindModel;
-import com.yunbao.common.bean.LinkMicUserBean;
-import com.yunbao.common.bean.LiveUserGiftBean;
-import com.yunbao.common.bean.MsgModel;
-import com.yunbao.common.bean.PkRankBean;
-import com.yunbao.common.bean.RedPacketInfoModel;
-import com.yunbao.common.bean.RedPacketModel;
-import com.yunbao.common.bean.SendMoneyLongModel;
-import com.yunbao.common.bean.SocketModel;
-import com.yunbao.common.bean.SudGameDateModel;
-import com.yunbao.common.bean.UserBean;
-import com.yunbao.common.bean.WishModel;
-import com.yunbao.common.bean.XydCompleteModel;
-import com.yunbao.common.event.AllServerNotifyEvent;
-import com.yunbao.common.event.AllServerNotifyFFGGGDJANEvent;
-import com.yunbao.common.event.CustomFullServiceNotifyEvent;
-import com.yunbao.common.event.GiftWallIlluminateEvent;
-import com.yunbao.common.event.QuickGiftingEvent;
-import com.yunbao.common.event.SendBlindGiftEvent;
-import com.yunbao.common.event.SendMoneyLongEndEvent;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.http.HttpClient;
-import com.yunbao.common.manager.IMRTCManager;
-import com.yunbao.common.manager.MicUserManager;
-import com.yunbao.common.manager.MicedUserManager;
-import com.yunbao.common.manager.NewLevelManager;
-import com.yunbao.common.manager.RandomPkManager;
-import com.yunbao.common.utils.Bus;
-import com.yunbao.common.utils.DialogUitl;
-import com.yunbao.common.utils.L;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.common.utils.ToastUtils;
-import com.yunbao.common.utils.WordUtil;
-import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveAudienceActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
-import com.yunbao.live.adapter.LiveChatAdapter;
-import com.yunbao.live.bean.LiveBuyGuardMsgBean;
-import com.yunbao.live.bean.LiveChatBean;
-import com.yunbao.live.bean.LiveDanMuBean;
-import com.yunbao.live.bean.LiveEnterRoomBean;
-import com.yunbao.live.bean.LiveGiftPrizePoolWinBean;
-import com.yunbao.live.bean.LiveLuckGiftWinBean;
-import com.yunbao.live.bean.LivePKUserListBean;
-import com.yunbao.live.bean.LiveReceiveGiftBean;
-import com.yunbao.live.bean.NewAllServerNotifyGuardEvent;
-import com.yunbao.live.bean.SendQuickGiftModel;
-import com.yunbao.live.event.LiveAnchorEvent;
-import com.yunbao.live.event.LiveAudienceEvent;
-import com.yunbao.live.views.LiveEndViewHolder;
-import com.yunbao.live.views.LivePlayKsyViewHolder;
-import com.yunbao.live.views.LivePlayRyViewHolder;
-import com.yunbao.live.views.LivePushRyViewHolder;
-import com.yunbao.live.views.LiveRoomViewHolder;
-
-import org.greenrobot.eventbus.EventBus;
-
-import java.lang.ref.WeakReference;
-import java.util.List;
-
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
-import cn.rongcloud.rtc.base.RTCErrorCode;
-import io.rong.imlib.IRongCoreCallback;
-import io.rong.imlib.IRongCoreEnum;
-import io.rong.imlib.chatroom.base.RongChatRoomClient;
-
-public class SocketRyClient {
-
- private final String TAG = "socket";
- private String mLiveUid;
- private String mStream;
- public static SocketHandler mSocketHandler;
- private Context mContext;
-
- public SocketRyClient(String mLiveUid, SocketMessageListener listener, Activity mContext) {
- this.mContext = mContext;
- mSocketHandler = new SocketHandler(listener);
- mSocketHandler.setLiveUid(mLiveUid);
- RongChatRoomClient.getInstance().joinChatRoom("g" + mLiveUid, -1, new IRongCoreCallback.OperationCallback() {
- @Override
- public void onSuccess() {
- Log.i("tx", "加入成功");
-
- }
-
- @Override
- public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
- Log.i("tx", "加入" + "失败" + coreErrorCode);
- if (WordUtil.isNewZh()) {
- ToastUtil.show("網絡不佳無法連接,請重新進入");
- } else {
- ToastUtil.show("The network is not connected, please re-enter");
- }
- }
- });
-
- }
-
- public void setLivePushRyViewHolder(LivePushRyViewHolder livePushRyViewHolder) {
- if (mSocketHandler != null) {
- mSocketHandler.setLivePushRyViewHolder(livePushRyViewHolder);
- }
- }
-
- public void disConnect() {
-// V2TIMManager.getInstance().
- mLiveUid = null;
- mStream = null;
- mSocketHandler = null;
- }
-
- public class SocketHandler extends Handler {
-
- private SocketMessageListener mListener;
- private LivePushRyViewHolder livePushRyViewHolder;
- private String mLiveUid;
-
- public SocketHandler(SocketMessageListener listener) {
- mListener = new WeakReference<>(listener).get();
- }
-
- public void setLiveUid(String liveUid) {
- mLiveUid = liveUid;
- }
-
- public void setLivePushRyViewHolder(LivePushRyViewHolder livePushRyViewHolder) {
- this.livePushRyViewHolder = livePushRyViewHolder;
- }
-
- @Override
- public void handleMessage(Message msg) {
- if (mListener == null) {
- return;
- }
- try {
- switch (msg.what) {
- case Constants.SOCKET_WHAT_CONN:
- mListener.onConnect((Boolean) msg.obj);
- break;
- case Constants.SOCKET_WHAT_BROADCAST:
- processBroadcast((String) msg.obj);
- break;
- case Constants.SOCKET_WHAT_DISCONN:
- mListener.onDisConnect();
- break;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
-
- public void processBroadcast(String socketMsg) {
- L.e("收到socket--->" + socketMsg);
-
- Log.i("SocketRyClient", "socketMsg" + socketMsg);
-
- if (Constants.SOCKET_STOP_PLAY.equals(socketMsg)) {
- mListener.onSuperCloseLive();//超管关闭房间
- return;
- }
- if (socketMsg.contains("LivePK_UnreadCount")) {
- return;
- }
- SocketReceiveBean received = JSON.parseObject(socketMsg, SocketReceiveBean.class);
-
- JSONObject map = received.getMsg().getJSONObject(0);
-// LogUtils.e("yqw=====>收到的socket:"+map.getString("_method_")+","+map.getString("ct"));
- switch (map.getString("_method_")) {
- //用户连麦
- case Constants.LIAN_MAI:
- int actions = map.getIntValue("action");
- //主播邀请用户连麦消息
- if (actions == 1) {
- EventBus.getDefault().post("inviteMic");
- //主播同意用户连麦申请
- } else if (actions == 4) {
- EventBus.getDefault().post("UsertoRY");
- } else if (actions == 5) {
- JSONObject mic_data = map.getJSONObject("ct");
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST)
- .setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class))
- );
- MicedUserManager.get().upDataMicUserList(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class));
- } else if (actions == 6) {
- if (WordUtil.isNewZh()) {
- ToastUtil.show("主播已關閉當前語音連麥功能");
- } else {
- ToastUtil.show("The host has disabled the voice connection function");
- }
- EventBus.getDefault().post("endMic");
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE)
- .setObject(map.toJavaObject(LinkMicUserBean.class)));
- } else if (actions == 8) {
- if (WordUtil.isNewZh()) {
- ToastUtil.show("您已被移出多人語音連麥");
- } else {
- ToastUtil.show("You have been removed from Multi-Voice Connection");
- }
- EventBus.getDefault().post("endMic");
- } else if (actions == 3) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC)
- .setObject(map.toJavaObject(LinkMicUserBean.class))
- );
- MicUserManager.get().upDataMicUser(map);
- } else if (actions == 7) {//取消连麦
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL)
- );
- MicUserManager.get().removeMiscUser(map);
- }
- break;
- case Constants.UP_USER_LIST:
- mListener.onUpUserList(map.getJSONObject("ct"));
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_AUDIENCE_LIST)
- .setObject(JSON.parseArray(map.getJSONObject("ct").getString("userlist"), LiveUserGiftBean.class))
- );
- break;
- case Constants.CARD:
-// LiveLinkMicPresenter.setHD(map.getString("ct"));
- break;
- case Constants.SOCKET_SYSTEM://系统消息
- if (map.getString("ct").contains("甜蜜不停")) {
- break;
- }
- UserBean us = CommonAppConfig.getInstance().getUserBean();
- if (map.getString("uid") != null && us != null && map.getString("uid").equals(us.getId())) {
- int num = LiveAudienceActivity.fansNum + 1;
- LiveRoomViewHolder.setFansNum(num);
- }
- if (map.getString("ct").contains("堅決維護青少年群體精神文明健康") || map.getString("ct").contains("click to register if you like. PoYo conducts")) {
- systemChatMessage(map.getString("ct"));
- } else {
- if (!WordUtil.isNewZh() && map.getString("ct").contains("退出比賽") && map.getString("ct").contains("獲得勝利")) {
- String ctTmp = map.getString("ct");
- ctTmp = ctTmp.replace("由於", "Due to")
- .replace("退出比賽", "withdrawing from the competition")
- .replace("獲得勝利", "won");
- map.put("ct", ctTmp);
- }
- systemChatMessage2(map.getString("ct"));
- }
-
- int action21 = map.getIntValue("action");
- //主播離開
- if (action21 == 13 && map.getString("ct").contains("離開")) {
- if (LivePlayKsyViewHolder.leave != null) {
- LivePlayKsyViewHolder.leave.setVisibility(View.VISIBLE);
- }
- if (LivePlayRyViewHolder.leave != null) {
- LivePlayRyViewHolder.leave.setVisibility(View.VISIBLE);
- }
- } else if (action21 == 13 && map.getString("ct").contains("回來")) {
- if (LivePlayKsyViewHolder.leave != null) {
- LivePlayKsyViewHolder.leave.setVisibility(View.GONE);
- }
- if (LivePlayRyViewHolder.leave != null) {
- LivePlayRyViewHolder.leave.setVisibility(View.GONE);
- }
- }
- break;
-
- case Constants.PrankSendData:
- //整蛊礼物刷新
- L.e("整蛊礼物刷新 整蛊礼物刷新 整蛊礼物刷新");
- if (map.getIntValue("action") == 13 && map.getString("msgtype").equals("4")){
- String ctString = map.getString("ct");
- L.e("整蛊礼物刷新 整蛊礼物刷新 整蛊礼物刷新 "+ctString);
- JsonElement jsonElement = JsonParser.parseString(ctString);
- if (jsonElement == null) break;
-// LogUtils.e("yqw=====>整蛊礼物列表:"+ctString);
- JsonObject jsonObject = jsonElement.getAsJsonObject();
- String content = WordUtil.isNewZh() ? jsonObject.get("msg").getAsString() : jsonObject.get("msg_en").getAsString();
- if(jsonObject.get("is_complete")!=null){
- String is_complete = jsonObject.get("is_complete").getAsString(); //0.未达成整蛊需要的数量 1.已达成整蛊
- if(is_complete.equals("1")){
- String user_name = jsonObject.get("user_name").getAsString(); //用户昵称
- String prank_content = jsonObject.get("prank_content").getAsString(); //整蛊内容
- String gift_count = jsonObject.get("gift_count").getAsString(); // 礼物数量
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setUserNiceName(user_name);
- chatBean.setGiftName(jsonObject.get("gift_name").getAsString());
- chatBean.setGiftname_en(jsonObject.get("gift_name_en").getAsString());
- chatBean.setHot_num(gift_count);
- chatBean.setContent(prank_content);
- chatBean.setType(TYPE_TO_ANCHOR_PRANK_GIFT);
- mListener.onChat(chatBean, 1);
- }
- }else{
- if (!TextUtils.isEmpty(content)){
- systemChatMessage2(content);
- }
- }
- if(CommonAppConfig.getInstance().getUid().equals(mLiveUid)&&"完成1次!".equals(jsonObject.get("msg").getAsString())){
- Toast toast = Toast.makeText(mContext,WordUtil.isNewZh()?jsonObject.get("msg").getAsString():jsonObject.get("msg_en").getAsString(),Toast.LENGTH_LONG);
- toast.show();
- }
- mListener.onUpdatePrankProgress(ctString);
- }
- break;
- case Constants.SOCKET_KICK://踢人
- systemChatMessage2(map.getString("ct"));
- mListener.onKick(map.getString("touid"));
- break;
- case Constants.SOCKET_SHUT_UP://禁言
- String ct = map.getString("ct");
- systemChatMessage2(ct);
- mListener.onShutUp(map.getString("touid"), ct);
- break;
- case Constants.SOCKET_SEND_MSG://文字消息,点亮,用户进房间,这种混乱的设计是因为服务器端逻辑就是这样设计的,客户端无法自行修改
- wordLightEnterRoom(map, received);
- L.e("收到socket---> 文字消息" + socketMsg);
- break;
- case Constants.SOCKET_LIGHT://飘心
- mListener.onLight();
- break;
- case Constants.SOCKET_SEND_GIFT://送礼物
- sendGiftInSameRoom(map);
- break;
-
-// case Constants.SOCKET_SEND_GIFT://送礼物
-// ////////pk
-// break;
- case Constants.SOCKET_LIVE_DRPK_RANDOM:
- case Constants.SOCKET_LIVE_DRPK://多人PK
- int action3 = map.getIntValue("action");
- //收到多人PK邀请
- if (action3 == 1) {
- UserBean u = new UserBean();
- u.setUserNiceName(map.getString("uname"));
- u.setId(map.getString("uid"));
- mListener.onLinkDRMicPkApply(u);
- }
- //收到对方同意多人PK邀请
- else if (action3 == 2) {
-// 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);
- }
-// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time"));
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE)
- .setPkScores(map.getJSONArray("userlist"))
- .setUid(mLiveUid)
- .setTime(map.getIntValue("drpk_time")));
- if (livePushRyViewHolder == null) {
- // LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
- );
- }
-
-
- } else if (action3 == 5) {
-// endDRGif();
- LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE);
- if (LiveRyAnchorActivity.mLiveAnchorViewHolder != null) {
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- params.topMargin = 0;
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM));
- isDRPK = 0;
- } else {
- // LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW)
- );
-
- }
- //創建了多人房間
- } else if (action3 == 3) {
- /* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
- LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
- }*/
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
- );
- isDRPK = 1;
- } else if (action3 == 10) {
- if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) {
- // LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
- );
- }
- }
-
- break;
- case Constants.SOCKET_ALL_SERVER_NOTIFY://全服通知
- int action2 = map.getIntValue("action");
- if (action2 == 71) {
- LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
- receiveGiftBean.setVipName(map.getString("ct"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- receiveGiftBean.setAllServerNotify(true);
- mListener.onSys(receiveGiftBean);
- } else if (action2 == 61) {//赠送礼物 超级头条
- sendGiftByNotify(map);
- } else if (action2 == 62) {//购买守护
-// buyGuardByNotify(map);
-// }else if (action2 == 63){
- } else if (action2 == 63) {//购买vip
- buyVipByNotify(map);
- } else if (action2 == 64) {//购买靓号
- buyLiangNameByNotify(map);
- } else if (action2 == 65) {//购买坐骑
- buyZuoJiByNotify(map);
- } else if (action2 == 66) {//购买贵族
- buyVipByNotify(map);
- } else if (action2 == 88) {//盲盒
- JSONObject mCt = map.getJSONObject("ct");
- String boxType = map.getString("box_type");
- String boxTypeName = "";
- if (TextUtils.equals(boxType, "1")) {
- boxTypeName = WordUtil.isNewZh() ? "迷你盲盒" : "Mini blind box";
- } else if (TextUtils.equals(boxType, "2")) {
- boxTypeName = WordUtil.isNewZh() ? "典藏盲盒" : "Collection blind box";
- } else {
- boxTypeName = WordUtil.isNewZh() ? "POYO盲盒" : "POYO blind box";
- }
- AllServerNotifyEvent allServerNotifyEvent
- = new AllServerNotifyEvent()
- .setBlindBoxId(map.getString("blind_box_id"))
- .setBoxType(boxType)
- .setBoxTypeName(boxTypeName)
- .setDressName(WordUtil.isNewZh() ? map.getString("dress_name") : TextUtils.isEmpty(map.getString("dress_nameen")) ? map.getString("dress_name") : map.getString("dress_nameen"))
- .setGiftNotification(map.getString("gift_notification"))
- .setGiftName(WordUtil.isNewZh() ? mCt.getString("giftname") : mCt.getString("giftnameen"))
- .setUserNiceName(map.getString("uname"))
- .setGiftIcon(map.getString("gifticon"))
- .setAnchorName(map.getString("ancherName"))
- .setDisplaySrc(map.getString("display_src"));
- Log.e("AllServerNotifyEvent", allServerNotifyEvent.toString());
- Log.e("AllServerNotifyEvent", map.toJSONString());
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX)
- .setAllServerNotifyEvent(allServerNotifyEvent));
- } else if (action2 == 89) {//红包
- JSONObject mCt = map.getJSONObject("ct");
- AllServerNotifyEvent allServerNotifyEvent
- = new AllServerNotifyEvent()
- .setUserNiceName(mCt.getString("user_nicename"))
- .setGiftName(WordUtil.isNewZh() ? map.getString("giftname") : map.getString("giftname_en"))
- .setGiftIcon(mCt.getString("gifticon"))
- .setRedPacket(true);
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX)
- .setAllServerNotifyEvent(allServerNotifyEvent));
- } else if (action2 == 90) {
- NewAllServerNotifyGuardEvent notifyGuardEvent = GsonUtils.fromJson(map.toString(), NewAllServerNotifyGuardEvent.class);
- Bus.get().post(notifyGuardEvent);
- if(mLiveUid.equals(map.getString("liveuid"))){
- buyGuardInSameRoom(map);
- }
- } else if (action2 == 91) {//通用模板
- AllServerNotifyFFGGGDJANEvent notifyFFGGGDJANEvent = GsonUtils.fromJson(map.toString(), AllServerNotifyFFGGGDJANEvent.class);
- Bus.get().post(notifyFFGGGDJANEvent);
- }
- break;
- case Constants.SOCKET_SEND_BARRAGE://发弹幕
- LiveDanMuBean liveDanMuBean2 = new LiveDanMuBean();
- liveDanMuBean2.setAvatar(map.getString("uhead"));
- liveDanMuBean2.setUserNiceName(map.getString("uname"));
- liveDanMuBean2.setContent(map.getString("ct"));
- if (map.containsKey("fansLevel")) {
- liveDanMuBean2.setFensLevel(map.getInteger("fansLevel"));
- }
- mListener.onSendDanMu(liveDanMuBean2);
- break;
- case Constants.SOCKET_LEAVE_ROOM://离开房间
- UserBean u = JSON.parseObject(map.getString("ct"), UserBean.class);
- mListener.onLeaveRoom(u);
- break;
- case Constants.SOCKET_LIVE_END://主播关闭直播
- int action = map.getIntValue("action");
- if (action == 18) {
- mListener.onLiveEnd();
- LiveEndViewHolder.upData(map.getString("votes"), map.getString("length"), map.getIntValue("nums"), map.getString("uname"));
- } else if (action == 19) {
- mListener.onAnchorInvalid();
- }
- //主播强制下播
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LIVE_END)
- .setVotes(map.getString("votes"))
- .setLength(map.getString("length"))
- .setNums(map.getIntValue("nums"))
- .setUname(map.getString("uname")));
- break;
- case Constants.SOCKET_CHANGE_LIVE://主播切换计时收费类型
- mListener.onChangeTimeCharge(map.getIntValue("type_val"));
- break;
- case Constants.SOCKET_UPDATE_VOTES:
- mListener.onUpdateVotes(map.getString("uid"), map.getString("votes"), map.getIntValue("isfirst"));
- break;
- case Constants.SOCKET_FAKE_FANS:
- JSONObject obj = map.getJSONObject("ct");
- String s = obj.getJSONObject("data").getJSONArray("info").getJSONObject(0).getString("list");
- L.e("僵尸粉--->" + s);
- List list = JSON.parseArray(s, LiveUserGiftBean.class);
- mListener.addFakeFans(list);
- break;
- case Constants.SOCKET_SET_ADMIN://设置或取消管理员
- systemChatMessage2(map.getString("ct"));
- mListener.onSetAdmin(map.getString("touid"), map.getIntValue("action"));
- break;
- case Constants.SUPER_VISION://设置或取消管理员
- systemChatMessage2(map.getString("ct"));
- break;
- case Constants.SOCKET_BUY_GUARD://购买守护
- buyGuardInSameRoom(map);
- break;
- case Constants.SOCKET_LINK_MIC://连麦
- processLinkMic(map);
- break;
- case Constants.SOCKET_LINK_MIC_ANCHOR://主播连麦
- processLinkMicAnchor(map);
- break;
- case Constants.SOCKET_LINK_MIC_PK://主播PK
- processAnchorLinkMicPk(map);
- break;
- case Constants.SOCKET_RED_PACK://红包消息
- String uid = map.getString("uid");
- if (TextUtils.isEmpty(uid)) {
- return;
- }
- LiveChatBean liveChatBean = new LiveChatBean();
- liveChatBean.setType(LiveChatBean.RED_PACK);
- liveChatBean.setId(uid);
- String name = uid.equals(mLiveUid) ? mContext.getString(R.string.live_anchor) : map.getString("uname");
- liveChatBean.setContent(name + map.getString("ct"));
- mListener.onRedPack(liveChatBean);
- break;
-
- case Constants.SOCKET_LUCK_WIN://幸运礼物中奖
- mListener.onLuckGiftWin(map.toJavaObject(LiveLuckGiftWinBean.class));
- break;
-
- case Constants.SOCKET_PRIZE_POOL_WIN://奖池中奖
- mListener.onPrizePoolWin(map.toJavaObject(LiveGiftPrizePoolWinBean.class));
- break;
- case Constants.SOCKET_PRIZE_POOL_UP://奖池升级
- mListener.onPrizePoolUp(map.getString("uplevel"));
- break;
- case Constants.SOCKET_HOUR://小时榜
- liveChatBean = new LiveChatBean();
- liveChatBean.setId("-1");
- liveChatBean.setType(LiveChatAdapter.MSG_HOUR_RANK_CHANGE);
- liveChatBean.setContent(map.getJSONObject("ct").getString("text"));
- mListener.onHourRank(liveChatBean, map.getJSONObject("ct").getJSONObject("new_rank"));
- break;
- //游戏socket
- case Constants.SOCKET_GAME_ZJH://游戏 智勇三张
- if (CommonAppConfig.GAME_ENABLE) {
- mListener.onGameZjh(map);
- }
- break;
- case Constants.SOCKET_GAME_HD://游戏 海盗船长
- if (CommonAppConfig.GAME_ENABLE) {
- mListener.onGameHd(map);
- }
- break;
- case Constants.SOCKET_GAME_ZP://游戏 幸运转盘
- if (CommonAppConfig.GAME_ENABLE) {
- mListener.onGameZp(map);
- }
- break;
- case Constants.SOCKET_GAME_NZ://游戏 开心牛仔
- if (CommonAppConfig.GAME_ENABLE) {
- mListener.onGameNz(map);
- }
- break;
- case Constants.SOCKET_GAME_EBB://游戏 二八贝
- if (CommonAppConfig.GAME_ENABLE) {
- mListener.onGameEbb(map);
- }
- break;
- case Constants.SOCKET_SEND_ACTIVE_MSG://新增,活动聊天显示
- sendActiveMsg(map, received);
- break;
- case Constants.SOCKET_PRANKTURNTABLE://新增,整蛊消息
- mListener.prankTurntable(map.getString("msgtype"), map.getIntValue("time"), JSON.parseObject(map.getString("ct")));
- String msgtype = map.getString("msgtype");
- JSONObject jsonObject = JSON.parseObject(map.getString("ct"));
-// if ("1".equals(msgtype)) {//新年大作战活动
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setId(jsonObject.getString("uid"));
- chatBean.setUserNiceName(jsonObject.getString("user_nicename"));
- if ("1".equals(map.getString("msgtype"))) {
- chatBean.setType(-3);
- } else {
- chatBean.setType(-4);
- }
- chatBean.setContent(jsonObject.getString("content"));
- chatBean.setBubble(jsonObject.getString("display_src"));
- chatBean.setMedal(jsonObject.getString("hope_nicename"));//做为拯救人名字
- chatBean.setAnchorName(jsonObject.getString("anchor_nicename"));
- mListener.onChat(chatBean, 1);
-// }
- break;
- case Constants.SOCKET_USEHOTCARD://新增,热度卡消息
-// mListener.prankTurntable(map.getString("msgtype"), map.getIntValue("time"), JSON.parseObject(map.getString("ct")));
- JSONObject jsonObject2 = JSON.parseObject(map.getString("ct"));
- LiveChatBean chatBean2 = new LiveChatBean();
- chatBean2.setType(-6);
- chatBean2.setBubble(jsonObject2.getString("system_bubble"));
- chatBean2.setId(jsonObject2.getString("user_id"));
- chatBean2.setUserNiceName(jsonObject2.getString("user_name"));
- chatBean2.setHot_num(jsonObject2.getString("hot_num"));
- chatBean2.setHot_card(jsonObject2.getString("hot_card"));
- getIsHot();
- mListener.onChat(chatBean2, 1);
- break;
- case Constants.LOVE_CHECK://甜蜜
- JSONObject jsonObject3 = JSON.parseObject(map.getString("ct"));
- LiveChatBean chatBean3 = new LiveChatBean();
- chatBean3.setType(-7);
- chatBean3.setBubble(jsonObject3.getString("system_bubble"));
- chatBean3.setId(jsonObject3.getString("user_id"));
- chatBean3.setUserNiceName(jsonObject3.getString("user_name"));
- chatBean3.setHot_num(jsonObject3.getString("gift_name"));
- mListener.onChat(chatBean3, 1);
- break;
- case Constants.TRUMPET_NOTIFY://全站喇叭
- SocketModel model = GsonUtils.fromJson(socketMsg, SocketModel.class);
- List msg = model.getMsg();
- if (msg.size() > 0) {
-// EventBus.getDefault().post(msg.get(0));
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.TRUMPET_NOTIFY)
- .setMsgModel(msg.get(0)));
- }
- break;
- case Constants.RECOMMEND_CARD_NOTIFY://推荐卡消息通知
- SocketModel recommendCardNotifyModel = GsonUtils.fromJson(socketMsg, SocketModel.class);
- List recommendCardNotifyMsg = recommendCardNotifyModel.getMsg();
- if (recommendCardNotifyMsg.size() > 0) {
-
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.RECOMMEND_CARD_NOTIFY)
- .setMsgModel(recommendCardNotifyMsg.get(0)));
- }
- break;
- case Constants.STAR_CHALLENGE_UPDATE://星级助力
-// SocketModel starChallengeModel = GsonUtils.fromJson(socketMsg, SocketModel.class);
-// List starChallengeMsg = starChallengeModel.getMsg();
-// if (starChallengeMsg.size() > 0) {
-//
-// Bus.get().post(new LiveAudienceEvent()
-// .setType(LiveAudienceEvent.LiveAudienceType.START_MESSAGE)
-// .setMsgModel(starChallengeMsg.get(0)));
-// }
- break;
- case Constants.AI_AUTOMATIC_SPEECH:
- case Constants.AI_AUTOMATIC_SPEECH_LIVE:
- //{"name_color":"#f19ec2","ai_name":"助手小小P","content":"@1 ","user_name":"1","icon":"https://downs.yaoulive.com/xzs_tab.png","system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"}
- AiAutomaticSpeechModel aiAutomaticSpeechModel = GsonUtils.fromJson(map.getString("ct"), AiAutomaticSpeechModel.class);
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.AI_AUTOMATIC_SPEECH)
- .setAiAutomaticSpeechModel(aiAutomaticSpeechModel));
- break;
- case Constants.STAR_CHALLENGE_UPGRADE_NOTIFY:
- SocketModel starChallengeUpgradeNotify = GsonUtils.fromJson(socketMsg, SocketModel.class);
- List starChallengeUpgradeNotifyMsg = starChallengeUpgradeNotify.getMsg();
- if (starChallengeUpgradeNotifyMsg.size() > 0) {
-
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.STAR_CHALLENGE_UPGRADE_NOTIFY)
- .setMsgModel(starChallengeUpgradeNotifyMsg.get(0)));
- }
- break;
- case Constants.LuckyAngel:
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LUCKY_ANGEL)
- .setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
- break;
- case Constants.Lucky100Check:
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LUCKY_100_CHECK)
- .setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
- break;
- case Constants.PK_RANK_UPDATE:
- Log.i("PK排位", map.toString());
- JSONObject item = map.getJSONObject("ct");
- PkRankBean pkRankBean = new PkRankBean();
- pkRankBean.setId(Integer.parseInt(item.getString("new_rank_id")));
- pkRankBean.setName(item.getString("new_rank_name"));
- pkRankBean.setImg(item.getString("new_rank_img"));
- pkRankBean.setNewRankNameEn(item.getString("new_rank_name_en"));
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_UPDATE)
- .setObject(pkRankBean));
- break;
- case Constants.CUSTOM_FULL_SERVICE_NOTIFY:
- Log.e("全服通知", map.toString());
- CustomFullServiceNotifyEvent customFullServiceNotifyEvent = GsonUtils.fromJson(map.toString(), CustomFullServiceNotifyEvent.class);
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.CUSTOM_FULL_SERVICE_NOTIFY)
- .setCustomFullServiceNotifyEvent(customFullServiceNotifyEvent));
- break;
- case Constants.XYD_COMPLETE:
-
-// xydComplete(map);
- XydCompleteModel xydCompleteModel = GsonUtils.fromJson(map.toString(), XydCompleteModel.class);
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.XYD_COMPLETE)
- .setXydCompleteModel(xydCompleteModel)
- .setLiveReceiveGiftBean(JSON.parseObject(map.toString(), LiveReceiveGiftBean.class)));
- break;
- case "GuardSpecialEffect":
- LiveReceiveGiftBean giftBean = JSON.parseObject(map.toString(), LiveReceiveGiftBean.class);
- giftBean.setMedal_name(map.getString("medal_name"));
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.GuardSpecialEffect)
- .setLiveReceiveGiftBean(giftBean));
- break;
- case Constants.WISH_LIST_PROGRESS:
- StringBuffer conString = new StringBuffer();
- conString.append(WordUtil.isNewZh() ? map.getString("msg") : map.getString("msg_en"));
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST_PROGRESS)
- .setWishListProgress(new WishModel()
- .setWishlistProgress(map.getString("wishlist_progress"))
- .setWishlistIcon(map.getString("wishlist_icon"))
- .setWishlistName(map.getString("wishlist_name"))
- .setWishlistNum(map.getString("wishlist_num"))
- .setGiftType(map.getInteger("giftId"))
- .setLuid(conString.toString())).setUname(map.getString("userName")).setLiveType(Integer.parseInt(map.getString("level"))));
- break;
- case Constants.LIVE_VOTE_CREATE:
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.VOTE_CREATE)
- .setObject(map)
- );
- break;
- case Constants.LIVE_VOTE_END:
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.VOTE_END)
- .setObject(map)
- );
- EventBus.getDefault().post(new LiveAnchorEvent()
- .setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END)
- .setObject(map)
- );
- break;
- case Constants.LIVE_VOTE_UPDATE:
- //通知给观众
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.VOTE_UPDATE)
- .setObject(map)
- );
- //通知给主播
- EventBus.getDefault().post(new LiveAnchorEvent()
- .setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE)
- .setObject(map)
- );
- break;
- case Constants.LIVE_PK_END:
-
- mListener.onEndPk(map.getLong("uid"),
- map.getLong("pkuid"),
- map.getLong("uid_score"),
- map.getLong("pkuid_score"),
- JSONObject.parseObject(map.getJSONObject("ct").getJSONObject("pk_top_users").toJSONString(), LivePKUserListBean.class)
- );
- break;
- case Constants.RED_PACKET:
- RedPacketModel redPacketModel = GsonUtils.fromJson(map.toString(), RedPacketModel.class);
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET)
- .setRedPacketModel(redPacketModel));
- break;
- case Constants.RED_PACKET_SUPER_JACKPOT:
- RedPacketInfoModel redPacketInfoModel = GsonUtils.fromJson(map.toString(), RedPacketInfoModel.class);
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET_SUPER_JACKPOT)
- .setRedPacketInfoModel(redPacketInfoModel));
- break;
- case "GiftWallIlluminate":
- Log.e("GiftWallIlluminate", map.toString());
- Bus.get().post(new GiftWallIlluminateEvent()
- .setNewNumber(map.getInteger("new_number"))
- .setMaxNumber(map.getInteger("max_number")));
- break;
- case SOCKET_LIVE_MSG_TO_USER:
- sendToUserMsg(map);
- break;
- case "SudGameCreateRoom":
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM)
- .setAvatar(WordUtil.isNewZh() ? map.getString("sud_game_name") : map.getString("sud_game_name_en"))
- .setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class)));
- break;
- case "sendQuickGift":
- SendQuickGiftModel sendQuickGiftModel = GsonUtils.fromJson(map.toString(), SendQuickGiftModel.class);
- StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(sendQuickGiftModel.getUserNicename())
- .append(WordUtil.isNewZh() ? " 送出了 " : " sent ")
- .append(sendQuickGiftModel.getQuickGiftNumber())
- .append(WordUtil.isNewZh() ? " 個小熊 " : " small pandas ");
- systemChatMessage2(stringBuffer.toString());
- Bus.get().post(new QuickGiftingEvent().setHotNum(sendQuickGiftModel.getHotNum()));
- break;
- case Constants.LIVE_PK_RANDOM_START:
- item = map.getJSONObject("ct");
- item.getString("text");
- item.getString("pktt_img");
- item.getString("uid_win_continuity");
- item.getString("pkuid_win_continuity");
- pkRankBean = new PkRankBean();
- pkRankBean.setBlueVal(item.getString("pkuid_win_continuity"));
- pkRankBean.setRedVal(item.getString("uid_win_continuity"));
- pkRankBean.setPkTopImgUrl(item.getString("pktt_img"));
-
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_START)
- .setObject(pkRankBean));
- break;
- case "guardMaturityDateRemind":
- GuardMaturityDateRemindModel maturityDateRemindModel = GsonUtils.fromJson(map.toString(), GuardMaturityDateRemindModel.class);
- Bus.get().post(maturityDateRemindModel);
- break;
- case "SendMoneyLong":
- SendMoneyLongModel sendMoneyLongModel = GsonUtils.fromJson(map.toString(), SendMoneyLongModel.class);
- Bus.get().post(sendMoneyLongModel);
- break;
- case "SendMoneyLongEnd":
- Bus.get().post(new SendMoneyLongEndEvent());
- break;
- case Constants.SOCKET_LIVE_ANCHOR_PK_DIALOG:
- item = map.getJSONObject("ct");
- //DialogUitl.showSimpleDialog(mContext,WordUtil.isNewZh()?item.getString("text"):item.getString("text_en"),null);
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LIVE_DIALOG_ANCHOR_TIPS)
- .setObject(WordUtil.isNewZh() ? item.getString("text") : item.getString("text_en")));
- break;
-
- }
- }
-
- private void buyGuardInSameRoom(JSONObject map) {
- if (TextUtils.isEmpty(map.getString("ancherName")) || TextUtils.isEmpty(map.getString("uname")))
- return;
- String guardName = WordUtil.isNewZh() ? "星之守護" : "Star Guardian";
- switch (map.getIntValue("guard_type")) {
- case 1:
- guardName = WordUtil.isNewZh() ? "星之守護" : "Star Guardian";
- break;
- case 2:
- guardName = WordUtil.isNewZh() ? "王之守護" : "King Guardian";
- break;
- case 3:
- guardName = WordUtil.isNewZh() ? "神之守護" : "God Guardian";
- break;
- }
- String content = WordUtil.isNewZh() ? "%s在%s的直播間開通了%s" : "%s has been opened in %s live broadcast room %s";
- content = String.format(content, map.getString("uname"), map.getString("ancherName"), guardName);
- LiveBuyGuardMsgBean buyGuardMsgBean = new LiveBuyGuardMsgBean();
- buyGuardMsgBean.setUid(map.getString("uid"));
- buyGuardMsgBean.setUserName(content);
- buyGuardMsgBean.setVotes(map.getString("votestotal"));
- buyGuardMsgBean.setGuardNum(map.getIntValue("guard_nums"));
- buyGuardMsgBean.setGuardType(map.getIntValue("guard_type"));
- mListener.onBuyGuard(buyGuardMsgBean);
- }
-
- private void buyGuardByNotify(JSONObject map) {
- if (mLiveUid.equals(map.getString("liveuid"))) {
-// buyGuardInSameRoom(map);
- //同一直播间,玩家自己开通,也能看到全服通知
- String userId = CommonAppConfig.getInstance().getUid();
- String uid = map.getString("uid");
- if (userId.equals(uid)) {
- LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
- receiveGiftBean.setUserNiceName(map.getString("uname"));
- receiveGiftBean.setAncherName(map.getString("ancherName"));
- receiveGiftBean.setmLiveUId(mLiveUid);
- receiveGiftBean.setRoomnum(map.getString("liveuid"));
- receiveGiftBean.setmTypeBuyGuard(true);
- receiveGiftBean.setUid(uid);
- receiveGiftBean.setGuardType(map.getString("guard_type"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- mListener.onSendGift(receiveGiftBean, null);
- }
- } else {
- LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
- receiveGiftBean.setUserNiceName(map.getString("uname"));
- receiveGiftBean.setAncherName(map.getString("ancherName"));
- receiveGiftBean.setmLiveUId(mLiveUid);
- receiveGiftBean.setRoomnum(map.getString("liveuid"));
- receiveGiftBean.setmTypeBuyGuard(true);
- receiveGiftBean.setUid(map.getString("uid"));
- receiveGiftBean.setGuardType(map.getString("guard_type"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- mListener.onSendGift(receiveGiftBean, null);
- }
- }
-
-
- private void buyZuoJiByNotify(JSONObject map) {
- LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
- receiveGiftBean.setUserNiceName(map.getString("nickname"));
- receiveGiftBean.setCarName(map.getString("carname"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- mListener.onBuyZuoji(receiveGiftBean);
- }
-
-
- private void buyLiangNameByNotify(JSONObject map) {
- LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
- receiveGiftBean.setUserNiceName(map.getString("nickname"));
- receiveGiftBean.setLiangName(map.getString("liangname"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- mListener.onBuyLiangName(receiveGiftBean);
- }
-
- private void buyVipByNotify(JSONObject map) {
- LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
- receiveGiftBean.setUserNiceName(map.getString("nicename"));
- receiveGiftBean.setVipName(map.getString("ct"));
- receiveGiftBean.setAvatar(map.getString("notice"));
- receiveGiftBean.setAllServerNotify(true);
- receiveGiftBean.setmLiveUId(map.getString("anchorUid"));
- receiveGiftBean.setGifUrl(map.getString("special_src"));
- receiveGiftBean.setVipTime(map.getString("viplength"));
- receiveGiftBean.setRoomnum(map.getString("anchorUid"));
- receiveGiftBean.setAncherName(map.getString("ancherName"));
- receiveGiftBean.setNobilityid(map.getString("nobilityid"));
- receiveGiftBean.setNobilityname(map.getString("nobilityname"));
- receiveGiftBean.setOpentype(map.getString("opentype"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- receiveGiftBean.setUname(map.getString("uname"));
- receiveGiftBean.setUhead(map.getString("uhead"));
- if (map.getString("notice").equals("1")) {
- LiveRoomViewHolder.paygzGif(map.getString("special_src"), map.getString("anchorUid"));
- }
- mListener.onBuyVip(receiveGiftBean);
- }
-
- private void sendActiveMsg(JSONObject map, SocketReceiveBean received) {
- String msgtype = map.getString("msgtype");
- if ("1".equals(msgtype)) {//新年大作战活动
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setId(map.getString("uid"));
- chatBean.setMedalLevelImageUrl(map.getString("monster_str"));//昵称暂时做为活动图片地址
- chatBean.setContent(map.getString("url"));//暂时做为活动链接地址
- chatBean.setUserNiceName(map.getString("activename"));
- chatBean.setType(6);
- mListener.onChat(chatBean, 0);
- }
- }
-
- /**
- * 七日留存新用户主播端弹幕显示接口
- */
- private void sendToUserMsg(JSONObject map) {
- LiveChatBean bean = new LiveChatBean();
- bean.setId(map.getString("uid"));
- bean.setAtUserID(map.getString("toUserID"));
- bean.setContent(map.getString("ct"));
- bean.setType(LiveChatBean.TYPE_TO_USER_MSG);
- bean.setUserNiceName(map.getString("user_nicename"));
- bean.setToUid(CommonAppConfig.getInstance().getUid());
- mListener.onChat(bean, 1);
- }
-
- private void wordLightEnterRoom(JSONObject map, SocketReceiveBean received) {
- String msgtype = map.getString("msgtype");
- if ("2".equals(msgtype)) {//发言,点亮
- if ("409002".equals(received.getRetcode())) {
- ToastUtil.show(WordUtil.isNewZh() ? "你已經被禁言" : "You\'ve been banned");
- return;
- }
-
- //禁言别人,自己发言只能自己看到
- if ("409100".equals(received.getRetcode())) {
- String uid = map.getString("uid");
- if (uid == null || !uid.equals(CommonAppConfig.getInstance().getUid())) {
- return;
- }
- }
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setId(map.getString("uid"));
- chatBean.setUserNiceName(map.getString("uname"));
- chatBean.setLevel(map.getIntValue("level"));
- chatBean.setAnchor(map.getIntValue("isAnchor") == 1);
- chatBean.setManager(map.getIntValue("usertype") == Constants.SOCKET_USER_TYPE_ADMIN);
- chatBean.setContent(map.getString("ct"));
- int heart = map.getIntValue("heart");
- chatBean.setHeart(heart);
- if (heart > 0) {
- chatBean.setType(LiveChatBean.LIGHT);
- }
- chatBean.setLiangName(map.getString("liangname"));
- chatBean.setBubble(map.getString("bubble"));
- chatBean.setMedal(map.getString("medal"));
- chatBean.setMedal_new(map.getString("medal_new"));
- chatBean.setMedal_new_en(map.getString("medal_new_en"));
- chatBean.setVipType(map.getIntValue("vip_type"));
- chatBean.setVipType(map.getIntValue("vip_type"));
- chatBean.setMedal_honor(map.getString("medal_honor"));
- chatBean.setGood_nub(map.getString("good_num"));
- chatBean.setNobleId(map.getString("noble_id"));//貴族ID
- chatBean.setStartColor(map.getString("startColor"));//昵称开始颜色
- chatBean.setEndColor(map.getString("endColor"));//昵称结束颜色
- chatBean.setContentColor(map.getString("contentColor"));//文字内容颜色
- chatBean.setAtUserName(map.getString("atUserName"));//@名字
- chatBean.setAtUserID(map.getString("atUserID"));//@ID
- if (map.containsKey("guard_type") && !map.getString("guard_type").equals("undefined")) {
- chatBean.setGuardType(map.getIntValue("guard_type"));
- }
- try {
- //增加粉丝徽章信息
- chatBean.setMedalNmae(map.getString("medal_name"));
- chatBean.setMedal_new_en(map.getString("medal_new_en"));
- FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
- if (fansMedalBean != null)
- chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- if (!"".equals(map.getString("prankIcon")) && map.getString("prankIcon") != null) {
- chatBean.setPrankIcon(map.getString("prankIcon"));
- chatBean.setType(-5);
- }
- mListener.onChat(chatBean, 1);
- } else if ("0".equals(msgtype)) {//用户进入房间
- JSONObject obj = JSON.parseObject(map.getString("ct"));
- LiveUserGiftBean u = GsonUtils.fromJson(obj.toJSONString(), LiveUserGiftBean.class);
- UserBean.Vip vip = new UserBean.Vip();
- int vipType = obj.getIntValue("vip_type");
- vip.setType(vipType);
- u.setVip(vip);
- UserBean.Car car = new UserBean.Car();
- car.setId(obj.getIntValue("car_id"));
- car.setSwf(obj.getString("car_swf"));
- car.setSwftime(obj.getFloatValue("car_swftime"));
- car.setWords(obj.getString("car_words"));
- u.setCar(car);
- UserBean.Liang liang = new UserBean.Liang();
- String liangName = obj.getString("liangname");
- liang.setName(liangName);
- u.setLiang(liang);
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setType(LiveChatBean.ENTER_ROOM);
- chatBean.setId(u.getId());
- chatBean.setMedal_honor(map.getString("medal_honor"));
- chatBean.setGood_nub(map.getString("good_num"));
- chatBean.setUserNiceName(u.getUserNiceName());
- chatBean.setLevel(u.getLevel());
- chatBean.setVipType(vipType);
- chatBean.setLiangName(liangName);
- chatBean.setBubble(obj.getString("bubble"));
- chatBean.setMedal(obj.getString("medal"));
- chatBean.setMedal_new(obj.getString("medal_new"));
- chatBean.setMedal_new_en(obj.getString("medal_new_en"));
- chatBean.setHot_num(obj.getString("hot_num"));
- UserBean.DressBean dressBean = new UserBean.DressBean();
- dressBean.setAvatar_frame(obj.getString("avatar_frame"));
- u.setDress(dressBean);
-
- chatBean.setManager(obj.getIntValue("usertype") == Constants.SOCKET_USER_TYPE_ADMIN);
- chatBean.setContent(mContext.getString(R.string.live_enter_room));
- chatBean.setGuardType(obj.getIntValue("guard_type"));
- chatBean.setNobleId(obj.getString("noble_id"));//貴族ID
- chatBean.setStartColor(obj.getString("startColor"));//昵称开始颜色
- chatBean.setEndColor(obj.getString("endColor"));//昵称结束颜色
- chatBean.setContentColor(obj.getString("contentColor"));//文字内容颜色
- chatBean.setNobleIcon(obj.getString("noble_icon"));//貴族圖標
- chatBean.setBubbleSrc(obj.getString("bubbleSrc"));//氣泡
- //增加粉丝徽章信息
- chatBean.setMedalNmae(obj.getString("medal_name"));
- chatBean.setUserNiceName(obj.getString("user_nicename"));//名字
- FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
- u.setFansLevel(obj.getIntValue("medal_level"));
- u.setFansEnterRoomUrl(obj.getString("medal_backgroup_thumb"));
- CommonAppConfig.getInstance().getUserBean().getDress().setMedal_new_en(obj.getString("medal_new_en"));
- if (fansMedalBean != null)
- chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
- mListener.onEnterRoom(new LiveEnterRoomBean(u, chatBean));
- }
- }
-
- //送礼物 全服通知
- private void sendGiftByNotify(JSONObject map) {
- LiveReceiveGiftBean receiveGiftBean = JSON.parseObject(map.getString("ct"), LiveReceiveGiftBean.class);
- receiveGiftBean.setAvatar(map.getString("uhead"));
- receiveGiftBean.setUserNiceName(map.getString("uname"));
- receiveGiftBean.setRoomnum(map.getString("roomnum"));
- receiveGiftBean.setAncherName(map.getString("ancherName"));
- receiveGiftBean.setHot_num(map.getString("hot_num"));
- receiveGiftBean.setSendtype(map.getIntValue("action"));
- receiveGiftBean.setmLiveUId(mLiveUid);
- receiveGiftBean.setmTypeBuyGuard(false);
- //全服通知时,不通知主播
- receiveGiftBean.setAllServerNotify(true);
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setUserNiceName(receiveGiftBean.getUserNiceName());
- chatBean.setLevel(receiveGiftBean.getLevel());
- chatBean.setBubble(map.getString("bubble"));
- chatBean.setMedal(map.getString("medal"));
- chatBean.setId(map.getString("uid"));
- chatBean.setMedal_honor(map.getString("medal_honor"));
- chatBean.setGood_nub(map.getString("good_num"));
- chatBean.setLiangName(map.getString("liangname"));
- chatBean.setVipType(map.getIntValue("vip_type"));
- chatBean.setType(LiveChatBean.GIFT);
- //增加粉丝徽章信息
- chatBean.setMedalNmae(map.getString("medal_name"));
- FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
- if (fansMedalBean != null)
- chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
- //聊天列表显示 玩家名 送 1 个 礼物名
-
- if (CommonAppContext.lang.equals("chinese")) {
- chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + receiveGiftBean.getGiftCount() + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftName());
- } else {
- chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen());
- }
-
- receiveGiftBean.setLiveChatBean(chatBean);
- if (map.getIntValue("ifpk") == 1) {
- if (!TextUtils.isEmpty(mLiveUid)) {
- //获取PK排名数据
- LivePKUserListBean livePKUserListBean = JSON.parseObject(receiveGiftBean.getPkTopUsers(), LivePKUserListBean.class);
- if (mLiveUid.equals(map.getString("roomnum"))) {
- if (!mLiveUid.equals(map.getString("roomnum"))) {
- mListener.onSendGift(receiveGiftBean, null);
- }
- //同一个直播间时才刷新pk
- mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
- } else {
- if (!mLiveUid.equals(map.getString("roomnum"))) {
- mListener.onSendGift(receiveGiftBean, null);
- }
- //同一个直播间时才刷新pk
- if (mLiveUid.equals(map.getString("pkuid1")) ||
- mLiveUid.equals(map.getString("pkuid2"))) {
- mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean);
- }
- }
- }
- } else {
- if (!mLiveUid.equals(map.getString("roomnum"))) {
- mListener.onSendGift(receiveGiftBean, null);
- }
- }
- }
-
- private void xydComplete(JSONObject map) {
- LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
- receiveGiftBean.setAvatar(map.getString("uhead") + "");
- receiveGiftBean.setUserNiceName(map.getString("uname"));
- receiveGiftBean.setRoomnum(map.getString("roomnum"));
- receiveGiftBean.setAncherName(map.getString("ancherName"));
- receiveGiftBean.setHot_num(map.getString("hot_num"));
- receiveGiftBean.setDrpk_status(map.getString("drpk_status"));
- receiveGiftBean.setGitType(map.getInteger("swftype "));
- receiveGiftBean.setmLiveUId(mLiveUid);
- receiveGiftBean.setmTypeBuyGuard(false);
- receiveGiftBean.setAllServerNotify(false);
- receiveGiftBean.setGifUrl(map.getString("svg"));
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setUserNiceName(receiveGiftBean.getUserNiceName());
- chatBean.setLevel(receiveGiftBean.getLevel());
- chatBean.setMedal_honor(map.getString("medal_honor"));
- chatBean.setId(map.getString("uid"));
- chatBean.setLiangName(map.getString("liangname"));
- chatBean.setVipType(map.getIntValue("vip_type"));
- chatBean.setBubble(map.getString("bubble"));
- chatBean.setMedal(map.getString("medal"));
- chatBean.setMedal_new(map.getString("medal_new"));
- chatBean.setMedal_new_en(map.getString("medal_new_en"));
- chatBean.setGood_nub(map.getString("good_num"));
- chatBean.setType(LiveChatBean.GIFT);
- if (map.get("guard_type") != null && !"".equals(map.get("guard_type")) && !"null".equals(map.get("guard_type"))) {
- chatBean.setGuardType(map.getInteger("guard_type"));
- }
- if (CommonAppContext.lang.equals("chinese")) {
- chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + receiveGiftBean.getGiftCount() + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftName());
- } else {
- chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen());
-
- }
- mListener.onSendGift(receiveGiftBean, null);
- }
-
- // 玩家自己送礼物
- private void sendGiftInSameRoom(JSONObject map) {
- String ctJson = map.getString("ct");
- SendBlindGiftEvent sendBlindGiftEvent = JSON.parseObject(ctJson, SendBlindGiftEvent.class);
- LiveReceiveGiftBean receiveGiftBean = JSON.parseObject(map.getString("ct"), LiveReceiveGiftBean.class);
- sendBlindGiftEvent.setUserNiceName(map.getString("uname"));
- receiveGiftBean.setAvatar(map.getString("uhead") + "");
- receiveGiftBean.setUserNiceName(map.getString("uname"));
- receiveGiftBean.setRoomnum(map.getString("roomnum"));
- receiveGiftBean.setAncherName(map.getString("ancherName"));
- receiveGiftBean.setHot_num(map.getString("hot_num"));
- receiveGiftBean.setDrpk_status(map.getString("drpk_status"));
- receiveGiftBean.setNamingCoin(map.getString("naming_live_name"));
- receiveGiftBean.setNamingLiveName(map.getString("naming_live_name"));
- receiveGiftBean.setNamingUid(map.getString("naming_uid"));
- receiveGiftBean.setNamingLiveuid(map.getString("naming_liveuid"));
- receiveGiftBean.setUser_naming_status(map.getInteger("user_naming_status"));
- receiveGiftBean.setmLiveUId(mLiveUid);
- receiveGiftBean.setmTypeBuyGuard(false);
- receiveGiftBean.setAllServerNotify(false);
- sendBlindGiftEvent.setGiftname_en(map.getString("giftname_en"));
- //获取PK排名数据
- LivePKUserListBean livePKUserListBean = JSON.parseObject(receiveGiftBean.getPkTopUsers(), LivePKUserListBean.class);
-
- LiveChatBean chatBean = new LiveChatBean();
- chatBean.setUserNiceName(receiveGiftBean.getUserNiceName());
- chatBean.setLevel(receiveGiftBean.getLevel());
- chatBean.setMedal_honor(map.getString("medal_honor"));
- chatBean.setId(map.getString("uid"));
- chatBean.setLiangName(map.getString("liangname"));
- chatBean.setVipType(map.getIntValue("vip_type"));
- chatBean.setBubble(map.getString("bubble"));
- chatBean.setMedal(map.getString("medal"));
- chatBean.setMedal_new(map.getString("medal_new"));
- chatBean.setMedal_new_en(map.getString("medal_new_en"));
- chatBean.setGood_nub(map.getString("good_num"));
- chatBean.setType(LiveChatBean.GIFT);
- if (map.get("guard_type") != null && !"".equals(map.get("guard_type")) && !"null".equals(map.get("guard_type"))) {
- chatBean.setGuardType(map.getInteger("guard_type"));
- }
- String special = "";
- if (sendBlindGiftEvent.getSpecialGift() == 1) {
- if (WordUtil.isNewZh()) {
- special = "送出" + receiveGiftBean.getGiftName() + sendBlindGiftEvent.getSpecialGiftName();
- } else {
- special = "Send " + receiveGiftBean.getGiftName() + sendBlindGiftEvent.getSpecialGiftNameEn();
- }
- chatBean.setContent(special);
- } else {
- if (WordUtil.isNewZh()) {
- chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + receiveGiftBean.getGiftCount() + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftName() + special);
- } else {
- chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen() + special);
- }
- }
- //增加粉丝徽章信息
- chatBean.setMedalNmae(map.getString("medal_name"));
- FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
- if (fansMedalBean != null)
- chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
-
- receiveGiftBean.setLiveChatBean(chatBean);
-
- if (map.getIntValue("ifpk") == 1) {
- try {
- if (!TextUtils.isEmpty(mLiveUid)) {
- if (mLiveUid.equals(map.getString("roomnum"))) {
- mListener.onSendGift(receiveGiftBean, sendBlindGiftEvent);
- mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
- } else {
- mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- } else {
- Log.i("tvvs", receiveGiftBean.getLiveChatBean().getContent());
- if (!TextUtils.isEmpty(sendBlindGiftEvent.getAction()) && TextUtils.equals("blind_box", sendBlindGiftEvent.getAction())) {
- mListener.onSendGift(receiveGiftBean, sendBlindGiftEvent);
- } else {
- mListener.onSendGift(receiveGiftBean, null);
- }
-
- }
- if (map.getIntValue("drpk_status") == 1) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE)
- .setPkScores(map.getJSONArray("userlist"))
- .setUid(mLiveUid)
- .setTime(0));
-// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);
- }
-
- }
-
- /**
- * 接收到系统消息,显示在聊天栏中
- */
- private void systemChatMessage(String content) {
- LiveChatBean bean = new LiveChatBean();
- bean.setContent(content);
- bean.setType(LiveChatBean.SYSTEM);
- mListener.onChat(bean, 1);
- }
-
- /**
- * 接收到系统消息,显示在聊天栏中
- */
- private void systemChatMessage2(String content) {
- LiveChatBean bean = new LiveChatBean();
- bean.setContent(content);
- bean.setType(LiveChatBean.SYSTEM2);
- mListener.onChat(bean, 1);
- }
-
- /**
- * 处理观众与主播连麦逻辑
- */
- private void processLinkMic(JSONObject map) {
- int action = map.getIntValue("action");
- switch (action) {
- case 1://主播收到观众连麦的申请
- UserBean u = new UserBean();
- u.setId(map.getString("uid"));
- u.setUserNiceName(map.getString("uname"));
- u.setAvatar(map.getString("uhead"));
- u.setSex(map.getIntValue("sex"));
- u.setLevel(map.getIntValue("level"));
- mListener.onAudienceApplyLinkMic(u);
- break;
- case 2://观众收到主播同意连麦的消息
- if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
- mListener.onAnchorAcceptLinkMic();
- }
- break;
- case 3://观众收到主播拒绝连麦的消息
- if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
- mListener.onAnchorRefuseLinkMic();
- }
- break;
- case 4://所有人收到连麦观众发过来的流地址
- String uid = map.getString("uid");
- if (!TextUtils.isEmpty(uid) && !uid.equals(CommonAppConfig.getInstance().getUid())) {
- mListener.onAudienceSendLinkMicUrl(uid, map.getString("uname"), map.getString("playurl"));
- }
- break;
- case 5://连麦观众自己断开连麦
- mListener.onAudienceCloseLinkMic(map.getString("uid"), map.getString("uname"));
- break;
- case 6://主播断开已连麦观众的连麦
- mListener.onAnchorCloseLinkMic(map.getString("touid"), map.getString("uname"));
- break;
- case 7://已申请连麦的观众收到主播繁忙的消息
- if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
- mListener.onAnchorBusy();
- }
- break;
- case 8://已申请连麦的观众收到主播无响应的消息
- if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
- mListener.onAnchorNotResponse();
- }
- break;
- case 9://所有人收到已连麦的观众退出直播间消息
- mListener.onAudienceLinkMicExitRoom(map.getString("touid"));
- break;
- }
- }
-
- /**
- * 处理主播与主播连麦逻辑
- *
- * @param map
- */
- private void processLinkMicAnchor(JSONObject map) {
- int action = map.getIntValue("action");
- switch (action) {
- case 1://收到其他主播连麦的邀请的回调
- UserBean u = new UserBean();
- u.setId(map.getString("uid"));
- u.setUserNiceName(map.getString("uname"));
- u.setAvatar(map.getString("uhead"));
- u.setSex(map.getIntValue("sex"));
- u.setLevel(map.getIntValue("level"));
- u.setLevelAnchor(map.getIntValue("level_anchor"));
- mListener.onLinkMicAnchorApply(u, map.getString("stream"));
- break;
- case 3://对方主播拒绝连麦的回调
- mListener.onLinkMicAnchorRefuse();
- break;
- case 4://所有人收到对方主播的播流地址的回调
- mListener.onLinkMicAnchorPlayUrl(map.getString("pkuid"), map.getString("pkpull"));
- break;
- case 5://断开连麦的回调
- mListener.onLinkMicAnchorClose();
- break;
- case 7://对方主播正在忙的回调
- mListener.onLinkMicAnchorBusy();
- break;
- case 8://对方主播无响应的回调
- mListener.onLinkMicAnchorNotResponse();
- break;
- case 9://对方主播正在游戏
- mListener.onlinkMicPlayGaming();
- break;
- }
- }
-
- /**
- * 处理主播与主播PK逻辑
- *
- * @param map
- */
- private void processAnchorLinkMicPk(JSONObject map) {
- int action = map.getIntValue("action");
- Log.i("Socket", "action = " + action + " json = " + map.toString());
- L.eSw("RY RY RY RY "+map.toString());
- switch (action) {
- case 1://收到对方主播PK回调
- UserBean u = new UserBean();
- u.setId(map.getString("uid"));
- u.setUserNiceName(map.getString("pkname"));
- u.setAvatar(map.getString("pkhead"));
- mListener.onLinkMicPkApply(u, map.getString("stream"), 1);
- break;
- case 2://收到对方主播PK回调
- RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
- mListener.onLinkMicToPk(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"));
- mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
- break;
- case 3://对方主播拒绝PK的回调
- RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
- mListener.onLinkMicPkRefuse();
- break;
- case 4://所有人收到PK开始址的回调
- // RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
- EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_START).setObject(map.getString("pkuid")));
- mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));
- break;
- case 5://PK时候断开连麦的回调
-// if (rtcRoom != null) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.DISCONNEXT_PK_TIME));
- RCRTCEngine.getInstance().leaveOtherRoom(map.getString("pkuid"), true, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", map.getString("pkuid") + "退出多人成功a as");
-
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", map.getString("pkuid") + "退asa出多人失败" + rtcErrorCode);
-
- }
- });
- //断开连麦
- HttpClient.getInstance().post("chaxunshoudongpkcishu", "chaxunshoudongpkcishu")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
-
- }
- });
-// }
- mListener.onLinkMicPkClose(1);
- if (RandomPkManager.getInstance().isRandomModel()) {
- RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_DEFAULT);
- }
- break;
- case 7://对方主播正在忙的回调
- mListener.onLinkMicPkBusy();
- break;
- case 8://对方主播无响应的回调
- mListener.onLinkMicPkNotResponse();
- break;
- case 9://pk结束的回调
- mListener.onLinkMicPkEnd(map.getString("win_uid"));
- EventBus.getDefault().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_END));
- break;
- case 10://系统发起PK回调
- JSONObject msg1 = new JSONObject();
- msg1.put("type", "autoLivePK");
- msg1.put("uid", CommonAppConfig.getInstance().getUid());
- msg1.put("pkuid", CommonAppConfig.getInstance().getUid());
- msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
- msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar());
- IMRTCManager.getInstance().requestJoinOtherRoom(map.getString("uid"), true, msg1.toString(), new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- if (WordUtil.isNewZh()) {
- ToastUtil.show("邀请 " + map.getString("uid") + " 发送成功");
- } else {
- ToastUtil.show("invite " + map.getString("uid") + " successful");
- }
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- dismiss();
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- dismiss();
- }
- });
- //todo 安卓端状态码说明文档:https://docs.rongcloud.cn/v4/views/rtc/call/code/android.html
- Log.e("ry", rtcErrorCode + "aaaaaa" + CommonAppConfig.getInstance().getUid() + "VDSSSS" + map.getString("uid"));
- if (WordUtil.isNewZh()) {
- ToastUtil.show("邀请 " + map.getString("uid") + " 发送失败 :" + rtcErrorCode);
- } else {
- ToastUtil.show("invite " + map.getString("uid") + " lose :" + rtcErrorCode);
- }
- }
- });
- break;
- }
- }
- }
-}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyLinkMicPkUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyLinkMicPkUtil.java
deleted file mode 100644
index 523ee6447..000000000
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyLinkMicPkUtil.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package com.yunbao.live.socket;
-
-import android.util.Log;
-
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.Constants;
-import com.yunbao.common.bean.UserBean;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.http.HttpClient;
-import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
-
-import io.rong.imlib.IRongCallback;
-import io.rong.imlib.RongIMClient;
-import io.rong.imlib.model.Conversation;
-import io.rong.imlib.model.Message;
-import io.rong.message.TextMessage;
-
-public class SocketRyLinkMicPkUtil {
- /**
- * 发起PK申请
- *
- * @param pkUid 对方主播的uid
- * @param stream 自己直播间的stream
- */
- public static void linkMicPkApply(SocketRyClient client, String pkUid, String stream) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- }
-
-
- /**
- * 主播接受对方主播的Pk请求
- *
- * @param pkUid 对方主播的uid
- */
- public static void linkMicPkAccept(SocketRyClient client, String pkUid, String url, String name) {
- HttpClient.getInstance().get("xiugaizhiboxinxi", "xiugaizhiboxinxi")
- .params("uid", CommonAppConfig.getInstance().getUid())
- .params("pkuid", pkUid)
- .params("type", "1")
- .params("sign", "1")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msgs, String[] info) {
- if (code == 0) {
-
- HttpClient.getInstance().get("kaishipk", "kaishipk")
- .params("uid", CommonAppConfig.getInstance().getUid())
- .params("pkuid", pkUid)
- .params("type", "1")
- .params("sign", "1")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msgs, String[] info) {
- if (code == 0) {
- Log.e("ry",name+"啊啊"+url);
- final SocketSendBean msg1 = new SocketSendBean()
- .param("_method_", Constants.SOCKET_LINK_MIC_PK)
- .param("action", 4)
- .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
- .param("pkuid", pkUid)
- .param("uid", CommonAppConfig.getInstance().getUid())
- .param("pkhead", url)
- .param("pkname", name);
- msg1.create();
-
- Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- Message message1 = Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent);
-
- RongcloudIMManager.sendMessage(message1, null, null, new IRongCallback.ISendMessageCallback() {
- @Override
- public void onAttached(Message message) {
-
- }
-
- @Override
- public void onSuccess(Message message) {
- Log.i("tx", "发送成功");
- }
-
- @Override
- public void onError(Message message, RongIMClient.ErrorCode errorCode) {
-
- }
- });
- }
-
- }
- });
- }
- }
- });
-
-
- }
-
- /**
- * 主播接受对方主播的Pk请求
- *
- * @param pkUid 对方主播的uid
- */
- public static void linkMicDRPkAccept(String pkUid) {
-
-
- }
-
- /**
- * 主播拒绝其他主播的连麦请求
- */
- public static void linkMicPkRefuse(SocketRyClient client, String pkUid) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
- final SocketSendBean msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_LINK_MIC_PK)
- .param("action", 3)
- .param("msgtype", 0)
- .param("uid", u.getId())
- .param("uname", u.getUserNiceName())
- .param("pkuid", pkUid)
- .param("ct", "");
-
- msg.create();
-
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
- Message message = Message.obtain(pkUid, conversationType, messageContent);
-
- RongcloudIMManager.sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
- @Override
- public void onAttached(Message message) {
-
- }
-
- @Override
- public void onSuccess(Message message) {
- Log.i("tx", "发送成功");
- }
-
- @Override
- public void onError(Message message, RongIMClient.ErrorCode errorCode) {
-
- }
- });
-
- }
-
-
- /**
- * 主播断开连麦
- */
- public static void linkMicAnchorClose(SocketRyClient client, String pkUid) {
- if (client == null) {
- return;
- }
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- if (u == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
-// .param("action", 5)
-// .param("msgtype", 0)
-// .param("uid", u.getId())
-// .param("ct", "")
-// .param("pkuid", pkUid)
-// .param("uname", u.getUserNiceName()));
-
-
- }
-
- /**
- * 当收到主播连麦的请求时候主播正在忙
- */
- public static void linkMicPkBusy(SocketClient client, String pkUid) {
- if (client == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
-// .param("action", 7)
-// .param("msgtype", 10)
-// .param("pkuid", pkUid));
- }
-
- /**
- * 当收到主播连麦的请求时候主播无响应
- */
- public static void linkMicPkNotResponse(SocketRyClient client, String pkUid) {
- if (client == null) {
- return;
- }
-// client.send(new SocketSendBean()
-// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
-// .param("action", 8)
-// .param("msgtype", 10)
-// .param("pkuid", pkUid));
- }
-
-
-}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java
index 458d72a0f..edd9cefa4 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java
@@ -204,6 +204,8 @@ public class SocketSwClient {
SocketReceiveBean received = JSON.parseObject(socketMsg, SocketReceiveBean.class);
JSONObject map = received.getMsg().getJSONObject(0);
+ L.e("收到IM数据--->" + map.toString());
+
String ct="";
switch (map.getString("_method_")) {
//用户连麦
@@ -803,6 +805,19 @@ public class SocketSwClient {
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_DIALOG_ANCHOR_TIPS)
.setObject(WordUtil.isNewZh() ? item.getString("text") : item.getString("text_en")));
+ case Constants.SOCKET_SEND_NEW_TASK_PUSH:
+ item = map.getJSONObject("ct");
+ if(CommonAppConfig.getInstance().getUid().equals(item.getString("uid"))){
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_AUTHOR_NEW_TASK_PUSH).setUid(item.getString("uid")).setHrefUrl(item.getString("href")));
+ }
+ break;
+ case Constants.SOCKET_SEND_NEW_TASK_IM:
+ item = map.getJSONObject("ct");
+ if(CommonAppConfig.getInstance().getUid().equals(item.getString("uid"))){
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_AUTHOR_GIFT_PUSH).setUid(item.getString("uid")).setHrefUrl(item.getString("href")));
+ }
+ break;
+
}
}
diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
index 54b00cb34..00e0252d0 100644
--- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
+++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
@@ -13,6 +13,7 @@ import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
+import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
@@ -51,6 +52,8 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.bean.LiveChatBean;
+import net.lucode.hackware.magicindicator.buildins.UIUtil;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -281,7 +284,6 @@ public class LiveTextRender {
*/
private void createPrefix(Drawable levelDrawable, LiveChatBean bean, CreatePrefixCallback createPrefixCallback) {
-
// if (bean.getGuardType() != Constants.GUARD_TYPE_NONE) {//守护图标
// Drawable drawable;
// if (bean.getGuardType() == Constants.GUARD_TYPE_MONTH) {
@@ -457,6 +459,103 @@ public class LiveTextRender {
}
+ private void createPrefixNew(Drawable levelDrawable, LiveChatBean bean,TextView textView, CreatePrefixCallback createPrefixCallback) {
+
+
+ getGuardImage(CommonAppContext.sInstance, bean.getGuardType(), new ImgLoader.DrawableCallback() {
+ @Override
+ public void onLoadSuccess(Drawable drawable) {
+ show(drawable);
+ }
+
+ @Override
+ public void onLoadFailed() {
+ show(null);
+ }
+
+ void show(Drawable drawable) {
+ SpannableStringBuilder builder = new SpannableStringBuilder();
+ int[] prefixWidthHolder = {0}; // 用于累加 prefixWidth
+
+ // 定义一个辅助方法来添加 Drawable 并累加宽度
+ // 见上述 appendDrawable 方法定义
+
+ // 添加 levelDrawable
+ if (levelDrawable != null) {
+ appendDrawable(builder, levelDrawable, 17, 17, textView, prefixWidthHolder);
+ }
+
+ // 添加贵族图标
+ if (gzDrawablesMap.containsKey(bean)) {
+ Drawable gzDrawable = gzDrawablesMap.get(bean);
+ appendDrawable(builder, gzDrawable, 35, 20, textView, prefixWidthHolder);
+ }
+
+ // 添加荣誉勋章
+ if (ryxzDrawablesMap.containsKey(bean)) {
+ Drawable ryxzDrawable = ryxzDrawablesMap.get(bean);
+ appendDrawable(builder, ryxzDrawable, 18, 18, textView, prefixWidthHolder);
+ }
+
+ // 添加靓号图标
+ if (nhDrawablesMap.containsKey(bean)) {
+ Drawable nhDrawable = nhDrawablesMap.get(bean);
+ appendDrawable(builder, nhDrawable, 17, 17, textView, prefixWidthHolder);
+ }
+
+ // 添加其他 Drawable
+ if (drawable != null) {
+ appendDrawable(builder, drawable, 34, 17, textView, prefixWidthHolder);
+ }
+
+ // 添加粉丝徽章
+ if (!TextUtils.isEmpty(bean.getMedalNmae()) && !TextUtils.isEmpty(bean.getMedalLevelImageUrl())
+ && !bean.getMedalNmae().equals("null") && !bean.getMedalNmae().equals("(null)") && !bean.getMedalNmae().equals("")) {
+ Drawable medalDrawable = getMedalImage(bean);
+ if (medalDrawable != null) {
+ appendDrawable(builder, medalDrawable, 44, 17, textView, prefixWidthHolder);
+ }
+ }
+
+ // 添加直播间管理员图标
+ if (bean.isManager()) {
+ Drawable managerDrawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_m);
+ if (managerDrawable != null) {
+ appendDrawable(builder, managerDrawable, 17, 14, textView, prefixWidthHolder);
+ }
+ }
+
+ // 添加靓号图标
+ if (!TextUtils.isEmpty(bean.getLiangName())) {
+ Drawable liangDrawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_liang);
+ if (liangDrawable != null) {
+ appendDrawable(builder, liangDrawable, 17, 14, textView, prefixWidthHolder);
+ }
+ }
+
+ // 获取最终的 prefixWidth
+ int prefixWidth = prefixWidthHolder[0];
+ createPrefixCallback.onPrefixCallback(builder, prefixWidth);
+ }
+ });
+ }
+
+
+ private void appendDrawable(SpannableStringBuilder builder, Drawable drawable, int widthDp, int heightDp, TextView textView, int[] prefixWidthHolder) {
+ if (drawable != null) {
+ int index = builder.length();
+ builder.append("\uFFFC ");
+ drawable.setBounds(0, 0, DpUtil.dp2px(widthDp), DpUtil.dp2px(heightDp));
+ builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ prefixWidthHolder[0] += drawable.getBounds().width();
+
+ // 计算空格的宽度并累加
+ TextPaint paint = textView.getPaint();
+ float spaceWidth = paint.measureText(" ");
+ prefixWidthHolder[0] += (int) spaceWidth;
+ }
+ }
+
private Drawable getMedalImage(final LiveChatBean bean) {
View view = LayoutInflater.from(CommonAppContext.sInstance).inflate(R.layout.live_medal_icon, null, false);
@@ -500,6 +599,7 @@ public class LiveTextRender {
@Override
public void onLoadFailed() {
gz(context, textView, bean);
+
}
});
}
@@ -706,13 +806,11 @@ public class LiveTextRender {
private void renderTMP(Context context, final TextView textView, final LiveChatBean bean) {
-
if (textView != null) {
getLiveLevelImage(context, bean.getLevel(), false, new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
-
- createPrefix(drawable, bean, new CreatePrefixCallback() {
+ createPrefixNew(drawable, bean,textView, new CreatePrefixCallback() {
@Override
public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int color = Color.parseColor("#68F1F4");
@@ -726,7 +824,7 @@ public class LiveTextRender {
builder = renderGift(color, builder, bean);
break;
default:
- builder = renderChat(textView, color, builder, bean, prefixWidth);
+ builder = renderChatNew(textView, color, builder, bean, prefixWidth);
break;
}
textView.setText(builder);
@@ -737,7 +835,7 @@ public class LiveTextRender {
@Override
public void onLoadFailed() {
- createPrefix(null, bean, new CreatePrefixCallback() {
+ createPrefixNew(null, bean,textView, new CreatePrefixCallback() {
@Override
public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int color = 0;
@@ -751,7 +849,7 @@ public class LiveTextRender {
builder = renderGift(color, builder, bean);
break;
default:
- builder = renderChat(textView, color, builder, bean, prefixWidth);
+ builder = renderChatNew(textView, color, builder, bean, prefixWidth);
break;
}
textView.setText(builder);
@@ -845,6 +943,83 @@ public class LiveTextRender {
public static int textTemp = 0;
public static String userName = "";
+ private SpannableStringBuilder renderChatNew(TextView textView, int color, SpannableStringBuilder builder, LiveChatBean bean, int prefixWidth) {
+ int length = builder.length();
+
+ // availableWidth textView 可用宽度 prefixWidth 图片宽度
+ int availableWidth = textView.getWidth() - textView.getPaddingLeft() - textView.getPaddingRight();
+// Log.e("renderChatNew", "availableWidth: " + availableWidth);
+// Log.e("renderChatNew", "textView.getPaddingLeft(): " + textView.getPaddingLeft());
+// Log.e("renderChatNew", "textView.getPaddingRight(): " + textView.getPaddingRight());
+
+ StringBuilder sb = new StringBuilder();
+ String name = bean.getUserNiceName();
+ if (bean.getType() != LiveChatBean.ENTER_ROOM) { // 产品规定,进场消息不允许加冒号
+ name += ":";
+ }
+
+ int lengthContent = length + name.length();
+
+ sb.append(name).append(bean.getContent());
+
+ TextPaint paint = textView.getPaint();
+ float nameWidth = paint.measureText(sb.toString());
+// Log.e("renderChatNew", "nameWidth: " + nameWidth + " prefixWidth: " + prefixWidth);
+
+ if (nameWidth + prefixWidth > availableWidth) {
+ StringBuilder sb_tmp = new StringBuilder();
+ StringBuilder saveContentSB = new StringBuilder();
+ int initImageWidth = prefixWidth;
+
+ for (int i = 0; i < sb.length(); i++) {
+ char content = sb.charAt(i);
+ sb_tmp.append(content);
+ float measuredTextWidth = paint.measureText(sb_tmp.toString()) + initImageWidth;
+// Log.e("renderChatNew", "文字:" + sb_tmp.toString() + " measuredTextWidth: " + measuredTextWidth + " initImageWidth:" + initImageWidth + " availableWidth: " + availableWidth);
+ if (measuredTextWidth > availableWidth) {
+ initImageWidth = 0;
+ saveContentSB.append("\n");
+// Log.e("renderChatNew", "sb_tmp.toString():" + sb_tmp.toString());
+ sb_tmp.setLength(0);
+ sb_tmp.append(content);
+ }
+ saveContentSB.append(content);
+// Log.e("renderChatNew", "saveContentSB.toString():" + saveContentSB.toString());
+ }
+ builder.append(saveContentSB);
+// Log.e("renderChatNew", "builder.toString():" + builder.toString());
+
+ } else {
+ builder.append(sb);
+ }
+
+
+ //超皇设置渐变色展示昵称
+ if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getStartColor())) {
+ builder.setSpan(new LinearGradientFontSpan(Color.parseColor(bean.getStartColor()), Color.parseColor(bean.getEndColor())), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ } else {
+ builder.setSpan(new ForegroundColorSpan(color), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+
+ //超皇设置渐变色展示昵称
+ if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getContentColor())) {
+ builder.setSpan(new ForegroundColorSpan(Color.parseColor(bean.getContentColor())), lengthContent, lengthContent + bean.getContent().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ if (bean.getType() == LiveChatBean.LIGHT) {
+ Drawable heartDrawable = ContextCompat.getDrawable(CommonAppContext.sInstance, LiveIconUtil.getLiveLightIcon(bean.getHeart()));
+ if (heartDrawable != null) {
+ builder.append(" ");
+ heartDrawable.setBounds(0, 0, DpUtil.dp2px(16), DpUtil.dp2px(16));
+ length = builder.length();
+ builder.setSpan(new VerticalImageSpan(heartDrawable), length - 1, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ }
+
+ return builder;
+ }
+
+
+
/**
* 渲染普通聊天消息
*/
@@ -860,25 +1035,25 @@ public class LiveTextRender {
}
SpannableStringBuilder sb = new SpannableStringBuilder();
sb.append(name);
- float measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ float measuredTextWidth = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
// Rect mRect = new Rect();
// textView.getPaint().getTextBounds(sb.toString(), 0, sb.length(), mRect);
int width = (int) (((ViewGroup) textView.getParent()).getMeasuredWidth() - prefixEmpty);
String TAG = "文字渲染";
- // Log.i(TAG, "测算|" + measuredText + "|" + mRect.width() + "|" + sb.toString());
+ // Log.i(TAG, "测算|" + measuredTextWidth + "|" + mRect.width() + "|" + sb.toString());
//|810|810|810|786|786
// Log.i(TAG, "控件宽度|" + width + "|" + ((ViewGroup) textView.getParent()).getWidth() + "|" + ((ViewGroup) textView.getParent()).getMeasuredWidth() + "|" + textView.getWidth() + "|" + textView.getMeasuredWidth());
// Log.i(TAG, "前缀预留宽度|" + prefixWidth + "|" + prefixEmpty);
// Log.i(TAG, "renderChat: " + textView.getCompoundPaddingLeft() + "|" + textView.getCompoundPaddingRight() + "|");
//检测渲染后图标+名字是否超过父布局宽度,超过了就做换行处理
String prefixName = "";
- if (measuredText > width) {
+ if (measuredTextWidth > width) {
sb.clear();
for (int i = 0; i < name.length(); i++) {
sb.append(name.charAt(i));
- measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
- Log.i(TAG, i + "逐测算|" + measuredText + "|" + textTemp);
- if (measuredText > width) {
+ measuredTextWidth = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ Log.i(TAG, i + "逐测算|" + measuredTextWidth + "|" + textTemp);
+ if (measuredTextWidth > width) {
prefixName = name.substring(0, i + textTemp);
name = prefixName + "\n" + name.substring(i + textTemp);
break;
@@ -909,12 +1084,12 @@ public class LiveTextRender {
Log.i(TAG, "renderChat: " + content);
sb.append(name).append(content);
SpannableStringBuilder csb = null;
- measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ measuredTextWidth = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
sb.clear();
sb.append(prefixName);
prefixEmpty = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
StringBuilder stringBuilder = new StringBuilder();
- if (measuredText > width) {
+ if (measuredTextWidth > width) {
sb.clear();
sb.append(name);
float lineWidth = 0;
@@ -948,6 +1123,10 @@ public class LiveTextRender {
}
*/
+ if (bean == null || bean.getContent() == null){
+ builder.append("null");
+ return builder;
+ }
builder.append(bean.getContent());
//超皇设置渐变色展示昵称
if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getContentColor())) {
@@ -1014,7 +1193,7 @@ public class LiveTextRender {
@Override
public void onLoadSuccess(Drawable drawable) {
if (textView != null) {
- createPrefix(drawable, bean, new CreatePrefixCallback() {
+ createPrefixNew(drawable, bean,textView, new CreatePrefixCallback() {
@Override
public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int start = builder.length();
@@ -1031,7 +1210,7 @@ public class LiveTextRender {
@Override
public void onLoadFailed() {
if (textView != null) {
- createPrefix(null, bean, new CreatePrefixCallback() {
+ createPrefixNew(null, bean,textView, new CreatePrefixCallback() {
@Override
public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int start = builder.length();
diff --git a/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java b/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java
index 5a5bee746..2060c7c96 100644
--- a/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/AbsLivePushViewHolder.java
@@ -15,7 +15,7 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
-import com.tencent.rtmp.ui.TXCloudVideoView;
+import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.utils.DpUtil;
@@ -45,9 +45,9 @@ public abstract class AbsLivePushViewHolder extends AbsViewHolder implements ILi
protected ViewGroup mLeftContainer;
protected ViewGroup mRightContainer;
protected ViewGroup mPkContainer;
- public static TXCloudVideoView mPreView,dr1_preview,dr2_preview,dr3_preview,dr4_preview;
+ public static StyledPlayerView mPreView,dr1_preview,dr2_preview,dr3_preview,dr4_preview;
public static ImageView leave;
- public static TXCloudVideoView mPreView1;
+ public static StyledPlayerView mPreView1;
protected boolean mOpenCamera;//是否选择了相机
diff --git a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java
index 6b926c278..90301ec46 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java
@@ -37,7 +37,6 @@ import com.yunbao.common.views.weight.ClipPathCircleImage;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.SearchRecommendBodyAdapter;
import com.yunbao.live.event.JumpUserHomeEvent;
@@ -234,9 +233,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
goHomeUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mContext instanceof LiveRyAnchorActivity) {
- ((LiveRyAnchorActivity) mContext).superBackPressed();
- } else if (mContext instanceof LiveAudienceActivity) {
+ if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
@@ -271,9 +268,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mContext instanceof LiveRyAnchorActivity) {
- ((LiveRyAnchorActivity) mContext).superBackPressed();
- } else if (mContext instanceof LiveAudienceActivity) {
+ if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
@@ -375,8 +370,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
- } else if (mContext instanceof LiveRyAnchorActivity) {
- ((LiveRyAnchorActivity) mContext).superBackPressed();
}
Bus.get().post(new CloseEvent());
}
@@ -467,8 +460,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
- } else if (mContext instanceof LiveRyAnchorActivity) {
- ((LiveRyAnchorActivity) mContext).superBackPressed();
}
}
}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPlayTxViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPlayTxViewHolder.java
index ca40805c3..7a6883d35 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPlayTxViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPlayTxViewHolder.java
@@ -9,11 +9,6 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
-import com.tencent.rtmp.ITXLivePlayListener;
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.TXLivePlayConfig;
-import com.tencent.rtmp.TXLivePlayer;
-import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
@@ -27,11 +22,11 @@ import cn.qqtheme.framework.util.ScreenUtils;
* 连麦播放小窗口 使用腾讯sdk
*/
-public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder implements ITXLivePlayListener {
+public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder {
private static final String TAG = "LiveLinkMicPlayTxViewHolder";
- private TXCloudVideoView mVideoView;
- private TXLivePlayer mPlayer;
+// private TXCloudVideoView mVideoView;
+// private TXLivePlayer mPlayer;
public LiveLinkMicPlayTxViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@@ -45,7 +40,7 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void init() {
super.init();
- mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
+ /* mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
mPlayer = new TXLivePlayer(mContext);
mPlayer.setPlayListener(this);
mPlayer.setPlayerView(mVideoView);
@@ -57,7 +52,7 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
playConfig.setAutoAdjustCacheTime(true);
playConfig.setMaxAutoAdjustCacheTime(5.0f);
playConfig.setMinAutoAdjustCacheTime(1.0f);
- mPlayer.setConfig(playConfig);
+ mPlayer.setConfig(playConfig);*/
// TODO: 2019-11-10
@@ -86,9 +81,9 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void play(final String url) {
if (TextUtils.isEmpty(url)) {
- if (mPlayer != null) {
+ /* if (mPlayer != null) {
mPlayer.stopPlay(true);
- }
+ }*/
mEndPlay = true;
return;
}
@@ -97,9 +92,9 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void run() {
mEndPlay = false;
- if (mPlayer != null) {
+ /*if (mPlayer != null) {
mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_RTMP_ACC);
- }
+ }*/
L.e(TAG, "play----url--->" + url);
}
}, 500);
@@ -109,11 +104,11 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void release() {
mEndPlay = true;
- if (mPlayer != null) {
+ /* if (mPlayer != null) {
mPlayer.stopPlay(false);
mPlayer.setPlayListener(null);
}
- mPlayer = null;
+ mPlayer = null;*/
if (mBtnClose != null) {
mBtnClose.setOnClickListener(null);
}
@@ -126,72 +121,18 @@ public class LiveLinkMicPlayTxViewHolder extends AbsLiveLinkMicPlayViewHolder im
@Override
public void resume() {
- if (mPaused && mVideoView != null) {
+ /*if (mPaused && mVideoView != null) {
mPlayer.resume();
- }
+ }*/
mPaused = false;
}
@Override
public void pause() {
- if (mVideoView != null) {
+ /* if (mVideoView != null) {
mPlayer.pause();
- }
+ }*/
mPaused = true;
}
- @Override
- public void onPlayEvent(int e, Bundle bundle) {
- if (mEndPlay) {
- return;
- }
- switch (e) {
- case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://播放开始
- if (mLoading != null && mLoading.getVisibility() == View.VISIBLE) {
- mLoading.setVisibility(View.INVISIBLE);
- }
- break;
- case TXLiveConstants.PLAY_EVT_PLAY_LOADING:
- if (mLoading != null && mLoading.getVisibility() != View.VISIBLE) {
- mLoading.setVisibility(View.VISIBLE);
- }
- break;
-// case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://第一帧
-// break;
-// case TXLiveConstants.PLAY_EVT_PLAY_END://播放结束
-// break;
- case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取视频宽高
-
-// float width = bundle.getInt("EVT_PARAM1", 0);
-// float height = bundle.getInt("EVT_PARAM2", 0);
-// L.e(TAG, "流---width----->" + width);
-// L.e(TAG, "流---height----->" + height);
-
-
-
-// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
-// int targetH = 0;
-// if (width / height > 0.5625f) {//横屏 9:16=0.5625
-// targetH = (int) (mVideoView.getWidth() / width * height);
-// } else {
-// targetH = ViewGroup.LayoutParams.MATCH_PARENT;
-// }
-// if (targetH != params.height) {
-// params.height = targetH;
-// params.addRule(RelativeLayout.CENTER_IN_PARENT);
-// mVideoView.requestLayout();
-// }
-
- break;
- case TXLiveConstants.PLAY_ERR_NET_DISCONNECT://播放失败
- case TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND:
- ToastUtil.show(mContext.getString(R.string.live_play_error));
- break;
- }
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
-
- }
}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPushTxViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPushTxViewHolder.java
index 32f842e24..e860b8c90 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPushTxViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPushTxViewHolder.java
@@ -8,11 +8,6 @@ import android.os.Bundle;
import android.util.TypedValue;
import android.view.ViewGroup;
-import com.tencent.rtmp.ITXLivePushListener;
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.TXLivePushConfig;
-import com.tencent.rtmp.TXLivePusher;
-import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
@@ -22,11 +17,11 @@ import com.yunbao.live.R;
* 连麦推流小窗口 腾讯sdk
*/
-public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder implements ITXLivePushListener {
+public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder {
private static final String TAG = "LiveLinkMicPushTxViewHolder";
- private TXLivePusher mLivePusher;
- private TXLivePushConfig mLivePushConfig;
+// private TXLivePusher mLivePusher;
+// private TXLivePushConfig mLivePushConfig;
public LiveLinkMicPushTxViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@@ -39,7 +34,7 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
@Override
public void init() {
- mLivePusher = new TXLivePusher(mContext);
+ /* mLivePusher = new TXLivePusher(mContext);
mLivePushConfig = new TXLivePushConfig();
mLivePushConfig.setVideoFPS(15);//视频帧率
mLivePushConfig.setVideoEncodeGop(1);//GOP大小
@@ -55,7 +50,7 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
mLivePusher.setConfig(mLivePushConfig);
mLivePusher.setMirror(true);
mLivePusher.setPushListener(this);
- mLivePusher.setMicVolume(4f);
+ mLivePusher.setMicVolume(4f);*/
}
@@ -66,16 +61,16 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
*/
@Override
public void startPush(String pushUrl) {
- if (mLivePusher != null) {
+ /* if (mLivePusher != null) {
mLivePusher.startCameraPreview((TXCloudVideoView) findViewById(R.id.camera_preview));
mLivePusher.startPusher(pushUrl);
- }
+ }*/
}
@Override
public void release() {
mLivePushListener = null;
- if (mLivePusher != null) {
+ /* if (mLivePusher != null) {
mLivePusher.stopPusher();
mLivePusher.stopScreenCapture();
mLivePusher.stopCameraPreview(false);
@@ -85,70 +80,26 @@ public class LiveLinkMicPushTxViewHolder extends AbsLiveLinkMicPushViewHolder im
if (mLivePushConfig != null) {
mLivePushConfig.setPauseImg(null);
}
- mLivePushConfig = null;
+ mLivePushConfig = null;*/
}
@Override
public void pause() {
mPaused = true;
- if (mStartPush && mLivePusher != null) {
+ /*if (mStartPush && mLivePusher != null) {
mLivePusher.pausePusher();
- }
+ }*/
}
@Override
public void resume() {
- if (mPaused && mStartPush && mLivePusher != null) {
+ /*if (mPaused && mStartPush && mLivePusher != null) {
mLivePusher.resumePusher();
- }
+ }*/
mPaused = false;
}
- @Override
- public void onPushEvent(int e, Bundle bundle) {
- if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
- ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
- if (mLivePushListener != null) {
- mLivePushListener.onPushFailed();
- }
- } else if (e == TXLiveConstants.PUSH_ERR_OPEN_MIC_FAIL) {
- ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
- if (mLivePushListener != null) {
- mLivePushListener.onPushFailed();
- }
- } else if (e == TXLiveConstants.PUSH_ERR_NET_DISCONNECT || e == TXLiveConstants.PUSH_ERR_INVALID_ADDRESS) {
- L.e(TAG, "网络断开,推流失败------>");
- if (mLivePushListener != null) {
- mLivePushListener.onPushFailed();
- }
- } else if (e == TXLiveConstants.PUSH_WARNING_HW_ACCELERATION_FAIL) {
- L.e(TAG, "不支持硬件加速------>");
- if (mLivePushConfig != null && mLivePusher != null) {
- mLivePushConfig.setHardwareAcceleration(TXLiveConstants.ENCODE_VIDEO_SOFTWARE);
- mLivePusher.setConfig(mLivePushConfig);
- }
- } else if (e == TXLiveConstants.PUSH_EVT_FIRST_FRAME_AVAILABLE) {//预览成功
- L.e(TAG, "mStearm--->初始化完毕");
- if (mLivePushListener != null) {
- mLivePushListener.onPreviewStart();
- }
- } else if (e == TXLiveConstants.PUSH_EVT_PUSH_BEGIN) {//推流成功
- L.e(TAG, "mStearm--->推流成功");
- if (!mStartPush) {
- mStartPush = true;
- if (mLivePushListener != null) {
- mLivePushListener.onPushStart();
- }
- }
- }
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
-
- }
-
private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue();
resources.openRawResource(id, value);
diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java
deleted file mode 100644
index ea92d50d6..000000000
--- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java
+++ /dev/null
@@ -1,977 +0,0 @@
-package com.yunbao.live.views;
-
-import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.text.Html;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.constraintlayout.widget.ConstraintLayout;
-import androidx.core.content.ContextCompat;
-
-import com.lxj.xpopup.XPopup;
-import com.lxj.xpopup.core.BasePopupView;
-import com.lxj.xpopup.interfaces.XPopupCallback;
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.Constants;
-import com.yunbao.common.bean.IMLoginModel;
-import com.yunbao.common.bean.LiveAnchorCallMeModel;
-import com.yunbao.common.bean.LiveAnchorSayModel;
-import com.yunbao.common.bean.LiveClassBean;
-import com.yunbao.common.bean.LiveRoomTypeBean;
-import com.yunbao.common.bean.UserBean;
-import com.yunbao.common.event.LivePushRyEvent;
-import com.yunbao.common.glide.ImgLoader;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.http.LiveHttpConsts;
-import com.yunbao.common.http.LiveHttpUtil;
-import com.yunbao.common.interfaces.CommonCallback;
-import com.yunbao.common.interfaces.ImageResultCallback;
-import com.yunbao.common.interfaces.OnItemClickListener;
-import com.yunbao.common.manager.IMLoginManager;
-import com.yunbao.common.utils.Bus;
-import com.yunbao.common.utils.DialogUitl;
-import com.yunbao.common.utils.L;
-import com.yunbao.common.utils.ProcessImageUtil;
-import com.yunbao.common.utils.RouteUtil;
-import com.yunbao.common.utils.StringUtil;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.common.utils.WordUtil;
-import com.yunbao.common.views.AbsViewHolder;
-import com.yunbao.common.views.LiveClarityCustomPopup;
-import com.yunbao.common.views.LiveNewWishListPopup;
-import com.yunbao.common.views.LiveOpenCustomPopup;
-import com.yunbao.common.views.LiveRobotSettingCustomPopup;
-import com.yunbao.common.views.weight.ViewClicksAntiShake;
-import com.yunbao.faceunity.FaceManager;
-import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
-import com.yunbao.live.dialog.LiveAnchorEditCallMeDialog;
-import com.yunbao.live.dialog.LiveAnchorSayPopDialog;
-import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
-import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment;
-import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment;
-import com.yunbao.live.dialog.LiveTimeDialogFragment;
-import com.yunbao.live.event.LiveAudienceEvent;
-
-import org.greenrobot.eventbus.Subscribe;
-import org.greenrobot.eventbus.ThreadMode;
-
-import java.io.File;
-import java.util.Locale;
-
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream;
-import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
-import cn.rongcloud.rtc.base.RCRTCParamsType;
-
-public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener {
-
- private ConstraintLayout mAvatar, mRootView;
- private TextView mCoverText;
- private EditText mEditTitle;
- private ProcessImageUtil mImageUtil;
- private File mAvatarFile;
- private TextView mLiveClass, anchorAgreement;
- private TextView mLiveTypeTextView, liveClarity;//房间类型TextView
- private TextView mLiveWishListTextView;//心愿单TextView
- private int mLiveClassID;//直播频道id
- private int mLiveType;//房间类型
- private int mLiveTypeVal;//房间密码,门票收费金额
- private int mLiveTimeCoin;//计时收费金额
- private boolean mOpenLocation = true;
- private int mLiveSdk;
- private LiveClassBean classBean;
- private FaceManager manager;
- private TextView faceTextView;//提示人脸未检测到的TextView
- private ImageView imgClarity, selectorProtocol;
- private int selectClarity = 1;
- private LiveOpenCustomPopup liveOpenCustomPopup;
- private boolean selector = true;
- private String mLiveUid;
-
- public LiveNewReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) {
- super(context, parentView, liveSdk);
- }
-
- @Override
- protected void processArguments(Object... args) {
- if (args.length > 0) {
- mLiveSdk = (int) args[0];
- }
- }
-
- @Override
- protected int getLayoutId() {
- return R.layout.view_new_live_ready;
- }
-
- @Override
- public void init() {
- mRootView = (ConstraintLayout) findViewById(R.id.traceroute_rootview);
- imgClarity = (ImageView) findViewById(R.id.img_clarity);
- selectorProtocol = (ImageView) findViewById(R.id.selector_protocol);
- liveClarity = (TextView) findViewById(R.id.live_clarity);
- anchorAgreement = (TextView) findViewById(R.id.anchor_agreement);
- mRootView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- InputMethodManager imm = (InputMethodManager)
- mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
- }
- });
-
- mAvatar = (ConstraintLayout) findViewById(R.id.avatar);
- mAvatar.setOnClickListener(this);
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- ImgLoader.displayDrawable(mContext, u.getAvatar(), new ImgLoader.DrawableCallback() {
- @Override
- public void onLoadSuccess(Drawable drawable) {
- mAvatar.setBackground(drawable);
- }
-
- @Override
- public void onLoadFailed() {
-
- }
- });
- mCoverText = (TextView) findViewById(R.id.cover_text);
- mEditTitle = (EditText) findViewById(R.id.edit_title);
- findViewById(R.id.btn_room_type).setOnClickListener(this);
- mOpenLocation = true;
- mLiveClass = (TextView) findViewById(R.id.live_class);
- mLiveTypeTextView = (TextView) findViewById(R.id.text_room_type);
- mLiveWishListTextView = (TextView) findViewById(R.id.text_wishlist);
- faceTextView = (TextView) findViewById(R.id.faceTextView);
-
- mImageUtil = ((LiveActivity) mContext).getProcessImageUtil();
- mImageUtil.setImageResultCallback(new ImageResultCallback() {
-
- @Override
- public void beforeCamera() {
- ((LiveRyAnchorActivity) mContext).beforeCamera();
- }
-
- @Override
- public void onSuccess(File file) {
- if (file != null) {
- ImgLoader.displayFileDrawable(mContext, file, new ImgLoader.DrawableCallback() {
- @Override
- public void onLoadSuccess(Drawable drawable) {
- mAvatar.setBackground(drawable);
- }
-
- @Override
- public void onLoadFailed() {
-
- }
- });
- if (mAvatarFile == null) {
- mCoverText.setText(mContext.getString(R.string.live_cover_2));
- mCoverText.setBackground(ContextCompat.getDrawable(mContext, R.drawable.bg_live_cover));
- }
- mAvatarFile = file;
- }
- }
-
- @Override
- public void onFailure() {
- }
- });
- findViewById(R.id.btn_camera).setOnClickListener(this);
- findViewById(R.id.btn_live_class).setOnClickListener(this);
- findViewById(R.id.btn_close).setOnClickListener(this);
- findViewById(R.id.btn_beauty).setOnClickListener(this);
- findViewById(R.id.btn_robot).setOnClickListener(this);
- findViewById(R.id.btn_start_live).setOnClickListener(this);
- findViewById(R.id.btn_wishlist).setOnClickListener(this);
- findViewById(R.id.btn_horizontally).setOnClickListener(this);
- findViewById(R.id.anchor_agreement_layout).setOnClickListener(this);
- findViewById(R.id.btn_live_anchor_say).setOnClickListener(this);
- findViewById(R.id.btn_live_anchor_call_me).setOnClickListener(this);
-
- if (manager != null) {
- manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
- final Handler handler = new Handler(Looper.getMainLooper());
-
- @Override
- public void onFaceChanged(int num) {
- handler.post(() -> {
- if (num == 0) {
- faceTextView.setVisibility(View.VISIBLE);
- } else {
- faceTextView.setVisibility(View.GONE);
- }
- });
- }
- });
- //新美颜
- setFaceUnity(true);
-
- }
- //设置清晰度
-// DeviceUtils.getMemory(mContext); //获取可用内存
-// DeviceUtils.getNetSpeed(mContext);//获取当前上传网速
-// Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext));
-
- IMLoginManager.get(mContext).setSelectClarity(selectClarity);
- setSelectClarity(IMLoginManager.get(mContext).getSelectClarity());
- ViewClicksAntiShake
- .clicksAntiShake(
- findViewById(R.id.btn_live_clarity), () -> {
-
- LiveClarityCustomPopup liveClarityCustomPopup =
- new LiveClarityCustomPopup(mContext,
- IMLoginManager.get(mContext).getSelectClarity(),
- IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
- new XPopup.Builder(mContext)
- .setPopupCallback(new XPopupCallback() {
- @Override
- public void onCreated(BasePopupView popupView) {
-
- }
-
- @Override
- public void beforeShow(BasePopupView popupView) {
-
- }
-
- @Override
- public void onShow(BasePopupView popupView) {
-
- }
-
- @Override
- public void onDismiss(BasePopupView popupView) {
- setSelectClarity(liveClarityCustomPopup.getSelectClarity());
- }
-
- @Override
- public void beforeDismiss(BasePopupView popupView) {
-
- }
-
- @Override
- public boolean onBackPressed(BasePopupView popupView) {
- return false;
- }
-
- @Override
- public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
-
- }
-
- @Override
- public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
-
- }
-
- @Override
- public void onClickOutside(BasePopupView popupView) {
-
- }
- })
- .asCustom(liveClarityCustomPopup)
- .show();
- });
- String keywordHtml2 = "" + mContext.getString(R.string.anchor_hint) + "";
- String contextHtml = "" + mContext.getString(R.string.anchor_agreement) + "";
- anchorAgreement.setText(Html.fromHtml(contextHtml + keywordHtml2));
- selectorProtocol.setPressed(true);
- selectorProtocol.setSelected(true);
- selector = selectorProtocol.isSelected();
- selectorProtocol.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- selector = !selector;
- selectorProtocol.setSelected(selector);
- }
- });
- }
-
- private void setSelectClarity(int selectClarity) {
-
- this.selectClarity = selectClarity;
- IMLoginManager.get(mContext).setSelectClarity(selectClarity);
- switch (selectClarity) {
- case 0:
- imgClarity.setImageResource(R.mipmap.icon_sd);
- liveClarity.setText(R.string.standard_clear);
- break;
- case 1:
- imgClarity.setImageResource(R.mipmap.icon_hd);
- liveClarity.setText(R.string.high_definition);
- break;
- case 2:
- imgClarity.setImageResource(R.mipmap.icon_fhd);
- liveClarity.setText(R.string.ultra_hd);
- break;
- }
- if (liveOpenCustomPopup != null) {
- liveOpenCustomPopup.setSelectClarity(selectClarity);
- }
- //設置開播分辨率
- RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- int minRate = 200;
- int maxRate = 900;
- switch (selectClarity) {
- case 0:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- minRate = 200;
- maxRate = 900;
- break;
- case 1:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
- minRate = 250;
- maxRate = 2200;
- break;
- case 2:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
- minRate = 400;
- maxRate = 4000;
- break;
- }
- RCRTCVideoStreamConfig config =
- RCRTCVideoStreamConfig.Builder.create()
- .setMinRate(minRate)
- .setMaxRate(maxRate)
- .setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_15)
- .setVideoResolution(rcrtcVideoResolution)
- .build();
- RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);
- Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
- //重新发布一下流
- Bus.get().post(new LivePushRyEvent());
- }
-
- public void setManager(FaceManager manager) {
- this.manager = manager;
- }
-
-
- @Override
- public void onClick(View v) {
- if (!canClick()) {
- return;
- }
- int i = v.getId();
- if (i == R.id.avatar) {
- setAvatar();
-
- } else if (i == R.id.btn_camera) {
- toggleCamera();
- } else if (i == R.id.btn_close) {
- close();
- } else if (i == R.id.btn_live_class) {
- chooseLiveClass();
- } else if (i == R.id.btn_beauty) {
- //beauty();//momo美颜
- setFaceUnity(false); //新娱美颜
- } else if (i == R.id.btn_wishlist) {
- //点击心愿单
- openWishListWindow();
- } else if (i == R.id.btn_room_type) {
- chooseLiveType();
- } else if (i == R.id.btn_start_live) {
- if (!selector) {
- ToastUtil.show(mContext.getString(R.string.anchor_agreement_hint));
- return;
- }
- if (mLiveClassID == 0) {
- ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
- return;
- }
-// startLive();
- liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity(), classBean, liveRoomTypeBean)
- .setSayStatus(IMLoginManager.get(mContext).getAnchorSayStatus())
- .setCallMeStatus(IMLoginManager.get(mContext).getAnchorCallStatus())
- .setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() {
- @Override
-
- public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) {
- if (classModel != null) {
- classBean = classModel;
- mLiveClassID = classBean.getId();
- }
- liveRoomTypeBean = liveRoomTypeModel;
- mLiveType = liveRoomTypeModel.getId();
- startLiveInit();
- liveOpenCustomPopup = null;
- }
-
- @Override
- public void selectClarity(int selectClarity) {
- LiveClarityCustomPopup liveClarityCustomPopup =
- new LiveClarityCustomPopup(mContext,
- IMLoginManager.get(mContext).getSelectClarity(),
- IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
- new XPopup.Builder(mContext)
- .setPopupCallback(new XPopupCallback() {
- @Override
- public void onCreated(BasePopupView popupView) {
-
- }
-
- @Override
- public void beforeShow(BasePopupView popupView) {
-
- }
-
- @Override
- public void onShow(BasePopupView popupView) {
-
- }
-
- @Override
- public void onDismiss(BasePopupView popupView) {
- setSelectClarity(liveClarityCustomPopup.getSelectClarity());
- }
-
- @Override
- public void beforeDismiss(BasePopupView popupView) {
-
- }
-
- @Override
- public boolean onBackPressed(BasePopupView popupView) {
- return false;
- }
-
- @Override
- public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
-
- }
-
- @Override
- public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
-
- }
-
- @Override
- public void onClickOutside(BasePopupView popupView) {
-
- }
- })
- .asCustom(liveClarityCustomPopup)
- .show();
- }
-
- @Override
- public void openRobot() {
- LiveRobotSettingCustomPopup liveRobotSettingCustomPopup = new LiveRobotSettingCustomPopup(mContext);
- new XPopup.Builder(mContext)
- .setPopupCallback(new XPopupCallback() {
- @Override
- public void onCreated(BasePopupView popupView) {
-
- }
-
- @Override
- public void beforeShow(BasePopupView popupView) {
-
- }
-
- @Override
- public void onShow(BasePopupView popupView) {
-
- }
-
- @Override
- public void onDismiss(BasePopupView popupView) {
- if (liveOpenCustomPopup != null) {
- liveOpenCustomPopup.initDate();
- }
- }
-
- @Override
- public void beforeDismiss(BasePopupView popupView) {
-
- }
-
- @Override
- public boolean onBackPressed(BasePopupView popupView) {
- return false;
- }
-
- @Override
- public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
-
- }
-
- @Override
- public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
-
- }
-
- @Override
- public void onClickOutside(BasePopupView popupView) {
-
- }
- })
- .asCustom(liveRobotSettingCustomPopup)
- .show();
- }
-
- @Override
- public void openLiveRoomType(LiveRoomTypeBean liveRoomTypeModel) {
- liveRoomTypeBean = liveRoomTypeModel;
- mLiveType = liveRoomTypeModel.getId();
- chooseLiveType();
- }
-
- @Override
- public void openLiveClass(LiveClassBean classModel) {
- if (classModel != null) {
- classBean = classModel;
- mLiveClassID = classBean.getId();
- }
- chooseLiveClass();
- }
-
- @Override
- public void openWishlist() {
- //点击心愿单
- openWishListWindow();
- }
-
- @Override
- public void openAnchorSay() {
- openAnchorSayDialog();
- }
-
- @Override
- public void openCallMe() {
- openAnchorCallMeDialog();
- }
- });
- new XPopup.Builder(mContext)
- .asCustom(liveOpenCustomPopup)
- .show();
- } else if (i == R.id.btn_locaiton) {
- switchLocation();
- } else if (i == R.id.btn_horizontally) {
- RCRTCCameraOutputStream cameraStream = RCRTCEngine.getInstance().getDefaultVideoStream();
- cameraStream.setPreviewMirror(!cameraStream.isPreviewMirror());
- } else if (i == R.id.btn_robot) {
- new XPopup.Builder(mContext)
- .asCustom(new LiveRobotSettingCustomPopup(mContext))
- .show();
- } else if (i == R.id.anchor_agreement_layout) {
- String ct = Locale.getDefault().getLanguage();
- IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
- StringBuffer url = new StringBuffer();
- url.append(CommonAppConfig.HOST);
- url.append("/h5/page/index.html?id=708");
- url.append("&uid=")
- .append(model.getId())
- .append("&token=")
- .append(model.getToken()).append("&isZh=")
- .append(WordUtil.isNewZh() ? "1" : 0);
- RouteUtil.forwardLiveZhuangBanActivity(url.toString(), false);
- } else if (i == R.id.btn_live_anchor_say) {
- openAnchorSayDialog();
- } else if (i == R.id.btn_live_anchor_call_me) {
- openAnchorCallMeDialog();
- }
- }
-
- /**
- * 新娱美颜
- */
- public void setFaceUnity(boolean init) {
- LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext);
- fragment.setManager(manager);
- fragment.setDismissShowUi(mRootView);
- if (mContext instanceof LiveRyAnchorActivity) {
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
- mRootView.setVisibility(View.INVISIBLE);
- if (init) {
- fragment.dismiss();
- }
- }
- }
-
- /**
- * 打开心愿单窗口
- */
- public void openWishListWindow() {
-// LiveNewWishListDialogFragment fragment = new LiveNewWishListDialogFragment();
-//
-// if (mContext instanceof LiveRyAnchorActivity) {
-// fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
-//
-// }
- new XPopup.Builder(mContext)
- .enableDrag(false)
- .asCustom(new LiveNewWishListPopup((LiveRyAnchorActivity) mContext))
- .show();
- }
-
- public void openAnchorSayDialog() {
- new LiveAnchorSayPopDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(LiveAnchorSayModel bean, int position) {
- if (liveOpenCustomPopup != null) {
- liveOpenCustomPopup.setSayStatus(bean.getLivePreview().getIsShow() == 1);
- }
- }
- }).showDialog();
- }
-
- public void openAnchorCallMeDialog() {
- new LiveAnchorEditCallMeDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(LiveAnchorCallMeModel bean, int position) {
- if (liveOpenCustomPopup != null) {
- liveOpenCustomPopup.setCallMeStatus(bean.getIsShow() == 1);
- }
- }
- }).showDialog();
- }
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void updateStart(LiveAudienceEvent event) {
- if (event.getType() == WISH_LIST_UPDATE) {
- if (liveOpenCustomPopup != null) {
- liveOpenCustomPopup.initDate();
- }
- }
- }
-
- /**
- * 打开 关闭位置
- */
- private void switchLocation() {
- if (mOpenLocation) {
- new DialogUitl.Builder(mContext)
- .setContent(mContext.getString(R.string.live_location_close_3))
- .setCancelable(true)
- .setConfirmString(mContext.getString(R.string.live_location_close_2))
- .setClickCallback(new DialogUitl.SimpleCallback() {
-
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- toggleLocation();
- }
- })
- .build()
- .show();
- } else {
- toggleLocation();
- }
- }
-
- private void toggleLocation() {
- mOpenLocation = !mOpenLocation;
- }
-
- /**
- * 设置头像
- */
- private void setAvatar() {
- if (mLiveSdk == Constants.LIVE_SDK_TX) {
- mImageUtil.getImageByAlbum();
- } else {
- DialogUitl.showStringArrayDialog(mContext, new Integer[]{
- R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
- @Override
- public void onItemClick(String text, int tag) {
- if (tag == R.string.camera) {
- mImageUtil.getImageByCamera();
- } else {
- mImageUtil.getImageByAlbum();
- }
- }
- });
- }
- }
-
- /**
- * 切换镜头
- */
- private void toggleCamera() {
- ((LiveRyAnchorActivity) mContext).toggleCamera();
- }
-
- /**
- * 关闭
- */
- private void close() {
- ((LiveRyAnchorActivity) mContext).endLives();
- }
-
- /**
- * 选择直播频道
- */
- private void chooseLiveClass() {
- /* try {
- Intent intent = new Intent(mContext, LiveChooseClassActivity.class);
- intent.putExtra(Constants.CLASS_ID, mLiveClassID);
- mImageUtil.startActivityForResult(intent, mActivityResultCallback);
- }catch (Exception e){
-
- }*/
-
- Bundle bundle = new Bundle();
- bundle.putInt(Constants.CLASS_ID, mLiveClassID);
- LiveNewRoomClassDialogFragment fragment = new LiveNewRoomClassDialogFragment();
- fragment.setArguments(bundle);
- fragment.setCallback(new CommonCallback() {
- @Override
- public void callback(LiveClassBean bean) {
- classBean = bean;
- mLiveClassID = classBean.getId();
- mLiveClass.setText(bean.getName());
- if (liveOpenCustomPopup != null) {
- liveOpenCustomPopup.setClassBean(classBean);
- }
- }
- });
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
-
- }
-
- /**
- * 设置美颜
- */
- private void beauty() {
- ((LiveRyAnchorActivity) mContext).beauty();
- // Intent intent = new Intent(mContext, Beauty360Activity3.class);
- // mContext.startActivity(intent);
-
- }
-
- /**
- * 选择直播类型
- */
- private LiveRoomTypeBean liveRoomTypeBean = new LiveRoomTypeBean(0, mContext.getString(R.string.live_room_public));
-
- private void chooseLiveType() {
- Bundle bundle = new Bundle();
- bundle.putInt(Constants.CHECKED_ID, mLiveType);
- LiveNewRoomTypeDialogFragment fragment = new LiveNewRoomTypeDialogFragment();
- fragment.setArguments(bundle);
- fragment.setCallback(new CommonCallback() {
- @Override
- public void callback(LiveRoomTypeBean bean) {
- liveRoomTypeBean = bean;
- switch (bean.getId()) {
- case Constants.LIVE_TYPE_NORMAL:
- onLiveTypeNormal(bean);
- break;
- case Constants.LIVE_TYPE_PWD:
- onLiveTypePwd(bean);
- break;
- case Constants.LIVE_TYPE_PAY:
- onLiveTypePay(bean);
- break;
- case Constants.LIVE_TYPE_TIME:
- onLiveTypeTime(bean);
- break;
- }
- if (liveOpenCustomPopup != null) {
- liveOpenCustomPopup.setLiveRoomTypeBean(liveRoomTypeBean);
- }
- }
- });
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
- }
-
- /**
- * 普通房间
- */
- private void onLiveTypeNormal(LiveRoomTypeBean bean) {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(bean.getName());
- mLiveTypeVal = 0;
- mLiveTimeCoin = 0;
- }
-
- /**
- * 密码房间
- */
- private void onLiveTypePwd(final LiveRoomTypeBean bean) {
- DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- if (TextUtils.isEmpty(content)) {
- ToastUtil.show(mContext.getString(R.string.live_set_pwd_empty));
- } else {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(WordUtil.isNewZh() ? "密碼房" : "password room");
- if (StringUtil.isInt(content)) {
- mLiveTypeVal = Integer.parseInt(content);
- }
- mLiveTimeCoin = 0;
- dialog.dismiss();
- }
- }
- });
- }
-
- /**
- * 付费房间
- */
- private void onLiveTypePay(final LiveRoomTypeBean bean) {
- DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_fee), DialogUitl.INPUT_TYPE_NUMBER, 8, new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- if (TextUtils.isEmpty(content)) {
- ToastUtil.show(mContext.getString(R.string.live_set_fee_empty));
- } else {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(bean.getName());
- if (StringUtil.isInt(content)) {
- mLiveTypeVal = Integer.parseInt(content);
- }
- mLiveTimeCoin = 0;
- dialog.dismiss();
- }
- }
- });
- }
-
- /**
- * 计时房间
- */
- private void onLiveTypeTime(final LiveRoomTypeBean bean) {
- LiveTimeDialogFragment fragment = new LiveTimeDialogFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(Constants.CHECKED_COIN, mLiveTimeCoin);
- fragment.setArguments(bundle);
- fragment.setCommonCallback(new CommonCallback() {
- @Override
- public void callback(Integer coin) {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(bean.getName());
- mLiveTypeVal = coin;
- mLiveTimeCoin = coin;
- }
- });
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
- }
-
- public void hide() {
- if (mContentView != null && mContentView.getVisibility() == View.VISIBLE) {
- mContentView.setVisibility(View.INVISIBLE);
- }
- }
-
-
- public void show() {
- if (mContentView != null && mContentView.getVisibility() != View.VISIBLE) {
- mContentView.setVisibility(View.VISIBLE);
- }
- }
-
- /**
- * 点击开始直播按钮
- */
- private void startLiveInit() {
- if (isWifiProxy(mContext) || checkVPN((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE))) {
- ToastUtil.show(WordUtil.isNewZh() ? "檢測開啓了VPN或者代理,請先關閉VPN或者代理再開播。" :
- "It is detected that VPN or proxy is turned on. Please turn off VPN or proxy before starting the broadcast.");
- } else {
- boolean startPreview = ((LiveRyAnchorActivity) mContext).isStartPreview();
-// if (!startPreview) {
-// ToastUtil.show(R.string.please_wait);
-// return;
-// }
- if (mLiveClassID == 0) {
- ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
- return;
- }
- createRoom();
- }
- }
-
- private boolean isWifiProxy(Context context) {
- final boolean IS_ICS_OR_LATER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
- String proxyAddress;
- int proxyPort;
- if (IS_ICS_OR_LATER) {
- proxyAddress = System.getProperty("http.proxyHost");
- String portStr = System.getProperty("http.proxyPort");
- proxyPort = Integer.parseInt((portStr != null ? portStr : "-1"));
- } else {
- proxyAddress = android.net.Proxy.getHost(context);
- proxyPort = android.net.Proxy.getPort(context);
- }
- return (!TextUtils.isEmpty(proxyAddress)) && (proxyPort != -1);
- }
-
- private boolean checkVPN(ConnectivityManager connMgr) {
- //don't know why always returns null:
- NetworkInfo networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_VPN);
- boolean isVpnConn = networkInfo == null ? false : networkInfo.isConnected();
- return isVpnConn;
- }
-
- /**
- * 请求创建直播间接口,开始直播
- */
- boolean isHttpBack = false;
-
- private void createRoom() {
- if (!isHttpBack) {
- isHttpBack = true;
- if (mLiveClassID == 0) {
- ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
- return;
- }
- String title = mEditTitle.getText().toString().trim();
- LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1, false, new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, final String[] info) {
- isHttpBack = false;
- if (code == 0 && info.length > 0) {
- L.e("开播", "createRoom------->" + info[0]);
- final CommonAppConfig appConfig = CommonAppConfig.getInstance();
- UserBean u = appConfig.getUserBean();
- ((LiveRyAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
- } else {
- ToastUtil.show(msg);
- }
- }
-
- @Override
- public void onError() {
- super.onError();
- isHttpBack = false;
- }
- });
- } else {
- ToastUtil.show("請求中,請勿重複點擊");
- }
- }
-
- public void release() {
- mImageUtil = null;
- }
-
- @Override
- public void onDestroy() {
- LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM);
- }
-
- public void setLiveUid(String mLiveUid) {
- this.mLiveUid = mLiveUid;
- }
-}
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 546f26826..8cde5b78f 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java
@@ -11,10 +11,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
-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.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.DpUtil;
@@ -35,8 +31,8 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
private ViewGroup mLeftContainer;
private ViewGroup mRightContainer;
private RelativeLayout mPkContainer;
- public static TXCloudVideoView mVideoView;
- private V2TXLivePlayer mPlayer;
+// public static TXCloudVideoView mVideoView;
+// private V2TXLivePlayer mPlayer;
private View mLoading;
private ImageView mCover;
@@ -78,7 +74,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
mPkContainer = (RelativeLayout) findViewById(R.id.pk_container);
- mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
+// mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
leave = (ImageView) findViewById(R.id.leave);
mLoading = findViewById(R.id.loading);
mCover = (ImageView) findViewById(R.id.cover);
@@ -129,14 +125,14 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
*/
@Override
public void play(String url,int playModel) {
- mPlayer = new V2TXLivePlayerImpl(mContext);
+ /* mPlayer = new V2TXLivePlayerImpl(mContext);
if (TextUtils.isEmpty(url) || mVideoView == null) {
return;
}
mPlayer.setRenderView(mVideoView);
- mPlayer.startPlay(url);
+ mPlayer.startPlay(url);*/
// mPlayer.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFit);
onPrepared();
@@ -152,7 +148,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
public void release() {
mEnd = true;
mStarted = false;
- mPlayer.stopPlay();
+// mPlayer.stopPlay();
L.e(TAG, "release------->");
}
@@ -169,20 +165,20 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void stopPlay2() {
- if (mPlayer != null) {
+ /*if (mPlayer != null) {
mPlayer.stopPlay();
- }
+ }*/
}
public static void setViewUP() {
Log.i("收", "整理");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
// params.height = contexts.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.height = vHeight;
params.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
+ params.addRule(RelativeLayout.ALIGN_TOP);*/
+// mVideoView.requestLayout();
}
/**
@@ -206,17 +202,17 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
if (landscape == 2) {
Log.i("收到socket--->", "还原9:16");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /* RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
- mVideoView.requestLayout();
+ mVideoView.requestLayout();*/
} else {
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
+ mVideoView.requestLayout();*/
}
hideCover();
}
@@ -224,12 +220,12 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void setPkview() {
Log.i("收到socket--->", "变成16:9");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
+ mVideoView.requestLayout();*/
}
@Override
@@ -239,18 +235,18 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
if (landscape == 2) {
Log.i("收到socket--->", "还原9:16");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
- mVideoView.requestLayout();
+ mVideoView.requestLayout();*/
} else {
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /*RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
+ mVideoView.requestLayout();*/
}
}
@@ -322,7 +318,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void changeToLeft() {
- if (mVideoView != null) {
+ /* if (mVideoView != null) {
//
// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mVideoView.getWidth() / 2, DpUtil.dp2px(250));
@@ -336,7 +332,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout();
- }
+ }*/
if (mLoading != null && mLeftContainer != null) {
ViewParent viewParent = mLoading.getParent();
if (viewParent != null) {
@@ -351,11 +347,11 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void changeToBig() {
- if (mVideoView != null) {
+ /*if (mVideoView != null) {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mVideoView.setLayoutParams(params);
- }
+ }*/
if (mLoading != null && mRoot != null) {
ViewParent viewParent = mLoading.getParent();
if (viewParent != null) {
@@ -370,10 +366,10 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void onResume() {
- if (!mPausedPlay && mPaused && mVideoView != null) {
+ /* if (!mPausedPlay && mPaused && mVideoView != null) {
// mVideoView.runInForeground();
// mVideoView.start();
- }
+ }*/
mPaused = false;
}
@@ -393,24 +389,24 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
//全屏
@Override
public void fullScreen() {
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /* RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
params.addRule(RelativeLayout.ALIGN_TOP);
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270);
- mVideoView.requestLayout();
+ mVideoView.requestLayout();*/
}
//小屏
@Override
public void smallScreen() {
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ /* RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
- mVideoView.requestLayout();
+ mVideoView.requestLayout();*/
}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
deleted file mode 100644
index 61525b6d5..000000000
--- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
+++ /dev/null
@@ -1,1418 +0,0 @@
-package com.yunbao.live.views;
-
-import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
-
-import android.Manifest;
-import android.app.Dialog;
-import android.content.Context;
-import android.graphics.Color;
-import android.media.AudioManager;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Looper;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-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.lxj.xpopup.XPopup;
-import com.lxj.xpopup.core.BasePopupView;
-import com.lxj.xpopup.interfaces.XPopupCallback;
-import com.lzf.easyfloat.EasyFloat;
-import com.lzy.okserver.OkDownload;
-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;
-import com.yunbao.common.interfaces.OnItemClickListener;
-import com.yunbao.common.manager.IMLoginManager;
-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.MicStatusManager;
-import com.yunbao.common.utils.ScreenDimenUtil;
-import com.yunbao.common.utils.SpUtil;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.common.utils.WordUtil;
-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.event.LiveAudienceEvent;
-import com.yunbao.live.utils.LiveExoPlayerManager;
-
-import org.greenrobot.eventbus.EventBus;
-import org.greenrobot.eventbus.Subscribe;
-import org.greenrobot.eventbus.ThreadMode;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.RCRTCRemoteUser;
-import cn.rongcloud.rtc.api.RCRTCRoom;
-import cn.rongcloud.rtc.api.RCRTCRoomConfig;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
-import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleDataCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCVideoInputFrameListener;
-import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
-import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
-import cn.rongcloud.rtc.api.stream.RCRTCOutputStream;
-import cn.rongcloud.rtc.api.stream.RCRTCVideoInputStream;
-import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
-import cn.rongcloud.rtc.api.stream.RCRTCVideoView;
-import cn.rongcloud.rtc.base.RCRTCLiveRole;
-import cn.rongcloud.rtc.base.RCRTCMediaType;
-import cn.rongcloud.rtc.base.RCRTCParamsType;
-import cn.rongcloud.rtc.base.RCRTCRemoteVideoFrame;
-import cn.rongcloud.rtc.base.RCRTCRoomType;
-import cn.rongcloud.rtc.base.RCRTCStreamType;
-import cn.rongcloud.rtc.base.RTCErrorCode;
-import cn.rongcloud.rtc.core.RendererCommon;
-
-public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
-
- private static final String TAG = "LivePlayViewHolder";
- private ViewGroup mRoot;
- private ViewGroup mSmallContainer;
- private ViewGroup mLeftContainer;
- private ViewGroup mRightContainer;
- private RelativeLayout mPkContainer;
- public StyledPlayerView mVideoView;
-
- private View mLoading, mLoading2;
- private ImageView mCover;
- private boolean mPaused;//是否切后台了
- private boolean mStarted;//是否开始了播放
- private boolean mEnd;//是否结束了播放
- public static ImageView leave;
-
- private boolean mPausedPlay;//是否被动暂停了播放
- public int landscape; //1h 2s
- public Context contexts;
- public FrameLayout ry_view;
-
- private static final int VIDEO_VERTICAL = 2;
- private static final int VIDEO_HORIZONTAL = 1;
- int videoLandscape = -1; // 视频方向,2=竖屏,1=横屏
-
- static int vHeight;//视频高
- private TextView debugView;
- private LiveExoPlayerManager mPlayer;
- private boolean isPk = false;
- private boolean userJoinLinkMic = false;//用户是否已加入房间
-
- //0未申请1申请中2连麦中
- RCRTCRoom rcrtcRoom;
- String purl, srcUrl;
-
- public int getLandscape() {
- return landscape;
- }
-
- public LivePlayRyViewHolder(Context context, ViewGroup parentView, int landscapes) {
- super(context, parentView);
- contexts = context;
- landscape = landscapes;
- Log.i("收收收", landscape + "");
- }
-
-
- @Override
- protected int getLayoutId() {
- return R.layout.view_live_play_ksy;
- }
-
- @Override
- public void init() {
- Log.i(TAG, "init: 初始化播放器ViewHolder");
- EventBus.getDefault().register(this);
- Bus.getOn(this);
- mRoot = (ViewGroup) findViewById(R.id.root);
- 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);
- mVideoView = (StyledPlayerView) findViewById(R.id.video_view);
- ry_view = (FrameLayout) findViewById(R.id.ry_view);
- leave = (ImageView) findViewById(R.id.leave);
- mLoading = findViewById(R.id.loading);
- mLoading2 = findViewById(R.id.loading2);
- mCover = (ImageView) findViewById(R.id.cover);
- ScreenDimenUtil util = ScreenDimenUtil.getInstance();
- int mScreenWdith = util.getScreenWdith();
- vHeight = mScreenWdith * 720 / 960;
-
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams();
- params.height = vHeight;
- mPkContainer.requestLayout();
-
- mPlayer = new LiveExoPlayerManager(mContext);
- mPlayer.setMainView(mVideoView);
- mPlayer.setListener(new ExoPlayerListener());
- debugView = new TextView(mContext);
- debugView.setBackgroundColor(Color.WHITE);
-
- }
-
- @Override
- public void hideCover() {
-// if (mCover != null) {
-// if (mCover.getVisibility()==View.VISIBLE){
-//// new Handler().postDelayed(new Runnable() {
-//// @Override
-//// public void run() {
-////
-//// }
-//// },200);
-// mCover.setVisibility(View.GONE);
-// mLoading2.setVisibility(View.GONE);
-// }
-//
-//
-// }
- }
-
- @Override
- public void setCover(String coverUrl) {
-// if (mCover != null) {
-// mCover.setVisibility(View.VISIBLE);
-// mLoading2.setVisibility(View.VISIBLE);
-// ImgLoader.displayBlurLive(mContext, coverUrl, mCover, 400, 600);
-//
-// }
- }//
-
- @Override
- public synchronized void setLiveBeanLandscape(int landscape) {
-// landscape=1;
- Log.i(TAG, "setLiveBeanLandscape: " + landscape + " isPk: " + isPk);
- this.landscape = landscape;
- this.videoLandscape = landscape;
- if (mPlayer != null) {
- mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
- }
-
- if (landscape == 2) {
- Log.i(TAG, "还原9:16");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
- params.topMargin = 0;
- mVideoView.setLayoutParams(params);
- mVideoView.requestLayout();
-
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
- params1.height = RelativeLayout.LayoutParams.MATCH_PARENT;
- params1.topMargin = 0;
- ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
- RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
- params2.height = RelativeLayout.LayoutParams.MATCH_PARENT;
- params2.topMargin = 0;
- mCover.setLayoutParams(params2);
- mCover.requestLayout();
-
- } else {
- Log.i(TAG, "还原16:9");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = vHeight;
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.setLayoutParams(params);
- mVideoView.requestLayout();
-
- 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();
- RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
- params2.height = DpUtil.dp2px(270);
- params2.topMargin = DpUtil.dp2px(120);
- mCover.setLayoutParams(params2);
- mCover.requestLayout();
- }
- }
-
- @Override
- public void setLiveEnterRoomNewModel(EnterRoomNewModel data) {
- super.setLiveEnterRoomNewModel(data);
- isPk = data.getEnterRoomInfo().getIsconnection().equals("1");
- if (isPk) {
- setLiveBeanLandscape(1);
- }
- }
-
- /**
- * 暂停播放
- */
- @Override
- public void pausePlay() {
-
- }
-
- /**
- * 暂停播放后恢复
- */
- @Override
- public void resumePlay() {
- if (!mPlayer.isPlaying()) {
- new Handler(Looper.getMainLooper())
- .postDelayed(() -> {
- mPlayer.replay();
- // ToastUtil.show("强制播放" + val);
- }, 100);
- }
- }
-
- /**
- * 开始播放
- *
- * @param url 流地址
- */
- @Override
- public void play(String url, int playModel) {
- srcUrl = url;
- PLAY_MODEL = playModel;
- waitNextUrl = null;
- Log.i(TAG, "play" + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape" + videoLandscape);
- if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
- mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
- if (landscape == VIDEO_VERTICAL && !isPk) {
- url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
- } else if (landscape == VIDEO_HORIZONTAL || isPk) {
- url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
- }
- } else if (!url.contains(videoFps[0] + ".flv")) {
- mPlayer.setViewResizeMode(false);
- }
- Log.e("purl121", url);
-
- if (TextUtils.isEmpty(url) || mVideoView == null) {
- return;
- }
-
- if (TextUtils.isEmpty(url) || mVideoView == null) {
- return;
- }
- if (mPlayer.isPlaying()) {
- mPlayer.stop();
- mPlayer.clearUrl();
- }
- mPlayer.startUrl(url);
- purl = url;
- onPrepared();
- }
-
- @Override
- public void switchStream(String url, int playModel) {
- srcUrl = url;
- PLAY_MODEL = playModel;
- Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape + " ispk = " + isPk + " bean = " + roomModel.getEnterRoomInfo().getIsconnection());
- if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
- mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
- if (landscape == VIDEO_VERTICAL && !isPk) {
- url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
- } else if (landscape == VIDEO_HORIZONTAL || isPk) {
- url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
- }
- } else if (!url.contains(videoFps[0] + ".flv")) {
- mPlayer.setViewResizeMode(false);
- }
- Log.e("purl121", url);
-
- if (TextUtils.isEmpty(url) || mVideoView == null) {
- return;
- }
-
-
- if (TextUtils.isEmpty(url) || mVideoView == null) {
- return;
- }
- mPlayer.switchUrl(url);
- purl = url;
- }
-
- boolean tmpPk = false;
- String waitNextUrl = null;
-
- @Override
- public void switchStreamPk(boolean isPk) {
- super.switchStreamPk(isPk);
- Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2 = " + this.isPk);
- if (this.isPk && tmpPk) return;
- if (isPk && !tmpPk || this.isPk) {
- mPlayer.setViewResizeMode(false);
- String url;
- if (PLAY_MODEL != -1) {
- url = srcUrl.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
- } else {
- url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv");
- }
- if (!tmpPk) {
- waitNextUrl = url;
- }
- mPlayer.switchUrl(srcUrl);
- tmpPk = true;
- } else if (!isPk) {
- tmpPk = false;
- if (landscape == VIDEO_VERTICAL && PLAY_MODEL != -1) {
- waitNextUrl = srcUrl.replace(".flv", videoRatioVertical[PLAY_MODEL] + videoFps[0] + ".flv");
- } else if (landscape == VIDEO_HORIZONTAL && PLAY_MODEL != -1) {
- waitNextUrl = srcUrl.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
- } else {
- waitNextUrl = null;
- }
- mPlayer.switchUrl(srcUrl);
- }
- }
-
- @Override
- public void clearFrame() {
- super.clearFrame();
- mPlayer.clearFrame();
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.setLayoutParams(params);
- mVideoView.requestLayout();
-
- 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();
- RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
- params2.height = DpUtil.dp2px(270);
- params2.topMargin = DpUtil.dp2px(120);
- mCover.setLayoutParams(params2);
- mCover.requestLayout();
- }
-
- @Override
- public void endPk() {
-
- }
-
- @Override
- public void endpk(String liveUid) {
-
- }
-
- @Override
- public void initSwEngine(String liveUid) {
-
- }
-
- @Override
- public void removeLiveUid(String uid) {
-
- }
-
- @Override
- public void release() {
- mEnd = true;
- mStarted = false;
- if (mPlayer != null) {
- mPlayer.stop();
- mPlayer.release();
- }
- Bus.getOff(this);
- EventBus.getDefault().unregister(this);
- L.e(TAG, "release------->");
- }
-
- @Override
- public void stopPlay() {
- Log.i(TAG, "stopPlay: ");
- if (mCover != null) {
- mCover.setAlpha(1f);
- if (mCover.getVisibility() != View.VISIBLE) {
- mCover.setVisibility(View.VISIBLE);
- }
- }
- if (mPlayer != null) {
- mPlayer.stop();
- }
- stopPlay2();
- }
-
- @Override
- public void stopPlay2() {
-
- }
-
- @Override
- public void setViewUP(int i) {
- if (mVideoView == null) return;
- Log.e("PK状态", "" + i);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = vHeight;
- params.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
-
- 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();
- isPk = true;
- if (mPlayer.getUrl().contains("848_24.flv") || mPlayer.getUrl().contains("1280_24.flv")) {
- tmpPk = false;
- switchStreamPk(true);
- }
- }
-
- /**
- * 播放开始
- */
- public void onPrepared() {
- if (mEnd) {
- release();
- return;
- }
- int height;
- if (videoLandscape == VIDEO_VERTICAL) {
- height = ViewGroup.LayoutParams.MATCH_PARENT;
- } else {
- height = ViewGroup.LayoutParams.WRAP_CONTENT;
- }
- mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
- if (landscape == 2) {
- Log.i(TAG, "onPrepared:还原9:16 land=" + videoLandscape);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = height;
- params.topMargin = 0;
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.setLayoutParams(params);
- mVideoView.requestLayout();
-
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
- params1.height = height;
- params1.topMargin = 0;
- ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
- RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
- params2.height = height;
- params2.topMargin = 0;
- mCover.setLayoutParams(params2);
- mCover.requestLayout();
- } else {
- Log.i(TAG, "onPrepared:还原16:9");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = height;
- params.topMargin = 0;
- if (videoLandscape == VIDEO_HORIZONTAL) {
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- }
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.setLayoutParams(params);
- mVideoView.requestLayout();
-
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
- params1.height = height;
- params1.topMargin = 0;
- params1.addRule(RelativeLayout.ALIGN_TOP);
- if (videoLandscape == VIDEO_HORIZONTAL) {
- params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- }
- ry_view.setLayoutParams(params1);
- ry_view.requestLayout();
- RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
- params2.height = height;
- params2.topMargin = DpUtil.dp2px(120);
- mCover.setLayoutParams(params2);
- mCover.requestLayout();
- }
- }
-
- @Override
- public void setPkview() {
- Log.i("收到socket--->", "变成16:9");
- String url = srcUrl;
- isPk = true;
- switchStreamPk(true);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = vHeight;
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
- }
-
- @Override
- public synchronized void setPkEndview() {
-
- Log.i("收收收", landscape + "");
- isPk = false;
- tmpPk = false;
- switchStreamPk(false);
- if (landscape == 2) {
- Log.i("收到socket--->", "还原9:16");
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
- params.topMargin = 0;
- mVideoView.requestLayout();
-
- } else {
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = vHeight;
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
- }
-// if (detailsView != null) {
-// mVideoView.removeView(detailsView);
-// detailsView = null;
-// }
- }
-
- @Override
- public void setDrMicInfo(UserBean u) {
-
- }
-
- public void removeDetailView() {
-// if (detailsView != null) {
-// mVideoView.removeView(detailsView);
-// detailsView = null;
-// }
- }
-
- @Override
- public void setPkView(String liveUid) {
-
- }
-
- @Override
- public void claerDrPkInfoView() {
-
- }
-
- @Override
- public void endLiveMic() {
-
- }
-
- @Override
- public ViewGroup getSmallContainer() {
- return mSmallContainer;
- }
-
-
- @Override
- public ViewGroup getRightContainer() {
- return mRightContainer;
- }
-
- @Override
- public ViewGroup getPkContainer() {
- return mPkContainer;
- }
-
- @Override
- public void changeToLeft() {
- if (mVideoView != null) {
-
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = vHeight;
-// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
-
- }
- if (mLoading != null && mLeftContainer != null) {
- ViewParent viewParent = mLoading.getParent();
- if (viewParent != null) {
- ((ViewGroup) viewParent).removeView(mLoading);
- }
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
- params.gravity = Gravity.CENTER;
- mLoading.setLayoutParams(params);
- mLeftContainer.addView(mLoading);
- }
- }
-
- @Override
- public void changeToBig() {
- if (mVideoView != null) {
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
- mVideoView.setLayoutParams(params);
-
- }
- if (mLoading != null && mRoot != null) {
- ViewParent viewParent = mLoading.getParent();
- if (viewParent != null) {
- ((ViewGroup) viewParent).removeView(mLoading);
- }
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
- params.addRule(RelativeLayout.CENTER_IN_PARENT);
- mLoading.setLayoutParams(params);
- System.out.println(" changeToBig changeToBig changeToBig"+mLoading.getParent());
- if(mLoading.getParent()!=mRoot){
- mRoot.addView(mLoading);
- }
- }
- }
-
- @Override
- public void onResume() {
- if (!mPausedPlay && mPaused && mVideoView != null) {
-// mVideoView.runInForeground();
-// mVideoView.start();
- }
- mPaused = false;
-// if (mPlayer.isPlaying() == 1) {
-// mPlayer.resumeVideo();
-// mPlayer.resumeAudio();
-// }
- }
-
- @Override
- public void onPause() {
-// if (!mPausedPlay && mVideoView != null) {
-// mVideoView.runInBackground(false);
-// }
-// mPaused = true;
-// mPlayer.pauseVideo();
-// mPlayer.pauseAudio();
- }
-
- @Override
- public void onDestroy() {
- release();
- }
-
- //全屏
- @Override
- public void fullScreen() {
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
- params.topMargin = 0;
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
- }
-
- //小屏
- @Override
- public void smallScreen() {
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- params.height = vHeight;
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
- params.addRule(RelativeLayout.ALIGN_TOP);
- mVideoView.requestLayout();
- }
-
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onUpdata(String str) {
- if ("UsertoRY".equals(str)) {
- DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.mic_tag), new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- UsertoRY();
- dialog = null;
- }
- });
-
- } else if ("inviteMic".equals(str)) {
- String content = "邀請您進行語音連麥";
- String confirm = "接受";
- String cancel = "拒絕";
- if (!WordUtil.isNewZh()) {
- content = "You are invited to join the voice connection";
- 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() {
- @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();
-
- }
- });
- }
- });
- builder.build().show();
-
- } else if ("endMic".equals(str)) {
- if (rcrtcRoom != null) {
- // 开始切换为观众身份
- RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {
-
- /**
- * 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。
- * SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。
- */
- @Override
- public void onKicked() {
-
- }
-
- @Override
- public void onSuccess() {
- Log.e("ry", "下麦成功");
- // 该用户切换为观众成功,可以以观众身份进行音视频
- //退出rtc播放
- leaveRoom();
- }
-
- /**
- * 当切换失败且不影响当前角色继续音视频时回调
- * @param errorCode 失败错误码
- */
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", "下麦失败" + errorCode);
- leaveRoom();
- }
-
- private void leaveRoom() {
- RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- userJoinLinkMic = false;
- Log.e("ry", "退出多人房间成功");
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
- if (WordUtil.isNewZh()) {
- ToastUtil.show("已成功退出語音連麥");
- } else {
- ToastUtil.show("You have successfully exited the voice connection");
- }
- if (mPlayer.getNowPlayer() != null) {
- mPlayer.play();
- Log.e("ry", mPlayer.isPlaying() + "purl" + purl);
- if (!mPlayer.isPlaying()) {
- mPlayer.switchUrl(purl);
- }
- ry_view.removeAllViews();
- ry_view.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
- onPrepared();
- rcrtcRoom = null;
- MicStatusManager.getInstance().clear();
-
- resumePlay();
- }
-
- if (onMicCallback != null) {
- onMicCallback.onMikUpdate();
- }
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", errorCode + "退出多人房间成功");
- userJoinLinkMic = false;
- }
- });
-
- }
- });
- }
- } else if ("Debug".equals(str)) {
- if (EasyFloat.isShow("Debug")) {
- EasyFloat.dismiss("Debug");
- return;
- }
- EasyFloat.with(mContext)
- .setDragEnable(true)
- .setTag("Debug")
- .setLayout(debugView)
- .show();
- }
- }
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onOpenDrawer(LiveAudienceEvent event) {
- if (event.getType() == LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO) {
- int ban = 0;//全模式都可以选择
- switch (roomModel.getClarityType() - 1) {
- case PLAY_MODEL_720://仅允许720(高清),ban掉1080(超高清)模式
- ban = LiveClarityCustomPopup.BAN_1080;
- break;
- case -1://没有该字段
- case PLAY_MODEL_480://仅允许480(流畅),ban掉1080(超高清)和720(高清)模式
- ban = LiveClarityCustomPopup.BAN_720;
- 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) {
-
- }
-
- @Override
- public void beforeShow(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();
- }
-
- 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 boolean onBackPressed(BasePopupView popupView) {
- return false;
- }
-
- @Override
- public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
-
- }
-
- @Override
- public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
-
- }
-
- @Override
- public void onClickOutside(BasePopupView popupView) {
-
- }
- })
- .asCustom(liveClarityCustomPopup)
- .show();
- } else if (event.getType() == LiveAudienceEvent.LiveAudienceType.FONT_SIZE) {
- int fount = 0;
- try {
- fount = Integer.parseInt(SpUtil.getStringValue("pd_live_room_fount_size"));
- } catch (Exception ignored) {
-
- }
- 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));
- }
- }).showDialog();
- }
- }
-
- /**
- * 把观众转换成主播
- */
- public List userinputStreamList = new ArrayList<>();
-
-
- public void UsertoRY() {
- userinputStreamList.clear();
- Log.e("ry", "主播同意了UsertoRY");
- if (userJoinLinkMic) {//已经在房间内,不再joinRoom直接去连麦
- subscribeMic(rcrtcRoom);
- return;
- }
- RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
- // 根据实际场景,选择音视频直播:LIVE_AUDIO_VIDEO 或音频直播:LIVE_AUDIO
- .setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO)
- .setLiveRole(RCRTCLiveRole.AUDIENCE)
- .build();
- RCRTCEngine.getInstance().joinRoom(LiveActivity.mLiveUid, roomConfig, new IRCRTCResultDataCallback() {
-
-
- @Override
- public void onSuccess(RCRTCRoom data) {
- userJoinLinkMic = true;
- rcrtcRoom = data;
- subscribeMic(data);
-
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", LiveActivity.mLiveUid + errorCode + "");
- if (errorCode.getValue() == 50007) {//userJoinLinkMic可能失效,直接leaveRoom
- userJoinLinkMic = false;
- RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- UsertoRY();
- }
- });
- } else {
- ToastUtil.show("房间失败" + errorCode);
- }
-
- }
- });
-
-
- }
-
- private void subscribeMic(RCRTCRoom data) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- RCRTCEngine.getInstance().enableSpeaker(true);
- //遍历远端用户发布的资源列表
- Log.i(TAG, "软件资源数量:" + data.getLiveStreams().size());
- for (RCRTCInputStream stream : data.getLiveStreams()) {
- Log.i(TAG, "资源流 type: " + stream.getMediaType());
- if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
- //暂停播放
- mPlayer.stop();
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
-
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- //todo 本demo只演示添加1个远端用户的视图
- remoteView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- remoteView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
- ry_view.addView(remoteView);
- Log.e("ry", stream.getMediaType() + "rcrtcOtherRoom成功 :" + data.getLiveStreams().size());
- }
- userinputStreamList.add(stream);
- }
- rcrtcRoom.getLocalUser().subscribeStreams(userinputStreamList, new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", userinputStreamList.size() + LiveActivity.mLiveUid + "订阅失败" + errorCode.toString());
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
-
- @Override
- public void onSuccess() {
- Log.e("ry", "订阅资源成功");
-// new Handler().postDelayed(new Runnable() {
-// @Override
-// public void run() {
- toMic();
-// }
-// }, 3000);
-
- }
- });
- }
- });
- }
-
- /**
- * 主房间事件监听
- * 详细说明请参考文档:https://www.rongcloud.cn/docs/api/android/rtclib_v4/cn/rongcloud/rtc/api/callback/IRCRTCRoomEventsListener.html
- */
- public IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() {
- @Override
- public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, List list) {
- Log.e("ry", "远端来了" + list.size());
- //TODO 按需在此订阅远端用户发布的资源
- rcrtcRoom.getLocalUser().subscribeStreams(list, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "远端成功" + list.size());
-
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", "远端失败" + list.size());
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
- });
- }
-
- @Override
- public void onRemoteUserMuteAudio(RCRTCRemoteUser remoteUser, RCRTCInputStream stream, boolean mute) {
-
- }
-
- @Override
- public void onRemoteUserMuteVideo(RCRTCRemoteUser remoteUser, RCRTCInputStream stream, boolean mute) {
-
- }
-
- @Override
- public void onRemoteUserUnpublishResource(RCRTCRemoteUser remoteUser, List streams) {
-
- }
-
- @Override
- public void onUserJoined(RCRTCRemoteUser remoteUser) {
-
- }
-
- @Override
- public void onUserLeft(RCRTCRemoteUser remoteUser) {
-
- }
-
- @Override
- public void onUserOffline(RCRTCRemoteUser remoteUser) {
-
- }
-
- @Override
- public void onPublishLiveStreams(List streams) {
-
- }
-
- @Override
- public void onUnpublishLiveStreams(List streams) {
-
- }
- };
-
-
- public List userinputStreamList1 = new ArrayList<>();
- public List userinputStreamList2 = new ArrayList<>();
-
- public void toMic() {
- RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC, RCRTCParamsType.AudioScenario.MUSIC_CLASSROOM);
- userinputStreamList1.clear();
- userinputStreamList2.clear();
- RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- int minRate = 200;
- int maxRate = 900;
- switch (IMLoginManager.get(mContext).getSelectClarity()) {
- case 0:
- rcrtcVideoResolution = landscape == 1 ? RCRTCParamsType.RCRTCVideoResolution.parseVideoResolution(960, 720) : RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- minRate = landscape == 1 ? 900 : 200;
- maxRate = landscape == 1 ? 700 : 900;
- break;
- case 1:
- rcrtcVideoResolution = landscape == 1 ? RCRTCParamsType.RCRTCVideoResolution.parseVideoResolution(960, 720) : RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
- minRate = landscape == 1 ? 900 : 250;
- maxRate = landscape == 1 ? 700 : 2200;
- break;
- case 2:
- rcrtcVideoResolution = landscape == 1 ? RCRTCParamsType.RCRTCVideoResolution.parseVideoResolution(960, 720) : RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
- minRate = landscape == 1 ? 900 : 400;
- maxRate = landscape == 1 ? 700 : 4000;
- break;
- }
- // 示例代码使用480x640分辨率演示
- RCRTCVideoStreamConfig config = RCRTCVideoStreamConfig
- .Builder.create()
- //设置分辨率
- .setVideoResolution(rcrtcVideoResolution)
- //设置帧率
- .setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_24)
- //设置最小码率,480P下推荐200
- .setMinRate(minRate)
- //设置最大码率,480P下推荐900
- .setMaxRate(maxRate)
- .build();
- RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);
-// 创建视图渲染视图
-// RCRTCVideoView videoView = new RCRTCVideoView(contexts);
-// RCRTCEngine.getInstance().getDefaultVideoStream().setVideoView(videoView);
-//TODO 示例代码使用获取本地默认视频流、音频流演示
- ArrayList streams = new ArrayList<>();
-// streams.add(RCRTCEngine.getInstance().getDefaultVideoStream());
- streams.add(RCRTCEngine.getInstance().getDefaultAudioStream());
- if (landscape == 1) {
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
- setLiveBeanLandscape(1);
- }
- });
-
- }
-// 开启摄像头
-// RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(null);
-// 开始切换为主播身份
- RCRTCEngine.getInstance().getRoom().getLocalUser().switchToBroadcaster(streams, new IRCRTCSwitchRoleDataCallback() {
- /**
- * 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。
- * SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。
- */
- @Override
- public void onKicked() {
- Log.e("ry", "切换onKicked");
-
- }
-
- @Override
- public void onSuccess(RCRTCLiveInfo data) {
- rcrtcRoom.registerRoomListener(roomEventsListener);
- //该用户切换为主播成功,可以以主播身份进行音视频
- Log.e("ry", "切换成功");
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
- if (onMicCallback != null) {
- onMicCallback.onMikUpdate();
- }
- //遍历远端用户列表
- for (int i = 0; i < rcrtcRoom.getRemoteUsers().size(); i++) {
- Log.e("ry", rcrtcRoom.getRemoteUsers().get(i).getUserId() + "收到rcrtcOtherRoom" + rcrtcRoom.getRemoteUsers().size());
- //遍历远端用户发布的资源列表
- for (RCRTCInputStream stream : rcrtcRoom.getRemoteUsers().get(i).getStreams()) {
- Log.e("ry", i + "收到" + stream.getMediaType() + "实打实打算" + rcrtcRoom.getRemoteUsers().get(i).getUserId());
- if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
- if (userinputStreamList1.size() == 0) {
-
- //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示
- RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
- ((RCRTCVideoInputStream) stream).setStreamType(RCRTCStreamType.NORMAL);
- ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
- ((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";
- //Log.d("ry", "onFrame: " + debugText);
- new Handler(Looper.getMainLooper()).post(() -> {
- debugView.setText(debugText);
-
- });
- }
- });
- //todo 本demo只演示添加1个远端用户的视图
- ry_view.removeAllViews();
- remoteView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- remoteView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
- ry_view.addView(remoteView);
- }
- userinputStreamList1.add(stream);
- }
- userinputStreamList2.add(stream);
- }
- }
- //开始订阅资源
- rcrtcRoom.getLocalUser().subscribeStreams(userinputStreamList2, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "订阅资源成功");
- MicStatusManager.getInstance().setMicData(MicStatusManager.MIC_TYPE_OPEN, LiveActivity.mLiveUid);
- AudioManager audioManager = (AudioManager) contexts.getSystemService(Context.AUDIO_SERVICE);
- RCRTCEngine.getInstance().enableSpeaker(true);
- audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
- audioManager.setSpeakerphoneOn(true);
-
- HttpClient.getInstance().get("jiaruduorenlianmai", "jiaruduorenlianmai")
- .params("roomid", LiveActivity.mLiveUid)
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- Log.e("ry", code + "热热热");
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", "订阅资源失败: " + rtcErrorCode.getReason());
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
- });
- }
- });
-
-
- }
-
- /**
- * 当切换失败且不影响当前角色继续音视频时回调
- * @param errorCode 失败错误码
- */
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", errorCode + "切换失败");
-
- }
- });
- }
-
- @Override
- public void setLoadViewListener(LoadingListener listener) {
- super.setLoadViewListener(listener);
- }
-
- 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();
- PLAY_MODEL = PLAY_MODEL_480;
- String url = srcUrl;
- if (videoLandscape == VIDEO_VERTICAL) {
- url = url.replace(".flv", videoRatioVertical[PLAY_MODEL_480] + videoFps[0] + ".flv");
- } else if (videoLandscape == VIDEO_HORIZONTAL) {
- url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL_480] + videoFps[0] + ".flv");
- }
- mPlayer.switchUrl(url);
- }
-
- private class ExoPlayerListener implements Player.Listener {
- String TAG = "播放流";
-
- @Override
- public void onPlayerError(PlaybackException error) {
- Player.Listener.super.onPlayerError(error);
- debugView.setText("播放出错code=" + error.errorCode + " msg=" + error.getErrorCodeName());
- }
-
- @Override
- public void onVideoSizeChanged(VideoSize videoSize) {
- Player.Listener.super.onVideoSizeChanged(videoSize);
- Log.i(TAG, "onVideoSizeChanged: width = " + videoSize.width + " height = " + videoSize.height);
- //ToastUtil.show("分辨率: 宽 = " + videoSize.width + " 高 = " + videoSize.height);
- if (videoSize.height > videoSize.width) {
- videoLandscape = VIDEO_VERTICAL;
- } else {
- videoLandscape = VIDEO_HORIZONTAL;
- }
- }
-
- @Override
- public void onPlaybackStateChanged(int playbackState) {
- Player.Listener.super.onPlaybackStateChanged(playbackState);
- if (playbackState == Player.STATE_BUFFERING) {
- //showLoadingDialog();
- mLoading.setVisibility(View.VISIBLE);
- OkDownload.getInstance().pauseAll();
- Log.i(TAG, "onPlaybackStateChanged: 缓存中");
- } else {
- mLoading.setVisibility(View.INVISIBLE);
- Log.i(TAG, "onPlaybackStateChanged: 播放中");
- }
- }
-
- @Override
- public void onIsPlayingChanged(boolean isPlaying) {
- Player.Listener.super.onIsPlayingChanged(isPlaying);
- if (isPlaying) {
- hideCover();
- mLoading.setVisibility(View.INVISIBLE);
- Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = " + waitNextUrl);
- OkDownload.getInstance().startAll();
- if (loadingListener != null) {
- loadingListener.onPlayer();
- }
- if (waitNextUrl != null) {
- mPlayer.switchUrl(waitNextUrl);
- waitNextUrl = null;
- }
- }
- }
- }
-
- private int mPkTimeCount = 0;
-
-
- public interface PlayViewLayoutInterface {
- void playViewLayout(int width, int height);
- }
-
- private PlayViewLayoutInterface layoutInterface;
-
- public void setLayoutInterface(PlayViewLayoutInterface layoutInterface) {
- mVideoView.post(new Runnable() {
- @Override
- public void run() {
- int width = mVideoView.getMeasuredWidth();
- int height = mVideoView.getMeasuredHeight();
- if (layoutInterface != null) {
- layoutInterface.playViewLayout(width, height);
- }
- }
- });
- }
-
-
-}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java
index 77ecab073..c20e51ae2 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java
@@ -68,7 +68,6 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
-import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
@@ -1083,10 +1082,8 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
/**
* 把观众转换成主播
*/
- public List userinputStreamList = new ArrayList<>();
public void UsertoRY() {
- userinputStreamList.clear();
Log.e("ry", "主播同意了UsertoRY");
joinLiveMic();
}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java
deleted file mode 100644
index 6097d1038..000000000
--- a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java
+++ /dev/null
@@ -1,545 +0,0 @@
-package com.yunbao.live.views;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.tencent.live2.V2TXLiveDef;
-import com.tencent.live2.V2TXLivePlayer;
-import com.tencent.live2.V2TXLivePlayerObserver;
-import com.tencent.live2.impl.V2TXLivePlayerImpl;
-import com.tencent.rtmp.ITXLivePlayListener;
-import com.tencent.rtmp.TXLivePlayConfig;
-import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.yunbao.common.bean.UserBean;
-import com.yunbao.common.glide.ImgLoader;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.utils.L;
-import com.yunbao.live.R;
-import com.yunbao.common.http.LiveHttpConsts;
-import com.yunbao.common.http.LiveHttpUtil;
-
-/**
- * Created by cxf on 2018/10/10.
- * 直播间播放器 腾讯播放器
- */
-
-public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXLivePlayListener {
-
- private static final String TAG = "LiveTxPlayViewHolder";
- private ViewGroup mRoot;
- private ViewGroup mSmallContainer;
- private ViewGroup mLeftContainer;
- private ViewGroup mRightContainer;
- private ViewGroup mPkContainer;
- private TXCloudVideoView mVideoView;
- private View mLoading;
- private ImageView mCover;
- private V2TXLivePlayer mPlayer;
- private boolean mPaused;//是否切后台了
- private boolean mStarted;//是否开始了播放
- private boolean mEnd;//是否结束了播放
- private boolean mPausedPlay;//是否被动暂停了播放
- private boolean mChangeToLeft;
- private boolean mChangeToAnchorLinkMic;
- private String mUrl;
- private int mPlayType;
- private HttpCallback mGetTxLinkMicAccUrlCallback;
- private Handler mHandler;
- private int mVideoLastProgress;
-
-
- public LivePlayTxViewHolder(Context context, ViewGroup parentView) {
- super(context, parentView);
- }
-
- @Override
- public void setPkview() {
-
- }
-
- @Override
- public void setPkEndview() {
-
- }
-
- @Override
- public void setDrMicInfo(UserBean u) {
-
- }
-
- @Override
- public void setLiveBeanLandscape(int landscape) {
- }
-
- @Override
- public void endPk() {
-
- }
-
- @Override
- public void endpk(String liveUid) {
-
- }
-
- @Override
- public void initSwEngine(String liveUid) {
-
- }
-
- @Override
- public void removeLiveUid(String uid) {
-
- }
-
- @Override
- public void removeDetailView() {
-
- }
-
- @Override
- public void setPkView(String liveUid) {
-
- }
-
- @Override
- public void claerDrPkInfoView() {
-
- }
-
- @Override
- public void endLiveMic() {
-
- }
-
- @Override
- protected int getLayoutId() {
- return R.layout.view_live_play_tx;
- }
-
- @Override
- public void init() {
- mRoot = (ViewGroup) findViewById(R.id.root);
- mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
- mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
- mRightContainer = (ViewGroup) findViewById(R.id.right_container);
- mPkContainer = (ViewGroup) findViewById(R.id.pk_container);
- mLoading = findViewById(R.id.loading);
- mCover = (ImageView) findViewById(R.id.cover);
- mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
-
-// mPlayer.setPlayListener(this);
-// mPlayer.setPlayerView(mVideoView);
-// mPlayer.enableHardwareDecode(false);
- // 设置画面渲染方向
-// mPlayer.setRenderRotation(TXLiveConstants.RENDER_ROTATION_LANDSCAPE);
- TXLivePlayConfig playConfig = new TXLivePlayConfig();
- playConfig.setAutoAdjustCacheTime(true);
- playConfig.setMaxAutoAdjustCacheTime(5.0f);
- playConfig.setMinAutoAdjustCacheTime(1.0f);
-// mPlayer.setConfig(playConfig);
- }
-
-
- @Override
- public void onPlayEvent(int e, Bundle bundle) {
- if (mEnd) {
- return;
- }
-// switch (e) {
-// case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://播放开始
-// if (mLoading != null && mLoading.getVisibility() == View.VISIBLE) {
-// mLoading.setVisibility(View.INVISIBLE);
-// }
-// break;
-// case TXLiveConstants.PLAY_EVT_PLAY_LOADING:
-// if (mLoading != null && mLoading.getVisibility() != View.VISIBLE) {
-// mLoading.setVisibility(View.VISIBLE);
-// }
-// break;
-// case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://第一帧
-// hideCover();
-// break;
-// case TXLiveConstants.PLAY_EVT_PLAY_END://播放结束
-// replay();
-// break;
-// case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取视频宽高
-// if (mChangeToLeft || mChangeToAnchorLinkMic) {
-// return;
-// }
-// float width = bundle.getInt("EVT_PARAM1", 0);
-// float height = bundle.getInt("EVT_PARAM2", 0);
-// L.e(TAG, "流---width----->" + width);
-// L.e(TAG, "流---height----->" + height);
-// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
-// int targetH = 0;
-// if (width >= height) {//横屏 9:16=0.5625
-// targetH = (int) (mVideoView.getWidth() / width * height);
-// } else {
-// targetH = ViewGroup.LayoutParams.MATCH_PARENT;
-// }
-// if (targetH != params.height) {
-// params.height = targetH;
-// params.gravity = Gravity.TOP;
-// params.topMargin = 230;
-// mVideoView.requestLayout();
-// }
-//
-// break;
-// case TXLiveConstants.PLAY_ERR_NET_DISCONNECT://播放失败
-// case TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND:
-// ToastUtil.show(mContext.getString(R.string.live_play_error));
-// break;
-// case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS:
-// int progress = bundle.getInt("EVT_PLAY_PROGRESS_MS");
-// if (mVideoLastProgress == progress) {
-// replay();
-// } else {
-// mVideoLastProgress = progress;
-// }
-// break;
-// default:break;
-// }
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
-
- }
-
-
- @Override
- public void hideCover() {
- if (mCover != null) {
- mCover.animate().alpha(0).setDuration(500).start();
- }
- }
-
- @Override
- public void setCover(String coverUrl) {
- if (mCover != null) {
- ImgLoader.displayBlur(mContext, coverUrl, mCover);
- }
- }
-
- @Override
- public void fullScreen() {
-
- }
-
- @Override
- public void smallScreen() {
-
- }
-
- /**
- * 循环播放
- */
- private void replay() {
- if (mStarted && mPlayer != null) {
-// mPlayer.seek(0);
-// mPlayer.resume();
- }
- }
-
-
- /**
- * 暂停播放
- */
- @Override
- public void pausePlay() {
- if (!mPausedPlay) {
- mPausedPlay = true;
- if (!mPaused) {
- if (mPlayer != null) {
-// mPlayer.pause();
- }
- }
- if (mCover != null) {
- mCover.setAlpha(1f);
- if (mCover.getVisibility() != View.VISIBLE) {
- mCover.setVisibility(View.VISIBLE);
- }
- }
- }
- }
-
- /**
- * 暂停播放后恢复
- */
- @Override
- public void resumePlay() {
- if (mPausedPlay) {
- mPausedPlay = false;
- if (!mPaused) {
- if (mPlayer != null) {
-// mPlayer.resume();
- }
- }
- hideCover();
- }
- }
-
- /**
- * 开始播放
- *
- * @param url 流地址
- */
- @Override
- public void play(String url,int playModel) {
- url = "webrtc://5664.liveplay.myqcloud.com/live/5664_harchar1";
-
- mPlayer = new V2TXLivePlayerImpl(mContext);
- mPlayer.setRenderView(mVideoView);
- mPlayer.setObserver(new V2TXLivePlayerObserver() {
-
- @Override
- public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
- Log.d(TAG, "[Player] onError: player-" + player + " code-" + code + " msg-" + msg + " info-" + extraInfo);
- }
-
- @Override
- public void onVideoPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle bundle) {
- Log.d(TAG, "[Player] onVideoPlayStatusUpdate: player-" + player + ", status-" + status + ", reason-" + reason);
- }
-
- @Override
- public void onWarning(V2TXLivePlayer v2TXLivePlayer, int i, String s, Bundle bundle) {
- Log.d(TAG, "[Player] Override: player-" + v2TXLivePlayer + ", i-" + i + ", s-" + s);
- }
-
- @Override
- public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveDef.V2TXLiveVideoFrame v2TXLiveVideoFrame) {
- super.onRenderVideoFrame(player, v2TXLiveVideoFrame);
- Log.d(TAG, "[Player] onRenderVideoFrame: player-" + player + ", v2TXLiveVideoFrame-" + v2TXLiveVideoFrame);
- }
- });
-
- int result = mPlayer.startPlay(url);
-
- Log.d(TAG, "startPlay : " + result);
-// if (TextUtils.isEmpty(url)) {
-// return;
-// }
-// int playType = -1;
-// if (url.startsWith("rtmp://")) {
-// playType = TXLivePlayer.PLAY_TYPE_LIVE_RTMP;
-// } else if (url.endsWith(".flv")) {
-// playType = TXLivePlayer.PLAY_TYPE_LIVE_FLV;
-// } else if (url.endsWith(".m3u8")) {
-// playType = TXLivePlayer.PLAY_TYPE_VOD_HLS;
-// } else if (url.endsWith(".mp4")) {
-// playType = TXLivePlayer.PLAY_TYPE_VOD_MP4;
-// }
-// if (playType == -1) {
-// ToastUtil.show(R.string.live_play_error_2);
-// return;
-// }
-// if (mPlayer != null) {
-// int result = mPlayer.startPlay(url);
-// if (result == 0) {
- mStarted = true;
-
-// mUrl = url;
-// mPlayType = playType;
-// }
-// }
- L.e(TAG, "play----url--->" + url);
- }
-
- @Override
- public void switchStream(String url, int playModel) {
-
- }
-
- @Override
- public void stopPlay() {
- mChangeToLeft = false;
- mChangeToAnchorLinkMic = false;
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- if (mCover != null) {
- mCover.setAlpha(1f);
- if (mCover.getVisibility() != View.VISIBLE) {
- mCover.setVisibility(View.VISIBLE);
- }
- }
- stopPlay2();
- }
-
- @Override
- public void stopPlay2() {
- if (mPlayer != null) {
- mPlayer.stopPlay();
- }
- }
-
- @Override
- public void release() {
- mEnd = true;
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- mHandler = null;
- LiveHttpUtil.cancel(LiveHttpConsts.GET_TX_LINK_MIC_ACC_URL);
- if (mPlayer != null) {
- mPlayer.stopPlay();
-// mPlayer.setPlayListener(null);
- }
- mPlayer = null;
- L.e(TAG, "release------->");
- }
-
-
- @Override
- public ViewGroup getSmallContainer() {
- return mSmallContainer;
- }
-
-
- @Override
- public ViewGroup getRightContainer() {
- return mRightContainer;
- }
-
- @Override
- public ViewGroup getPkContainer() {
- return mPkContainer;
- }
-
- @Override
- public void changeToLeft() {
-// mChangeToLeft = true;
-// if (mVideoView != null) {
-// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
-// params.width = mVideoView.getWidth() / 2;
-// params.height = DpUtil.dp2px(250);
-// params.topMargin = DpUtil.dp2px(130);
-// mVideoView.setLayoutParams(params);
-// }
-// if (mLoading != null && mLeftContainer != null) {
-// ViewParent viewParent = mLoading.getParent();
-// if (viewParent != null) {
-// ((ViewGroup) viewParent).removeView(mLoading);
-// }
-// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
-// params.gravity = Gravity.CENTER;
-// mLoading.setLayoutParams(params);
-// mLeftContainer.addView(mLoading);
-// }
- }
-
- @Override
- public void changeToBig() {
-// mChangeToLeft = false;
-// if (mVideoView != null) {
-// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
-// params.width = ViewGroup.LayoutParams.MATCH_PARENT;
-// params.height = ViewGroup.LayoutParams.MATCH_PARENT;
-// params.topMargin = 0;
-// mVideoView.setLayoutParams(params);
-// }
-// if (mLoading != null && mRoot != null) {
-// ViewParent viewParent = mLoading.getParent();
-// if (viewParent != null) {
-// ((ViewGroup) viewParent).removeView(mLoading);
-// }
-// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
-// params.gravity = Gravity.CENTER;
-// mLoading.setLayoutParams(params);
-// mRoot.addView(mLoading);
-// }
- }
-
- @Override
- public void onResume() {
- if (!mPausedPlay && mPaused && mPlayer != null) {
-// mPlayer.resume();
- }
- mPaused = false;
- }
-
- @Override
- public void onPause() {
- if (!mPausedPlay && mPlayer != null) {
-// mPlayer.pause();
- }
- mPaused = true;
- }
-
- @Override
- public void onDestroy() {
- release();
- }
-
- /**
- * 腾讯sdk连麦时候切换低延时流
- */
- public void onLinkMicTxAccEvent(boolean linkMic) {
- if (mStarted && mPlayer != null && !TextUtils.isEmpty(mUrl)) {
- mPlayer.stopPlay();
- if (linkMic) {
- if (mGetTxLinkMicAccUrlCallback == null) {
- mGetTxLinkMicAccUrlCallback = new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0 && info.length > 0) {
- JSONObject obj = JSON.parseObject(info[0]);
- if (obj != null) {
- String accUrl = obj.getString("streamUrlWithSignature");
- if (!TextUtils.isEmpty(accUrl) && mPlayer != null) {
- L.e(TAG, "低延时流----->" + accUrl);
- mPlayer.startPlay(accUrl);
- }
- }
- }
- }
- };
- }
- LiveHttpUtil.getTxLinkMicAccUrl(mUrl, mGetTxLinkMicAccUrlCallback);
- } else {
- mPlayer.startPlay(mUrl);
- }
- }
- }
-
- /**
- * 设置主播连麦模式
- *
- * @param anchorLinkMic
- */
- public void setAnchorLinkMic(final boolean anchorLinkMic, int delayTime) {
-// if (mVideoView == null) {
-// return;
-// }
-// if (mHandler == null) {
-// mHandler = new Handler();
-// }
-// mHandler.postDelayed(new Runnable() {
-// @Override
-// public void run() {
-// mChangeToAnchorLinkMic = anchorLinkMic;
-// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
-// Log.d("aaaaa",""+anchorLinkMic);
-// if (anchorLinkMic) {
-// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
-// params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
-// params.gravity = Gravity.TOP;
-// } else {
-// params.height = ViewGroup.LayoutParams.MATCH_PARENT;
-// params.topMargin = 0;
-// params.gravity = Gravity.CENTER;
-// }
-// mVideoView.setLayoutParams(params);
-// }
-// }, delayTime);
- }
-}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
deleted file mode 100644
index c38a2b902..000000000
--- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
+++ /dev/null
@@ -1,1108 +0,0 @@
-package com.yunbao.live.views;
-
-import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
-import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
-import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
-import static com.yunbao.live.activity.LiveActivity.mLiveRyLinkMicPkPresenter;
-import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_END;
-import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_ING;
-import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList;
-import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList1;
-import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.mPkUid;
-import static cn.rongcloud.rtc.base.RCRTCLiveRole.BROADCASTER;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.alibaba.fastjson.JSONObject;
-import com.tencent.liteav.device.TXDeviceManager;
-import com.tencent.rtmp.ITXLivePushListener;
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.trtc.TRTCCloudDef;
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.Constants;
-import com.yunbao.common.bean.HttpCallbackModel;
-import com.yunbao.common.bean.UserBean;
-import com.yunbao.common.event.AnchorInfoEvent;
-import com.yunbao.common.event.LivePushRyEvent;
-import com.yunbao.common.glide.ImgLoader;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.http.HttpClient;
-import com.yunbao.common.http.live.LiveNetManager;
-import com.yunbao.common.manager.IMLoginManager;
-import com.yunbao.common.manager.IMRTCManager;
-import com.yunbao.common.manager.RandomPkManager;
-import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
-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.ToastUtil;
-import com.yunbao.common.utils.WordUtil;
-import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
-import com.yunbao.live.event.LiveAudienceEvent;
-import com.yunbao.common.http.LiveHttpConsts;
-import com.yunbao.common.http.LiveHttpUtil;
-import com.yunbao.live.momo.TencentTRTCBeautyManager;
-import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
-import com.yunbao.live.socket.SocketRyClient;
-import com.yunbao.live.socket.SocketSendBean;
-
-import org.greenrobot.eventbus.EventBus;
-import org.greenrobot.eventbus.Subscribe;
-import org.greenrobot.eventbus.ThreadMode;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import cn.rongcloud.rtc.api.RCRTCConfig;
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.RCRTCMixConfig;
-import cn.rongcloud.rtc.api.RCRTCRemoteUser;
-import cn.rongcloud.rtc.api.RCRTCRoom;
-import cn.rongcloud.rtc.api.RCRTCRoomConfig;
-import cn.rongcloud.rtc.api.callback.IRCRTCEngineEventListener;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
-import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
-import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
-import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
-import cn.rongcloud.rtc.api.stream.RCRTCVideoView;
-import cn.rongcloud.rtc.base.RCRTCParamsType;
-import cn.rongcloud.rtc.base.RCRTCRoomType;
-import cn.rongcloud.rtc.base.RCRTCVideoEventCode;
-import cn.rongcloud.rtc.base.RTCErrorCode;
-import cn.rongcloud.rtc.core.CameraVideoCapturer;
-import cn.rongcloud.rtc.core.RendererCommon;
-import io.rong.imlib.IRongCallback;
-import io.rong.imlib.RongIMClient;
-import io.rong.imlib.model.Conversation;
-import io.rong.message.TextMessage;
-
-/**
- * Created by cxf on 2018/10/7.
- * 腾讯云直播推流
- */
-
-public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITXLivePushListener {
-
- private int mMeiBaiVal;//基础美颜 美白
- private int mMoPiVal;//基础美颜 磨皮
- private int mHongRunVal;//基础美颜 红润
- private String mBgmPath;//背景音乐路径
- private Bitmap mFilterBmp;
-
- private TXDeviceManager mTXDeviceManager;
- private TRTCCloudDef.TRTCParams mTRTCParams;
- private Handler mMainHandler;
- public TencentTRTCBeautyManager tencentTRTCBeautyManager;
- public static Context contexts;
- public static TextView btn_close;
- public LinearLayout dr_pk_view;
- public static RCRTCRoom rtcRoom;
- public static RCRTCLiveInfo rcrtcLiveInfo;
-
- private ViewGroup liveActivityContainer;
- public FrameLayout timeTitle;
- public TextView textTime;
- private TextView tv_avatarOther_name;
- private ImageView avatarOther;
- private LinearLayout goto_room_view;
- private boolean isPk = false;
- private boolean isNeedOpenCamera = false;
-
- //修改上面主播的头像
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onUPAnchorInfo(AnchorInfoEvent e) {
- Log.i(TAG, "onUPAnchorInfo: " + e);
- if (e != null) {
- if (!e.isClear()) {
- tv_avatarOther_name.setText(e.getUserNiceName());
- tv_avatarOther_name.setTag(e.getUserNiceName());
- ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther);
- goto_room_view.setVisibility(View.VISIBLE);
- } else {
- goto_room_view.setVisibility(View.GONE);
-
- }
- }
- }
-
-
- public LivePushRyViewHolder(Context context, ViewGroup parentView) {
- super(context, parentView);
- this.contexts = context;
- EventBus.getDefault().register(this);
- }
-
- @Override
- protected int getLayoutId() {
- return R.layout.view_live_push_ry;
- }
-
- public void setLiveActivityContainer(ViewGroup liveActivityContainer) {
- this.liveActivityContainer = liveActivityContainer;
- }
-
- /**
- * 主房间事件监听
- * 详细说明请参考文档:https://www.rongcloud.cn/docs/api/android/rtclib_v4/cn/rongcloud/rtc/api/callback/IRCRTCRoomEventsListener.html
- */
- public IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() {
- @Override
- public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, List list) {
- Log.e("ry", "远端来了" + list.size());
- //TODO 按需在此订阅远端用户发布的资源
- rtcRoom.getLocalUser().subscribeStreams(list, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "远端成功" + list.size());
-
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", "远端失败" + list.size() + "|errorCode:" + rtcErrorCode.toString());
- ToastUtil.show(mContext.getString(R.string.live_pk_link_error));
- }
- });
- }
-
- @Override
- public void onRemoteUserMuteAudio(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
- }
-
- @Override
- public void onRemoteUserMuteVideo(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
- }
-
- @Override
- public void onRemoteUserUnpublishResource(RCRTCRemoteUser rcrtcRemoteUser, List list) {
- }
-
- @Override
- public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) {
- }
-
- @Override
- public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
- }
-
- @Override
- public void onUserOffline(RCRTCRemoteUser rcrtcRemoteUser) {
- }
-
- @Override
- public void onPublishLiveStreams(List list) {
- }
-
- @Override
- public void onUnpublishLiveStreams(List list) {
- }
-
- @Override
- public void onLeaveRoom(int i) {
- }
-
- /**
- * 收到邀请者的跨房间连麦通知
- *
- * @param inviterRoomId 邀请者房间 Id
- * @param inviterUserId 邀请者用户 Id
- * @param extra 扩展字段,默认为空
- */
- @Override
- public void onRequestJoinOtherRoom(String inviterRoomId, String inviterUserId, String extra) {
- super.onRequestJoinOtherRoom(inviterRoomId, inviterUserId, extra);
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Log.e("ry", inviterRoomId + extra + "Request");
- UserBean userBean = new UserBean();
- userBean.setId(inviterRoomId);
- //收到邀请这个时候正在PK或连麦中 自动拒绝对方
- if (isPking() == true) {
-
- rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), false, false, "extra", new IRCRTCResultCallback() {
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
-
- @Override
- public void onSuccess() {
- final SocketSendBean msg1 = new SocketSendBean()
- .param("_method_", SOCKET_LINK_MIC_PK)
- .param("action", 8);
- msg1.create();
-
- String targetId = userBean.getId();
- Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
- TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
- io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
-
- RongcloudIMManager.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", "发送失敗" + userBean.getId());
- }
- });
- }
- });
-
- } else if (extra.equals(SOCKET_LIVE_DRPK)) {
- //收到多人PK申请
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
- } else {
- mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, LivePushRyViewHolder.this, true, liveActivityContainer);
- mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
- }
- } else if (extra.equals("LiveDRPK1")) {
- Log.e("ry", "LiveDRPK1");
- rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), true, true, "LiveDRPK1", new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- mLiveRyLinkMicPkPresenter.dRjoinOtherRoom(userBean.getId(), 2);
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
-
- }
- });
- } else {
- if (extra.contains("autoLivePK")) {
- UserBean userBean1 = new UserBean();
- if (!extra.equals("")) {
- JSONObject map = JSONObject.parseObject(extra);
- userBean1.setId(map.getString("uid"));
- userBean1.setUserNiceName(map.getString("pkname"));
- userBean1.setAvatar(map.getString("pkhead"));
- } else {
- userBean1.setId(inviterRoomId);
- userBean1.setUserNiceName("null");
- userBean1.setAvatar("null");
- }
- mLiveRyLinkMicPkPresenter.onLinkMicPkApply(userBean1, "", 1);
- } else {
- Log.e("ry", extra);
- /*
- * {
- * "pkhead": "https://downs.yaoulive.com/20220906170849_79c553dc1319fb5c215e06e01674eba4?imageView2/2/w/600/h/600",
- * "pkname": "用户_98274",
- * "pkuid": "98274",
- * "randomPk": true,
- * "uid": "98274"
- * }
- */
- UserBean userBean1 = new UserBean();
- if (!extra.equals("")) {
- JSONObject map = JSONObject.parseObject(extra);
- userBean1.setAvatar(map.getString("pkhead"));
- userBean1.setUserNiceName(map.getString("pkname"));
- userBean1.setRandomPk(map.containsKey("random_pk") && map.getString("random_pk").equals("1"));
- userBean1.setRankPkImgUrl(map.containsKey("is_ladders") ? map.getString("is_ladders") : null);
- userBean1.setId(map.getString("uid"));
- userBean1.setUserNiceName(map.getString("pkname"));
- userBean1.setAvatar(map.getString("pkhead"));
- } else {
- userBean1.setId(inviterRoomId);
- userBean1.setUserNiceName("null");
- userBean1.setAvatar("null");
- }
- //收到单人PK申请
- mLiveRyLinkMicPkPresenter.onLinkMicPkApply(userBean1, "", 0);
- }
- }
- }
- });
- }
-
- /**
- * 收到邀请者的取消跨房间连麦通知
- *
- * @param inviterRoomId 邀请者房间 Id
- * @param inviterUserId 邀请者用户 Id
- * @param extra 扩展字段,默认为空
- */
- @Override
- public void onCancelRequestOtherRoom(String inviterRoomId, String inviterUserId, String extra) {
- super.onCancelRequestOtherRoom(inviterRoomId, inviterUserId, extra);
- }
-
- /**
- * 收到被邀请者的跨房间连麦响应
- *
- * 1.如果被邀请者同意请求,邀请者房间和被邀请者房间中所有人会收到通知。
- *
- * 2.如果被邀请者拒绝请求,仅邀请者收到通知。
- *
- *
- * @param inviterRoomId 邀请者房间 Id
- * @param inviterUserId 邀请者用户 Id
- * @param inviteeRoomId 被邀请者房间 Id
- * @param inviteeUserId 被邀请者用户 Id
- * @param agree 被邀请者是否同意连麦请求
- * @param extra 扩展字段,默认为空
- */
- @Override
- public void onResponseJoinOtherRoom(String inviterRoomId, String inviterUserId, String inviteeRoomId, String inviteeUserId, boolean agree, String extra) {
- super.onResponseJoinOtherRoom(inviterRoomId, inviterUserId, inviteeRoomId, inviteeUserId, agree, extra);
- IMRTCManager.getInstance().callPkSuccess(inviterRoomId);
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Log.e("ry", inviterRoomId + extra + "Response" + agree);
- if (agree == false) {
-// ToastUtil.show(inviteeUserId+(agree?" 同意":" 拒绝")+"了你的邀请!");
- } else if (agree == true && extra.equals(SOCKET_LIVE_DRPK)) {
- mLiveRyLinkMicPkPresenter.onDRLinkMicToPk(inviteeRoomId);
- } else if (extra.equals("LiveDRPK1")) {
- mLiveRyLinkMicPkPresenter.dRjoinOtherRoom(inviteeRoomId, 3);
- } else {
- Log.e("ry", extra);
- UserBean userBean1 = new UserBean();
- if (!extra.equals("")) {
- JSONObject map = JSONObject.parseObject(extra);
- userBean1.setId(map.getString("uid"));
- userBean1.setUserNiceName(map.getString("pkname"));
- userBean1.setAvatar(map.getString("pkhead"));
- } else {
- userBean1.setId(inviterRoomId);
- userBean1.setUserNiceName("null");
- userBean1.setAvatar("null");
- }
- //单人PK,减掉次数
- if (!RandomPkManager.getInstance().isRandomModel()) {
- LiveNetManager.get(mContext).setFreePkNum(new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(HttpCallbackModel data) {
-
- }
-
- @Override
- public void onError(String error) {
- ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
- }
- });
-
- }
- mLiveRyLinkMicPkPresenter.onLinkMicToPk(userBean1);
- mLiveRyLinkMicPkPresenter.onLinkMicPkStart(inviteeRoomId, 3);
- EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UP_PK_TWO).setObject(userBean1.getId()));
- }
- }
- });
- }
-
- @Override
- public void onKickedByServer() {
- super.onKickedByServer();
- }
-
- /**
- * 收到结束跨房间连麦的通知,需要在此处调用 {@link RCRTCEngine#leaveOtherRoom(String, boolean, IRCRTCResultCallback)} 决定是否与对端结束连麦(停止合流)
- *
- * @param roomId 结束连麦的房间 Id
- * @param userId 发起结束连麦的用户 id
- */
- @Override
- public void onFinishOtherRoom(String roomId, String userId) {
- super.onFinishOtherRoom(roomId, userId);
- Log.e("ry", roomId + "房间是" + userId);
- RCRTCEngine.getInstance().leaveOtherRoom(roomId, true, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", roomId + "退出啊房间成功" + userId);
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", roomId + "退出啊房间失败" + userId);
-
- }
- });
-
-
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.leaveDRRoom();
- }
- }
-
- /**
- * 加入的副房间,连接断开。
- */
- @Override
- public void onOtherRoomConnectionError(String otherRoomId) {
- super.onOtherRoomConnectionError(otherRoomId);
- }
- };
-
-
- @Override
- public void init() {
- super.init();
- Bus.getOn(this);
- mPreView = (FrameLayout) findViewById(R.id.camera_preview);
- camera = (LinearLayout) findViewById(R.id.camera);
- mPreView1 = (FrameLayout) findViewById(R.id.camera_preview1);
- cameraPreview3 = (FrameLayout) findViewById(R.id.camera_preview3);
- 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);
- leave = (ImageView) findViewById(R.id.leave);
- dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
- timeTitle = (FrameLayout) findViewById(R.id.time_title);
- textTime = (TextView) findViewById(R.id.text_time);
- dr_pk_view.setVisibility(View.GONE);
- cameraPreview3.setVisibility(View.GONE);
- btn_close = (TextView) findViewById(R.id.btn_close);
- tv_avatarOther_name = (TextView) findViewById(R.id.tv_avatarOther_name);
- avatarOther = (ImageView) findViewById(R.id.avatarOther);
- goto_room_view = (LinearLayout) findViewById(R.id.goto_room_view);
- goto_room_view.setVisibility(View.GONE);
- mMainHandler = new Handler(Looper.getMainLooper());
- btn_close.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh() ? "是否要斷開連麥?" : "Do you want to disconnect Link?", new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- Log.i("PK----->", "updateSub: " + isPk + "|");
- aheadOfScheduleEndPK(mPkUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName(), (String) tv_avatarOther_name.getTag());
- //断开连麦
- LiveRyAnchorActivity.isDRPK = 0;
- HttpClient.getInstance().post("chaxunshoudongpkcishu", "chaxunshoudongpkcishu")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- }
- });
-
-
- HttpClient.getInstance().get("jieshupk", "jieshupk")
- .params("uid", CommonAppConfig.getInstance().getUid())
- .params("addtime", "1")
- .params("type", "1")
- .params("sign", "1")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0) {
- JSONObject datas = JSONObject.parseObject(info[0]);
- String pkUid = datas.getString("pkuid");
- //退出副房间
- RCRTCEngine.getInstance().leaveOtherRoom(pkUid, true, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "退出房间成功" + pkUid);
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
- mPreView1.removeAllViews();
- mPreView1.setVisibility(View.GONE);
- inputStreamList.clear();
- inputStreamList1.clear();
- changeToBig();
- //清理PK上面对方的头像
- EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
- closeButtonGone();
- }
- });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", pkUid + "退出房间s失败" + rtcErrorCode);
- }
- });
-
-
- SocketSendBean seed_msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_LINK_MIC_PK)
- .param("action", 9)
- .param("msgtype", 10)
- .param("win_uid", datas.getString("win_uid"))
- .param("uid", CommonAppConfig.getInstance().getUid());
- seed_msg.create();
- Log.i("seed", seed_msg.mResult.toString());
- HttpClient.getInstance().get("fasongxiaoxiv2", "fasongxiaoxiv2")
- .params("GroupId", "g" + pkUid)
- .params("jsonstr", seed_msg.mResult.toString())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
-
- HttpClient.getInstance().get("fasongxiaoxiv2", "fasongxiaoxiv2")
- .params("GroupId", "g" + CommonAppConfig.getInstance().getUid())
- .params("jsonstr", seed_msg.mResult.toString())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
-
- SocketSendBean seed_msgs = new SocketSendBean()
- .param("_method_", Constants.SOCKET_LINK_MIC_PK)
- .param("action", 5)
- .param("msgtype", 10)
- .param("uname", "1")
- .param("uimg", "1")
- .param("pkuid", LiveRyLinkMicPkPresenter.oldmPkUid)
- .param("uid", CommonAppConfig.getInstance().getUid());
- seed_msgs.create();
- Log.i("seed", seed_msgs.mResult.toString());
-
- HttpClient.getInstance().get("fasongxiaoxiv2", "fasongxiaoxiv2")
- .params("GroupId", "g" + LiveRyLinkMicPkPresenter.oldmPkUid)
- .params("jsonstr", seed_msgs.mResult.toString())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- HttpClient.getInstance().get("fasongxiaoxiv2", "fasongxiaoxiv2")
- .params("GroupId", "g" + CommonAppConfig.getInstance().getUid())
- .params("jsonstr", seed_msgs.mResult.toString())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
-
- }
- });
- }
- });
- }
- });
- }
- });
-
- }
-
- }
- });
-
-
- }
- });
- }
- });
-
- // 构建 RoomConfig,指定房间类型和主播身份:
- RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
- // 根据实际场景,选择音视频直播:LIVE_AUDIO_VIDEO 或音频直播:LIVE_AUDIO
- .setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO)
- .setLiveRole(BROADCASTER)
- .build();
-
-
- //调用 RCRTCEngine 下的 joinRoom 方法创建并加入一个直播房间:
- final CommonAppConfig appConfig = CommonAppConfig.getInstance();
-
- RCRTCEngine.getInstance().joinRoom(appConfig.getUid(), roomConfig, new IRCRTCResultDataCallback() {
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- ToastUtil.show("开播失败" + errorCode);
- }
-
- @Override
- public void onSuccess(final RCRTCRoom room) {
-
- // 保存房间对象
- rtcRoom = room;
- IMRTCManager.getInstance().setRtcRoom(room);
-
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- public void run() {
-
- RCRTCConfig config = RCRTCConfig.Builder.create()
- //是否硬解码
- .enableHardwareDecoder(true)
- //是否硬编码
- .enableHardwareEncoder(true)
- .build();
-
-
- RCRTCEngine.getInstance().init(contexts, config);
- RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM);
- //設置開播分辨率
- RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- int minRate = 200;
- int maxRate = 900;
- switch (IMLoginManager.get(mContext).getSelectClarity()) {
- case 0:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- minRate = 200;
- maxRate = 900;
- break;
- case 1:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
- minRate = 250;
- maxRate = 2200;
- break;
- case 2:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
- minRate = 400;
- maxRate = 4000;
- break;
- }
-
- RCRTCVideoStreamConfig videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create()
- //设置分辨率
- .setVideoResolution(rcrtcVideoResolution)
- //设置帧率
- .setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_24)
- //设置最小码率,480P下推荐200
- .setMinRate(minRate)
- //设置最大码率,480P下推荐900
- .setMaxRate(maxRate)
- .build();
-
- // 创建本地视频显示视图
- RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(videoConfigBuilder);
- RCRTCEngine.getInstance().getDefaultVideoStream().enableTinyStream(false);
- RCRTCVideoView rongRTCVideoView = new RCRTCVideoView(contexts);
- rongRTCVideoView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
- RCRTCEngine.getInstance().getDefaultVideoStream().setVideoView(rongRTCVideoView);
- RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(Boolean data) {
- //设置摄像头最大缩放比例
- boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
- // ToastUtil.show("设置比例="+zoom);
- Log.i("摄像头", "onSuccess: 打开摄像头");
- isNeedOpenCamera = false;
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.i("摄像头", "onFailed: 打开摄像头失败 " + errorCode);
- }
- });
- RCRTCEngine.getInstance().registerEventListener(new IRCRTCEngineEventListener() {
- @Override
- public void onKicked(String roomId, RCRTCParamsType.RCRTCKickedReason kickedReason) {
-
- }
-
- @Override
- public void onError(RTCErrorCode errorCode) {
- super.onError(errorCode);
- Log.i("摄像头", "onError: 错误码" + errorCode);
- }
-
- @Override
- public void onLocalVideoEventNotify(RCRTCVideoEventCode event) {
- super.onLocalVideoEventNotify(event);
- Log.i("摄像头", "onLocalVideoEventNotify: 本地视频事件" + event.code);
- if (event.code == 3) {
- isNeedOpenCamera = true;
- }
- }
- });
- //设置摄像头最大缩放比例
- // RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(RCRTCEngine.getInstance().getDefaultVideoStream().getCameraMaxZoomFactor());
- mPreView.addView(rongRTCVideoView);
- tencentTRTCBeautyManager = new TencentTRTCBeautyManager(mContext);
-
- //加入房间成功后可以通过 RCRTCLocalUser 对象发布本地默认音视频流,包括:麦克风采集的音频和摄像头采集的视频。
- RCRTCEngine.getInstance().getDefaultVideoStream().setEncoderMirror(true);
- if (rtcRoom == null || rtcRoom.getLocalUser() == null) {
- if (room == null || room.getLocalUser() == null) {
- ToastUtil.show("开播失败 请稍后再试,错误代码:room is null");
- ((LiveRyAnchorActivity) mContext).endLives();
- return;
- }
- rtcRoom = room;
- IMRTCManager.getInstance().setRtcRoom(room);
- }
- rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(RCRTCLiveInfo rcrtcLiveInfo1) {
- rcrtcLiveInfo = rcrtcLiveInfo1;
-
- room.registerRoomListener(roomEventsListener);
-
- //美颜
-// new Handler(Looper.getMainLooper()).post(new Runnable() {
-// public void run() {
-// //旧美颜不需要了
-//
-//
-// }
-// });
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", "rtcErrorCode" + rtcErrorCode);
- }
- });
- }
-
- });
-
-
- }
- });
- }
-
-
- @Override
- public void changeToLeft() {
- if (mPreView != null) {
- FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mPreView.getLayoutParams();
- params.width = mPreView.getWidth() / 2;
- params.height = DpUtil.dp2px(250);
- params.topMargin = DpUtil.dp2px(130);
- camera.setLayoutParams(params);
- }
- }
-
- @Override
- public void changeToBig() {
- if (camera != null) {
- LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) camera.getLayoutParams();
- params.width = ViewGroup.LayoutParams.MATCH_PARENT;
- params.height = ViewGroup.LayoutParams.MATCH_PARENT;
- params.topMargin = 0;
- camera.setLayoutParams(params);
- }
- if (mPreView1.getVisibility() == View.VISIBLE) {
- mPreView1.removeAllViews();
- mPreView1.setVisibility(View.GONE);
- inputStreamList.clear();
- inputStreamList1.clear();
- }
- }
-
- public void closeButtonGone() {
- btn_close.setVisibility(View.GONE);
- }
-
- @Override
- public void toggleCamera() {
- if (mCameraFront) {
- mCameraFront = false;
- } else {
- mCameraFront = true;
- }
- RCRTCEngine.getInstance().getDefaultVideoStream().switchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
- @Override
- public void onCameraSwitchDone(boolean isFrontCamera) {
-
- }
-
- @Override
- public void onCameraSwitchError(String errorDescription) {
-
- }
- });
- }
-
- /**
- * 打开关闭闪光灯
- */
- @Override
- public void toggleFlash() {
- if (mCameraFront) {
- ToastUtil.show(mContext.getString(R.string.live_open_flash));
- return;
- }
-
- }
-
- /**
- * 开始推流
- *
- * @param pushUrl 推流地址
- */
- @Override
- public void startPush(String pushUrl) {
- if (rcrtcLiveInfo != null) {
- rcrtcLiveInfo.addPublishStreamUrl(pushUrl, new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(String[] data) {
- //强制设置开播后cdn的尺寸竖屏,因为有时候PK异常退出,cdn没有还原竖屏。
- if (rtcRoom != null) {
- 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();
-
- //推荐宽、高、帧率参数值可以通过默认视频流的配置获取,也可以根据实际需求来自定义设置
- //如不设置宽高值则服务端将使用默认宽高 360 * 640
- //例:发布的视频分辨率为720 * 1280,如果不设置则观众端看到的视频分辨率为 360 * 640,
- //所以如果想让观众端看到的视频分辨率和发布视频分辨率一致,则应从发布的视频流中获取分辨率配置并设置到 mediaConfig 中
- //設置開播分辨率
- //設置開播分辨率
- RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- int minRate = 200;
- int maxRate = 900;
- switch (IMLoginManager.get(mContext).getSelectClarity()) {
- case 0:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
- break;
- case 1:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
- break;
- case 2:
- rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
- break;
- }
- int width = rcrtcVideoResolution.getWidth();
- int height = rcrtcVideoResolution.getHeight();
- normal.setWidth(width); //视频宽
- normal.setHeight(height); //视频高
- normal.setFps(15); //视频帧率
- videoConfig.setVideoLayout(normal);
- //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. 合流画布设置
- rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "混成功12");
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", "混失败" + errorCode);
-
- }
- });
- }
-
-
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- }
- });
- startCountDown();
- } else {
- ToastUtil.show("请稍后,准备中....");
- }
- }
-
- public boolean isPking() {
- if (btn_close != null) {
- return btn_close.getVisibility() == View.VISIBLE;
- }
- return false;
- }
-
- @Override
- public void onPause() {
- mPaused = true;
-
- }
-
- @Override
- public void onResume() {
- mPaused = false;
- Log.i("摄像头", "onResume: " + isNeedOpenCamera);
- if(isNeedOpenCamera){
- RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(Boolean data) {
- //设置摄像头最大缩放比例
- boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
- // ToastUtil.show("设置比例="+zoom);
- Log.i("摄像头", "onSuccess: 打开摄像头");
- isNeedOpenCamera = false;
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.i("摄像头", "onFailed: 打开摄像头失败 " + errorCode);
- }
- });
- }
- }
-
- @Override
- public void startBgm(String path) {
- mBgmPath = path;
-
-
- }
-
- @Override
- public void pauseBgm() {
-
- }
-
- @Override
- public void resumeBgm() {
-
- }
-
- @Override
- public void stopBgm() {
- mBgmPath = null;
- }
-
-
- @Override
- public void release() {
- super.release();
- Bus.getOff(this);
- LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
- rtcRoom = null;
- }
-
- @Override
- public void onPushEvent(int e, Bundle bundle) {
- if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
- ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
-
- } else if (e == TXLiveConstants.PUSH_ERR_OPEN_MIC_FAIL) {
- ToastUtil.show(mContext.getString(R.string.live_push_failed_2));
-
- } else if (e == TXLiveConstants.PUSH_ERR_NET_DISCONNECT || e == TXLiveConstants.PUSH_ERR_INVALID_ADDRESS) {
- L.e(TAG, "网络断开,推流失败------>");
-
- } else if (e == TXLiveConstants.PUSH_WARNING_HW_ACCELERATION_FAIL) {
- L.e(TAG, "不支持硬件加速------>");
-
- } else if (e == TXLiveConstants.PUSH_EVT_FIRST_FRAME_AVAILABLE) {//预览成功
- L.e(TAG, "mStearm--->初始化完毕");
- if (mLivePushListener != null) {
- mLivePushListener.onPreviewStart();
- }
- } else if (e == TXLiveConstants.PUSH_EVT_PUSH_BEGIN) {//推流成功
- L.e(TAG, "mStearm--->推流成功");
- if (!mStartPush) {
- mStartPush = true;
- if (mLivePushListener != null) {
- mLivePushListener.onPushStart();
- }
- }
- }
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
-
- }
-
- private void aheadOfScheduleEndPK(String pkUid, String uname, String pkname) {
- if (!isPk) {
- return;
- }
- String ct = "由於 " + uname + " 退出比賽," + pkname + " 獲得勝利";
-
- SocketSendBean seed_msg = new SocketSendBean()
- .param("_method_", Constants.SOCKET_SYSTEM)
- .param("action", 1)
- .param("ct", ct);
- seed_msg.create();
-
-
- HttpClient.getInstance().get("fasongxiaoxiv2", "fasongxiaoxiv2")
- .params("GroupId", "g" + pkUid)
- .params("jsonstr", seed_msg.mResult.toString())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- HttpClient.getInstance().post("fasongxiaoxiv2", "fasongxiaoxiv2")
- .params("GroupId", "g" + CommonAppConfig.getInstance().getUid())
- .params("jsonstr", seed_msg.mResult.toString())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
-
- }
- });
- }
- });
- }
-
- private Bitmap decodeResource(Resources resources, int id) {
- TypedValue value = new TypedValue();
- resources.openRawResource(id, value);
- BitmapFactory.Options opts = new BitmapFactory.Options();
- opts.inTargetDensity = value.density;
- return BitmapFactory.decodeResource(resources, id, opts);
- }
-
- public static String getLiveStream() {
- return ((LiveActivity) contexts).getStream();
- }
-
- private String getTxAppId() {
- return ((LiveActivity) mContext).getTxAppId();
- }
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void setSelectClarity(LivePushRyEvent event) {
- if (rtcRoom != null)
- rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(RCRTCLiveInfo rcrtcLiveInfo1) {
- rcrtcLiveInfo = rcrtcLiveInfo1;
- }
-
- @Override
- public void onFailed(RTCErrorCode rtcErrorCode) {
- Log.e("ry", "rtcErrorCode" + rtcErrorCode);
- }
- });
- }
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void updateSub(LiveAudienceEvent event) {
- if (event.getType() == LIVE_PK_END) {
- isPk = false;
- } else if (event.getType() == LIVE_PK_ING) {
- isPk = true;
- }
- Log.i("PK----->", "updateSub: " + isPk + "|" + event.getType());
- }
-}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java
index 350a6cd40..79724f229 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java
@@ -3,8 +3,6 @@ package com.yunbao.live.views;
import static com.yunbao.live.activity.LiveActivity.mLiveSwLinkMicPkPresenter;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_END;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_ING;
-import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.inputStreamList;
-import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.inputStreamList1;
import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.mPkUid;
import android.app.Activity;
@@ -27,8 +25,6 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
-import com.tencent.rtmp.ITXLivePushListener;
-import com.tencent.rtmp.TXLiveConstants;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@@ -62,14 +58,6 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.RCRTCMixConfig;
-import cn.rongcloud.rtc.api.RCRTCRoom;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
-import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
-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.imlib.IRongCallback;
@@ -83,7 +71,7 @@ import io.rong.message.TextMessage;
* 腾讯云直播推流
*/
-public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITXLivePushListener {
+public class LivePushSwViewHolder extends AbsRyLivePushViewHolder {
private int mMeiBaiVal;//基础美颜 美白
private int mMoPiVal;//基础美颜 磨皮
private int mHongRunVal;//基础美颜 红润
@@ -93,8 +81,8 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
public static Context contexts;
public static TextView btn_close;
public LinearLayout dr_pk_view;
- public static RCRTCRoom rtcRoom;
- public static RCRTCLiveInfo rcrtcLiveInfo;
+// public static RCRTCRoom rtcRoom;
+// public static RCRTCLiveInfo rcrtcLiveInfo;
private ViewGroup liveActivityContainer;
public FrameLayout timeTitle;
public TextView textTime;
@@ -370,7 +358,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
}
switch (temp) {
case 2:
- swManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid),temp);
+ swManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid), temp);
swManager.updateMyChannelView(dr1_preview);
mBigContainer.removeAllViews();
@@ -379,7 +367,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
break;
case 3:
drpkUid3 = uid;
- swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid),temp);
+ swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid), temp);
dr3_preview.setVisibility(View.GONE);
dr4_preview.setVisibility(View.VISIBLE);
break;
@@ -387,9 +375,9 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
dr3_preview.setVisibility(View.VISIBLE);
//先退出这个主播的直播间,在进入该直播间,(视图问题暂时這樣處理)
swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drpkUid3);
- swManager.joinChannelDrEx(dr3_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3),temp);
+ swManager.joinChannelDrEx(dr3_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3), temp);
- swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid),temp);
+ swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid), temp);
break;
}
dr_pk_view.setVisibility(View.VISIBLE);
@@ -399,7 +387,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
}
public void anchorClose() {
- swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),pkUid1);
+ swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), pkUid1);
swManager.updateMyChannelView((FrameLayout) mBigContainer); //用户主动断开连麦再退出画面
mPkContainer.setVisibility(View.GONE);
pkUid1 = null;
@@ -441,8 +429,8 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
if (mPreView1.getVisibility() == View.VISIBLE) {
mPreView1.removeAllViews();
mPreView1.setVisibility(View.GONE);
- inputStreamList.clear();
- inputStreamList1.clear();
+// inputStreamList.clear();
+// inputStreamList1.clear();
}
}
@@ -504,23 +492,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
public void onResume() {
mPaused = false;
Log.i("摄像头", "onResume: " + isNeedOpenCamera);
- if (isNeedOpenCamera) {
- RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback() {
- @Override
- public void onSuccess(Boolean data) {
- //设置摄像头最大缩放比例
- boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
- // ToastUtil.show("设置比例="+zoom);
- Log.i("摄像头", "onSuccess: 打开摄像头");
- isNeedOpenCamera = false;
- }
-
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.i("摄像头", "onFailed: 打开摄像头失败 " + errorCode);
- }
- });
- }
+ swManager.resetCamera();
}
@Override
@@ -550,12 +522,14 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
super.release();
Bus.getOff(this);
onDestroy();
+ SWManager.get().release();
LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
- rtcRoom = null;
+// rtcRoom = null;
}
+ /*
@Override
- public void onPushEvent(int e, Bundle bundle) {
+ public void onPushEvent(int e, Bundle bundle) {
if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
@@ -587,7 +561,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void onNetStatus(Bundle bundle) {
- }
+ }*/
private void aheadOfScheduleEndPK(String pkUid, String uname, String pkname) {
if (!isPk) {
@@ -629,7 +603,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
@Subscribe(threadMode = ThreadMode.MAIN)
public void setSelectClarity(LivePushRyEvent event) {
- if (rtcRoom != null)
+ /* if (rtcRoom != null)
rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback() {
@Override
public void onSuccess(RCRTCLiveInfo rcrtcLiveInfo1) {
@@ -640,7 +614,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", "rtcErrorCode" + rtcErrorCode);
}
- });
+ });*/
}
public void setEnableBeauty(boolean flag) {
@@ -667,17 +641,20 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
}
}
- public void closeLive(){
+ public void closeLive() {
if (swManager != null) {
swManager.exitChannelAll();
}
}
- public interface onDrPkJoinSuccessListener{
+ public interface onDrPkJoinSuccessListener {
void joinSuccess1();
+
void joinSuccess2();
+
void joinSuccess3();
+
void joinSuccess4();
}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java
index e0d3496a2..58fdc1957 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder.java
@@ -20,13 +20,7 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.tencent.liteav.device.TXDeviceManager;
-import com.tencent.rtmp.ITXLivePushListener;
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.tencent.trtc.TRTCCloud;
-import com.tencent.trtc.TRTCCloudDef;
-import com.tencent.trtc.TRTCCloudListener;
+import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
@@ -49,16 +43,13 @@ import com.yunbao.live.socket.SocketSendBean;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
-import static com.tencent.trtc.TRTCCloudDef.TRTC_APP_SCENE_LIVE;
-import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
-import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG;
/**
* Created by cxf on 2018/10/7.
* 腾讯云直播推流
*/
-public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLivePushListener {
+public class LivePushTxViewHolder extends AbsLivePushViewHolder {
private int mMeiBaiVal;//基础美颜 美白
private int mMoPiVal;//基础美颜 磨皮
@@ -66,9 +57,9 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
private String mBgmPath;//背景音乐路径
private Bitmap mFilterBmp;
- public static TRTCCloud mTRTCCloud;
- private TXDeviceManager mTXDeviceManager;
- private TRTCCloudDef.TRTCParams mTRTCParams;
+// public static TRTCCloud mTRTCCloud;
+// private TXDeviceManager mTXDeviceManager;
+// private TRTCCloudDef.TRTCParams mTRTCParams;
private Handler mMainHandler;
public TencentTRTCBeautyManager tencentTRTCBeautyManager;
public static Context contexts;
@@ -89,19 +80,19 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
@Override
public void init() {
super.init();
- mPreView = (TXCloudVideoView) findViewById(R.id.camera_preview);
- mPreView1 = (TXCloudVideoView) findViewById(R.id.camera_preview1);
- dr1_preview = (TXCloudVideoView) findViewById(R.id.dr1_preview);
- dr2_preview = (TXCloudVideoView) findViewById(R.id.dr2_preview);
- dr3_preview = (TXCloudVideoView) findViewById(R.id.dr3_preview);
- dr4_preview = (TXCloudVideoView) findViewById(R.id.dr4_preview);
+ mPreView = (StyledPlayerView) findViewById(R.id.camera_preview);
+ mPreView1 = (StyledPlayerView) findViewById(R.id.camera_preview1);
+ dr1_preview = (StyledPlayerView) findViewById(R.id.dr1_preview);
+ dr2_preview = (StyledPlayerView) findViewById(R.id.dr2_preview);
+ dr3_preview = (StyledPlayerView) findViewById(R.id.dr3_preview);
+ dr4_preview = (StyledPlayerView) findViewById(R.id.dr4_preview);
leave = (ImageView) findViewById(R.id.leave);
dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
dr_pk_view.setVisibility(View.GONE);
btn_close = (TextView) findViewById(R.id.btn_close);
- mTRTCCloud = TRTCCloud.sharedInstance(mContext);
+// mTRTCCloud = TRTCCloud.sharedInstance(mContext);
mMainHandler = new Handler(Looper.getMainLooper());
- btn_close.setOnClickListener(new View.OnClickListener() {
+ /* btn_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh()?"是否要斷開連麥?":"Do you want to disconnect Link?", new DialogUitl.SimpleCallback() {
@@ -227,7 +218,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
tencentTRTCBeautyManager.textureDestoryed();
}
});
- enterRoom();
+ enterRoom();*/
}
@@ -260,7 +251,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
} else {
mCameraFront = true;
}
- mTXDeviceManager.switchCamera(mCameraFront);
+// mTXDeviceManager.switchCamera(mCameraFront);
}
/**
@@ -288,13 +279,13 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
@Override
public void startPush(String pushUrl) {
- mTRTCCloud.enterRoom(mTRTCParams, TRTC_APP_SCENE_LIVE);
- mTRTCCloud.startPublishing(getLiveStream(), TRTC_VIDEO_STREAM_TYPE_BIG);
+// mTRTCCloud.enterRoom(mTRTCParams, TRTC_APP_SCENE_LIVE);
+// mTRTCCloud.startPublishing(getLiveStream(), TRTC_VIDEO_STREAM_TYPE_BIG);
startCountDown();
}
- protected class TRTCCloudImplListener extends TRTCCloudListener {
+ /* protected class TRTCCloudImplListener extends TRTCCloudListener {
private WeakReference mContext;
@@ -426,7 +417,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
// Bitmap bitmap = decodeResource(mContext.getResources(), R.mipmap.bg_live_tx_pause);
mTRTCCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_DEFAULT);
- }
+ }*/
@Override
public void onPause() {
@@ -480,10 +471,10 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
public void release() {
super.release();
LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
- mTRTCCloud = null;
+// mTRTCCloud = null;
}
- @Override
+ /* @Override
public void onPushEvent(int e, Bundle bundle) {
if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
@@ -519,7 +510,7 @@ public class LivePushTxViewHolder extends AbsLivePushViewHolder implements ITXLi
@Override
public void onNetStatus(Bundle bundle) {
- }
+ }*/
private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue();
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java
index c08d50405..3134ca659 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePushTxViewHolder360Beauty.java
@@ -19,11 +19,6 @@ import android.widget.FrameLayout;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.tencent.rtmp.ITXLivePushListener;
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.TXLivePushConfig;
-import com.tencent.rtmp.TXLivePusher;
-import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.utils.DownloadUtil;
@@ -47,11 +42,11 @@ import cn.qqtheme.framework.util.ScreenUtils;
* 腾讯云直播推流
*/
-public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder implements ITXLivePushListener, SurfaceHolder.Callback,
+public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder implements SurfaceHolder.Callback,
SurfaceTexture.OnFrameAvailableListener, Camera.PreviewCallback {
- private TXLivePusher mLivePusher;
- private TXLivePushConfig mLivePushConfig;
+// private TXLivePusher mLivePusher;
+// private TXLivePushConfig mLivePushConfig;
private int mMeiBaiVal;//基础美颜 美白
private int mMoPiVal;//基础美颜 磨皮
private int mHongRunVal;//基础美颜 红润
@@ -87,7 +82,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
super.init();
String mBeauty360TieZhiUrl= CommonAppConfig.getInstance().getBeauty360TieZhiUrl();
- mLivePusher = new TXLivePusher(mContext);
+ /* mLivePusher = new TXLivePusher(mContext);
mLivePushConfig = new TXLivePushConfig();
mLivePushConfig.setVideoFPS(15);//视频帧率
mLivePushConfig.setVideoEncodeGop(1);//GOP大小
@@ -108,7 +103,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
mLivePusher.setMicVolume(4f);
mLivePusher.setConfig(mLivePushConfig);
- mLivePusher.setPushListener(this);
+ mLivePusher.setPushListener(this);*/
initBeauty360();
@@ -141,7 +136,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
String mBeautySdkType= CommonAppConfig.getInstance().getBeautySdkType();
Log.d("mBeautySdkType",mBeautySdkType);
if ("2".equals(mBeautySdkType)) {
- mLivePusher.setVideoProcessListener(new TXLivePusher.VideoCustomProcessListener() {
+ /* mLivePusher.setVideoProcessListener(new TXLivePusher.VideoCustomProcessListener() {
@Override
public int onTextureCustomProcess(int i, int i1, int i2) {
@@ -154,7 +149,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
public void onTextureDestoryed() {
}
});
- mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);
+ mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);*/
} else if ("3".equals(mBeautySdkType)){
//遍历解压缩后的文件夹,获取所有贴纸列表
@@ -174,7 +169,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
download360TieZhi(mBeauty360TieZhiUrl,CommonAppConfig.TIEZHI_360_NAME+".zip");
}
}else {
- mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);
+// mLivePusher.startCameraPreview((TXCloudVideoView) mPreView);
}
}
@@ -296,7 +291,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
*/
@Override
public void toggleCamera() {
- if (mLivePusher != null) {
+ /* if (mLivePusher != null) {
if (mFlashOpen) {
toggleFlash();
}
@@ -304,7 +299,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
// mPreviewUtils.switchCamera();
mCameraFront = !mCameraFront;
mLivePusher.setMirror(mCameraFront);
- }
+ }*/
}
@@ -317,14 +312,14 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
ToastUtil.show(mContext.getString(R.string.live_open_flash));
return;
}
- if (mLivePusher != null) {
+ /* if (mLivePusher != null) {
boolean open = !mFlashOpen;
// if (mLivePusher.turnOnFlashLight(open)) {
// mFlashOpen = open;
// }
// mPreviewUtils.switchCameraFlashLight();
mFlashOpen = open;
- }
+ }*/
}
/**
@@ -334,10 +329,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
*/
@Override
public void startPush(String pushUrl) {
- if (mLivePusher != null) {
+ /*if (mLivePusher != null) {
//启动 RTMP 推流 0-启动成功,1-启动失败
mLivePusher.startPusher(pushUrl);
- }
+ }*/
startCountDown();
}
@@ -345,10 +340,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
@Override
public void onPause() {
mPaused = true;
- if (mStartPush && mLivePusher != null) {
+ /* if (mStartPush && mLivePusher != null) {
mLivePusher.pauseBGM();
mLivePusher.pausePusher();
- }
+ }*/
// mPreviewUtils.pause();
@@ -363,10 +358,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
@Override
public void onResume() {
- if (mPaused && mStartPush && mLivePusher != null) {
+ /* if (mPaused && mStartPush && mLivePusher != null) {
mLivePusher.resumePusher();
mLivePusher.resumeBGM();
- }
+ }*/
mPaused = false;
//camera
@@ -405,33 +400,33 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
}
@Override
public void startBgm(String path) {
- if (mLivePusher != null) {
+ /*if (mLivePusher != null) {
boolean result = mLivePusher.playBGM(path);
if (result) {
mBgmPath = path;
}
- }
+ }*/
}
@Override
public void pauseBgm() {
- if (mLivePusher != null) {
+ /*if (mLivePusher != null) {
mLivePusher.pauseBGM();
- }
+ }*/
}
@Override
public void resumeBgm() {
- if (mLivePusher != null) {
+ /* if (mLivePusher != null) {
mLivePusher.resumeBGM();
- }
+ }*/
}
@Override
public void stopBgm() {
- if (mLivePusher != null) {
+ /*if (mLivePusher != null) {
mLivePusher.stopBGM();
- }
+ }*/
mBgmPath = null;
}
@@ -446,7 +441,7 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
public void release() {
super.release();
LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
- if (mLivePusher != null) {
+ /* if (mLivePusher != null) {
mLivePusher.stopBGM();
mLivePusher.stopPusher();
// mLivePusher.stopScreenCapture();
@@ -459,52 +454,12 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
if (mLivePushConfig != null) {
mLivePushConfig.setPauseImg(null);
}
- mLivePushConfig = null;
+ mLivePushConfig = null;*/
// mPreviewUtils.freeRes();
}
- @Override
- public void onPushEvent(int e, Bundle bundle) {
-// String msg = bundle.getString(TXLiveConstants.EVT_DESCRIPTION);
-
- Log.d("onPushEvent",""+e+" "+bundle.toString());
- if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
- ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
-
- } else if (e == TXLiveConstants.PUSH_ERR_OPEN_MIC_FAIL) {
- ToastUtil.show(mContext.getString(R.string.live_push_failed_2));
-
- } else if (e == TXLiveConstants.PUSH_ERR_NET_DISCONNECT || e == TXLiveConstants.PUSH_ERR_INVALID_ADDRESS) {
- L.e(TAG, "网络断开,推流失败------>");
-
- } else if (e == TXLiveConstants.PUSH_WARNING_HW_ACCELERATION_FAIL) {
- L.e(TAG, "不支持硬件加速------>");
- if (mLivePushConfig != null && mLivePusher != null) {
- mLivePushConfig.setHardwareAcceleration(TXLiveConstants.ENCODE_VIDEO_SOFTWARE);
- mLivePusher.setConfig(mLivePushConfig);
- }
- } else if (e == TXLiveConstants.PUSH_EVT_FIRST_FRAME_AVAILABLE) {//预览成功
- L.e(TAG, "mStearm--->初始化完毕");
- if (mLivePushListener != null) {
- mLivePushListener.onPreviewStart();
- }
- } else if (e == TXLiveConstants.PUSH_EVT_PUSH_BEGIN) {//推流成功
- L.e(TAG, "mStearm--->推流成功");
- if (!mStartPush) {
- mStartPush = true;
- if (mLivePushListener != null) {
- mLivePushListener.onPushStart();
- }
- }
- }
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
-
- }
private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue();
@@ -684,10 +639,10 @@ public class LivePushTxViewHolder360Beauty extends AbsLivePushViewHolder impleme
if (mLivePushListener != null) {
mLivePushListener.onPreviewStart();
}
- if (mLivePusher != null)
+ /*if (mLivePusher != null)
{
// int ret=mLivePusher.sendCustomVideoData(mPreviewUtils.getSkinSoftenByte(), TXLivePusher.RGB_RGBA, mPreviewUtils.getCameraHeight(), mPreviewUtils.getCameraWidth());
- }
+ }*/
}
@Override
diff --git a/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java
deleted file mode 100644
index 6e26b6276..000000000
--- a/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java
+++ /dev/null
@@ -1,528 +0,0 @@
-package com.yunbao.live.views;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import androidx.core.content.ContextCompat;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import android.text.TextUtils;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.Constants;
-import com.yunbao.common.bean.UserBean;
-import com.yunbao.common.glide.ImgLoader;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.interfaces.ActivityResultCallback;
-import com.yunbao.common.interfaces.CommonCallback;
-import com.yunbao.common.interfaces.ImageResultCallback;
-import com.yunbao.common.utils.DialogUitl;
-import com.yunbao.common.utils.L;
-import com.yunbao.common.utils.ProcessImageUtil;
-import com.yunbao.common.utils.StringUtil;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.common.utils.WordUtil;
-import com.yunbao.common.views.AbsViewHolder;
-import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveActivity;
-import com.yunbao.live.activity.LiveChooseClassActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
-import com.yunbao.live.adapter.LiveReadyShareAdapter;
-import com.yunbao.common.bean.LiveRoomTypeBean;
-import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
-import com.yunbao.live.dialog.LiveTimeDialogFragment;
-import com.yunbao.live.dialog.LiveWishListDialogFragment;
-import com.yunbao.common.http.LiveHttpConsts;
-import com.yunbao.common.http.LiveHttpUtil;
-
-import java.io.File;
-
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream;
-
-public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener {
-
- private ImageView mAvatar;
- private TextView mCoverText;
- private EditText mEditTitle;
- private RecyclerView mLiveShareRecyclerView;
- private LiveReadyShareAdapter mLiveShareAdapter;
- private ProcessImageUtil mImageUtil;
- private File mAvatarFile;
- private TextView mCity;
- private ImageView mLocationImg;
- private TextView mLiveClass;
- private TextView mLiveTypeTextView;//房间类型TextView
- private TextView mLiveWishListTextView;//心愿单TextView
- private int mLiveClassID;//直播频道id
- private int mLiveType;//房间类型
- private int mLiveTypeVal;//房间密码,门票收费金额
- private int mLiveTimeCoin;//计时收费金额
- private ActivityResultCallback mActivityResultCallback;
- private CommonCallback mLiveTypeCallback;
- private boolean mOpenLocation = true;
- private int mLiveSdk;
-
- public LiveReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) {
- super(context, parentView, liveSdk);
- }
-
- @Override
- protected void processArguments(Object... args) {
- if (args.length > 0) {
- mLiveSdk = (int) args[0];
- }
- }
-
- @Override
- protected int getLayoutId() {
- return R.layout.view_live_ready;
- }
-
- @Override
- public void init() {
- RelativeLayout traceroute_rootview = (RelativeLayout)findViewById(R.id.traceroute_rootview);
- traceroute_rootview.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- InputMethodManager imm = (InputMethodManager)
- mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
- }
- });
- mAvatar = (ImageView) findViewById(R.id.avatar);
- UserBean u = CommonAppConfig.getInstance().getUserBean();
- ImgLoader.displayAvatar(mContext, u.getAvatar(), mAvatar);
- mCoverText = (TextView) findViewById(R.id.cover_text);
- mEditTitle = (EditText) findViewById(R.id.edit_title);
- mCity = (TextView) findViewById(R.id.city);
- mCity.setText(CommonAppConfig.getInstance().getCity());
- mLocationImg = (ImageView) findViewById(R.id.location_img);
- findViewById(R.id.btn_locaiton).setOnClickListener(this);
- findViewById(R.id.btn_live_class).setOnClickListener(this);
- mOpenLocation = true;
- mLiveClass = (TextView) findViewById(R.id.live_class);
- mLiveTypeTextView = (TextView) findViewById(R.id.btn_room_type);
- findViewById(R.id.btn_horizontally).setOnClickListener(this);
- mLiveWishListTextView= (TextView) findViewById(R.id.btn_wishlist);
- mLiveShareRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
- mLiveShareRecyclerView.setHasFixedSize(true);
- mLiveShareRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
- mLiveShareAdapter = new LiveReadyShareAdapter(mContext);
- mLiveShareRecyclerView.setAdapter(mLiveShareAdapter);
- mImageUtil = ((LiveActivity) mContext).getProcessImageUtil();
- mImageUtil.setImageResultCallback(new ImageResultCallback() {
-
- @Override
- public void beforeCamera() {
- ((LiveRyAnchorActivity) mContext).beforeCamera();
- }
-
- @Override
- public void onSuccess(File file) {
- if (file != null) {
- ImgLoader.display(mContext, file, mAvatar);
- if (mAvatarFile == null) {
- mCoverText.setText(mContext.getString(R.string.live_cover_2));
- mCoverText.setBackground(ContextCompat.getDrawable(mContext, R.drawable.bg_live_cover));
- }
- mAvatarFile = file;
- }
- }
-
- @Override
- public void onFailure() {
- }
- });
- findViewById(R.id.avatar_group).setOnClickListener(this);
- findViewById(R.id.btn_camera).setOnClickListener(this);
- findViewById(R.id.btn_close).setOnClickListener(this);
- findViewById(R.id.btn_beauty).setOnClickListener(this);
- findViewById(R.id.btn_start_live).setOnClickListener(this);
- mLiveTypeTextView.setOnClickListener(this);
- mLiveWishListTextView.setOnClickListener(this);
- mActivityResultCallback = new ActivityResultCallback() {
- @Override
- public void onSuccess(Intent intent) {
- mLiveClassID = intent.getIntExtra(Constants.CLASS_ID, 0);
- mLiveClass.setText(intent.getStringExtra(Constants.CLASS_NAME));
- }
- };
- mLiveTypeCallback = new CommonCallback() {
- @Override
- public void callback(LiveRoomTypeBean bean) {
- switch (bean.getId()) {
- case Constants.LIVE_TYPE_NORMAL:
- onLiveTypeNormal(bean);
- break;
- case Constants.LIVE_TYPE_PWD:
- onLiveTypePwd(bean);
- break;
- case Constants.LIVE_TYPE_PAY:
- onLiveTypePay(bean);
- break;
- case Constants.LIVE_TYPE_TIME:
- onLiveTypeTime(bean);
- break;
- }
- }
- };
-
- }
-
- @Override
- public void onClick(View v) {
- if (!canClick()) {
- return;
- }
- int i = v.getId();
- if (i == R.id.avatar_group) {
- setAvatar();
-
- } else if (i == R.id.btn_camera) {
- toggleCamera();
- } else if (i == R.id.btn_close) {
- close();
- } else if (i == R.id.btn_live_class) {
- chooseLiveClass();
- } else if (i == R.id.btn_beauty) {
- beauty();
- }else if (i == R.id.btn_wishlist) {
- //点击心愿单
- openWishListWindow();
- } else if (i == R.id.btn_room_type) {
- chooseLiveType();
- } else if (i == R.id.btn_start_live) {
- startLive();
-
- } else if (i == R.id.btn_locaiton) {
- switchLocation();
- }else if(i == R.id.btn_horizontally){
- RCRTCCameraOutputStream cameraStream = RCRTCEngine.getInstance().getDefaultVideoStream();
- cameraStream.setPreviewMirror(!cameraStream.isPreviewMirror());
- }
- }
-
-
- /**
- * 打开心愿单窗口
- */
- public void openWishListWindow() {
- LiveWishListDialogFragment fragment = new LiveWishListDialogFragment();
-
- if (mContext instanceof LiveRyAnchorActivity){
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
- }
- }
-
- /**
- * 打开 关闭位置
- */
- private void switchLocation() {
- if (mOpenLocation) {
- new DialogUitl.Builder(mContext)
- .setContent(mContext.getString(R.string.live_location_close_3))
- .setCancelable(true)
- .setConfirmString(mContext.getString(R.string.live_location_close_2))
- .setClickCallback(new DialogUitl.SimpleCallback() {
-
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- toggleLocation();
- }
- })
- .build()
- .show();
- } else {
- toggleLocation();
- }
- }
-
- private void toggleLocation() {
- mOpenLocation = !mOpenLocation;
- if (mLocationImg != null) {
- mLocationImg.setImageResource(mOpenLocation ? R.mipmap.address_choice : R.mipmap.icon_live_ready_location_0);
- }
- if (mCity != null) {
- mCity.setText(mOpenLocation ? CommonAppConfig.getInstance().getCity() :mContext.getString(R.string.live_location_close));
- }
- }
-
- /**
- * 设置头像
- */
- private void setAvatar() {
- if (mLiveSdk == Constants.LIVE_SDK_TX) {
- mImageUtil.getImageByAlbum();
- } else {
- DialogUitl.showStringArrayDialog(mContext, new Integer[]{
- R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
- @Override
- public void onItemClick(String text, int tag) {
- if (tag == R.string.camera) {
- mImageUtil.getImageByCamera();
- } else {
- mImageUtil.getImageByAlbum();
- }
- }
- });
- }
- }
-
- /**
- * 切换镜头
- */
- private void toggleCamera() {
- ((LiveRyAnchorActivity) mContext).toggleCamera();
- }
-
- /**
- * 关闭
- */
- private void close() {
- ((LiveRyAnchorActivity) mContext).endLives();
- }
-
- /**
- * 选择直播频道
- */
- private void chooseLiveClass() {
- try {
- Intent intent = new Intent(mContext, LiveChooseClassActivity.class);
- intent.putExtra(Constants.CLASS_ID, mLiveClassID);
- mImageUtil.startActivityForResult(intent, mActivityResultCallback);
- }catch (Exception e){
-
- }
-
- }
-
- /**
- * 设置美颜
- */
- private void beauty() {
- ((LiveRyAnchorActivity) mContext).beauty();
-// Intent intent = new Intent(mContext, Beauty360Activity3.class);
-// mContext.startActivity(intent);
-
- }
-
- /**
- * 选择直播类型
- */
- private void chooseLiveType() {
- Bundle bundle = new Bundle();
- bundle.putInt(Constants.CHECKED_ID, mLiveType);
- LiveRoomTypeDialogFragment fragment = new LiveRoomTypeDialogFragment();
- fragment.setArguments(bundle);
- fragment.setCallback(mLiveTypeCallback);
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
- }
-
- /**
- * 普通房间
- */
- private void onLiveTypeNormal(LiveRoomTypeBean bean) {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(bean.getName());
- mLiveTypeVal = 0;
- mLiveTimeCoin = 0;
- }
-
- /**
- * 密码房间
- */
- private void onLiveTypePwd(final LiveRoomTypeBean bean) {
- DialogUitl.showSimpleInputDialog(mContext,mContext.getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- if (TextUtils.isEmpty(content)) {
- ToastUtil.show(mContext.getString(R.string.live_set_pwd_empty));
- } else {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(bean.getName());
- if (StringUtil.isInt(content)) {
- mLiveTypeVal = Integer.parseInt(content);
- }
- mLiveTimeCoin = 0;
- dialog.dismiss();
- }
- }
- });
- }
-
- /**
- * 付费房间
- */
- private void onLiveTypePay(final LiveRoomTypeBean bean) {
- DialogUitl.showSimpleInputDialog(mContext,mContext.getString(R.string.live_set_fee), DialogUitl.INPUT_TYPE_NUMBER, 8, new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- if (TextUtils.isEmpty(content)) {
- ToastUtil.show(mContext.getString(R.string.live_set_fee_empty));
- } else {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(bean.getName());
- if (StringUtil.isInt(content)) {
- mLiveTypeVal = Integer.parseInt(content);
- }
- mLiveTimeCoin = 0;
- dialog.dismiss();
- }
- }
- });
- }
-
- /**
- * 计时房间
- */
- private void onLiveTypeTime(final LiveRoomTypeBean bean) {
- LiveTimeDialogFragment fragment = new LiveTimeDialogFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(Constants.CHECKED_COIN, mLiveTimeCoin);
- fragment.setArguments(bundle);
- fragment.setCommonCallback(new CommonCallback() {
- @Override
- public void callback(Integer coin) {
- mLiveType = bean.getId();
- mLiveTypeTextView.setText(bean.getName());
- mLiveTypeVal = coin;
- mLiveTimeCoin = coin;
- }
- });
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
- }
-
- public void hide() {
- if (mContentView != null && mContentView.getVisibility() == View.VISIBLE) {
- mContentView.setVisibility(View.INVISIBLE);
- }
- }
-
-
- public void show() {
- if (mContentView != null && mContentView.getVisibility() != View.VISIBLE) {
- mContentView.setVisibility(View.VISIBLE);
- }
- }
-
- /**
- * 点击开始直播按钮
- */
- private void startLive() {
- boolean startPreview = ((LiveRyAnchorActivity) mContext).isStartPreview();
-// if (!startPreview) {
-// ToastUtil.show(R.string.please_wait);
-// return;
-// }
- if (mLiveClassID == 0) {
- ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
- return;
- }
- if (mLiveShareAdapter != null) {
- String type = mLiveShareAdapter.getShareType();
- if (!TextUtils.isEmpty(type)) {
-// ((LiveActivity) mContext).shareLive(type, new MobCallback() {
-// @Override
-// public void onSuccess(Object data) {
-//
-// }
-//
-// @Override
-// public void onError() {
-//
-// }
-//
-// @Override
-// public void onCancel() {
-//
-// }
-//
-// @Override
-// public void onFinish() {
-// createRoom();
-// }
-// });
- } else {
- createRoom();
- }
- } else {
- createRoom();
- }
- }
-
- /**
- * 请求创建直播间接口,开始直播
- */
- boolean isHttpBack = false;
- private void createRoom() {
- if(isHttpBack == false) {
- isHttpBack = true;
- if (mLiveClassID == 0) {
- ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
- return;
- }
- String title = mEditTitle.getText().toString().trim();
- LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile,0, false,new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, final String[] info) {
- if (code == 0 && info.length > 0) {
- L.e("开播", "createRoom------->" + info[0]);
- isHttpBack = false;
- final CommonAppConfig appConfig = CommonAppConfig.getInstance();
- UserBean u = appConfig.getUserBean();
-
- ((LiveRyAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
-//
-// RongChatRoomClient.getInstance().joinChatRoom("g" + appConfig.getUid(), -1, new IRongCoreCallback.OperationCallback() {
-// @Override
-// public void onSuccess() {
-// Log.i("tx","创建成功");
-// ((LiveAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
-// }
-//
-// @Override
-// public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
-// Log.i("tx",code+"创建失败"+coreErrorCode);
-// if(code == 10025){
-// ((LiveAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
-// }else{
-// ToastUtil.show("开播失败,联系客服。");
-// }
-// }
-// });
- } else {
- ToastUtil.show(msg);
- }
- }
-
- @Override
- public void onError() {
- super.onError();
- isHttpBack = false;
- }
- });
- }else {
- ToastUtil.show("請求中,請勿重複點擊");
- }
- }
-
- public void release() {
- mImageUtil = null;
- mActivityResultCallback = null;
- mLiveTypeCallback = null;
- }
-
- @Override
- public void onDestroy() {
- LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM);
- }
-}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java
index 6f88ab017..afeed02d1 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java
@@ -1,8 +1,5 @@
package com.yunbao.live.views;
-import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
-import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
-import static com.yunbao.live.views.LivePushTxViewHolder.mTRTCCloud;
import android.app.Dialog;
import android.content.Context;
@@ -23,9 +20,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lzy.okgo.model.Response;
-import com.tencent.imsdk.v2.V2TIMManager;
-import com.tencent.imsdk.v2.V2TIMSendCallback;
-import com.tencent.trtc.TRTCCloudDef;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.LiveRoomTypeBean;
@@ -221,7 +215,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
} else if (i == R.id.btn_locaiton) {
switchLocation();
} else if (i == R.id.btn_horizontally) {
- TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
+ /* TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
if (mrr == 0) {
mrr = 1;
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_ENABLE;
@@ -231,7 +225,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_DISABLE;
mTRTCCloud.setVideoEncoderMirror(false);
}
- mTRTCCloud.setLocalRenderParams(t);
+ mTRTCCloud.setLocalRenderParams(t);*/
}
}
@@ -499,7 +493,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
L.e("tx开播", "createRoom------->" + info[0]);
final CommonAppConfig appConfig = CommonAppConfig.getInstance();
UserBean u = appConfig.getUserBean();
- V2TIMManager.getInstance().createGroup(V2TIMManager.GROUP_TYPE_AVCHATROOM, "g" + appConfig.getUid(), "直播", new V2TIMSendCallback() {
+ /* V2TIMManager.getInstance().createGroup(V2TIMManager.GROUP_TYPE_AVCHATROOM, "g" + appConfig.getUid(), "直播", new V2TIMSendCallback() {
@Override
public void onProgress(int progress) {
@@ -520,7 +514,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
ToastUtil.show("开播失败,联系客服。");
}
}
- });
+ });*/
} else {
ToastUtil.show(msg);
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRecordPlayViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRecordPlayViewHolder.java
deleted file mode 100644
index c728405b4..000000000
--- a/live/src/main/java/com/yunbao/live/views/LiveRecordPlayViewHolder.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package com.yunbao.live.views;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.RelativeLayout;
-
-import com.tencent.rtmp.ITXLivePlayListener;
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.TXVodPlayer;
-import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.yunbao.common.utils.L;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.common.views.AbsViewHolder;
-import com.yunbao.live.R;
-
-/**
- * Created by cxf on 2018/10/29.
- * 直播记录播放页面
- */
-
-public class LiveRecordPlayViewHolder extends AbsViewHolder implements ITXLivePlayListener {
-
- private static final String TAG = "VideoPlayViewHolder";
- private TXCloudVideoView mVideoView;
- private View mLoading;
- private TXVodPlayer mPlayer;
- private boolean mClickPaused;
- private boolean mPaused;
- private boolean mStarted;
- private boolean mEnd;
- private long mDuration;
- private long mCurTime;
- private int mProgress;
- private ActionListener mActionListener;
-
- public LiveRecordPlayViewHolder(Context context, ViewGroup parentView) {
- super(context, parentView);
- }
-
- @Override
- protected int getLayoutId() {
- return R.layout.view_live_record_play;
- }
-
- @Override
- public void init() {
- mLoading = findViewById(R.id.loading);
- mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
- mVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
- mPlayer = new TXVodPlayer(mContext);
- mPlayer.setPlayerView(mVideoView);
- mPlayer.setAutoPlay(true);
- mPlayer.setPlayListener(this);
- }
-
- @Override
- public void onPlayEvent(int e, Bundle bundle) {
- switch (e) {
- case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS://进度条
- if (mActionListener != null) {
- int duration = bundle.getInt("EVT_PLAY_DURATION_MS");
- if (mDuration != duration) {
- mDuration = duration;
- mActionListener.onDuration(duration);
- }
- int curTime = bundle.getInt("EVT_PLAY_PROGRESS_MS");
- if (mCurTime != curTime) {
- mCurTime = curTime;
- mActionListener.onCurTime(curTime);
- }
- int progress = curTime * 100 / duration;
- if (mProgress != progress) {
- mProgress = progress;
- mActionListener.onProgress(progress);
- }
- }
- break;
- case TXLiveConstants.PLAY_EVT_PLAY_BEGIN:
- if (!mEnd) {
- L.e(TAG, "VideoPlayView------>播放开始");
- if (mLoading != null && mLoading.getVisibility() == View.VISIBLE) {
- mLoading.setVisibility(View.INVISIBLE);
- }
- } else {
- release();
- }
- break;
- case TXLiveConstants.PLAY_ERR_NET_DISCONNECT:
- case TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND:
- ToastUtil.show(mContext.getString(R.string.live_play_error));
- break;
- case TXLiveConstants.PLAY_EVT_PLAY_LOADING:
- if (mLoading != null && mLoading.getVisibility() != View.VISIBLE) {
- mLoading.setVisibility(View.VISIBLE);
- }
- break;
- case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME:
- L.e(TAG, "VideoPlayView------>第一帧");
- break;
- case TXLiveConstants.PLAY_EVT_PLAY_END:
- onReplay();
- break;
- case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION:
- int width = bundle.getInt("EVT_PARAM1", 0);
- int height = bundle.getInt("EVT_PARAM2", 0);
- if (mVideoView != null && width >= height) {//横屏视频
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
- float rate = ((float) width) / height;
- params.height = (int) (mVideoView.getWidth() / rate);
- params.addRule(RelativeLayout.CENTER_IN_PARENT);
- mVideoView.requestLayout();
- }
- break;
- }
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
- L.e("onNetStatus-------->");
- }
-
- /**
- * 循环播放
- */
- private void onReplay() {
- if (!mEnd && mStarted && mPlayer != null) {
- mPlayer.seek(0);
- mPlayer.resume();
- }
- }
-
- /**
- * 开始播放
- */
- public void play(String url) {
- if (!mEnd && mPlayer != null) {
- if (mStarted) {
- mPlayer.stopPlay(false);
- }
- mPlayer.startPlay(url);
- mStarted = true;
- L.e(TAG, "play------->" + url);
- }
- }
-
- public void release() {
- mActionListener = null;
- mEnd = true;
- if (mPlayer != null) {
- mPlayer.stopPlay(true);
- }
- mPlayer = null;
- if (mVideoView != null) {
- mVideoView.onDestroy();
- }
- mVideoView = null;
- L.e(TAG, "release------->");
- }
-
- public void clickPause() {
- mClickPaused = true;
- if (!mEnd && mPlayer != null) {
- mPlayer.pause();
- }
- if (mActionListener != null) {
- mActionListener.onClickPause();
- }
- }
-
- public void clickResume() {
- if (mClickPaused) {
- mClickPaused = false;
- if (!mEnd && mPlayer != null) {
- mPlayer.resume();
- }
- if (mActionListener != null) {
- mActionListener.onClickResume();
- }
- }
- }
-
- /**
- * 跳转到视频流指定时间点.
- * 可实现视频快进,快退,进度条跳转等功能.
- *
- * @param time 视频流时间点,小数点后为毫秒
- */
- public void seekTo(float time) {
- if (!mEnd && mPlayer != null) {
- mPlayer.seek(time);
- }
- }
-
- public void setActionListener(ActionListener actionListener) {
- mActionListener = actionListener;
- }
-
- public interface ActionListener {
-
- void onProgress(int progress);
-
- void onDuration(long duration);
-
- void onCurTime(long curTime);
-
- void onClickPause();
-
- void onClickResume();
- }
-
- @Override
- public void onPause() {
- mPaused = true;
- if (!mEnd && !mClickPaused && mPlayer != null) {
- mPlayer.pause();
- }
- }
-
- @Override
- public void onResume() {
- if (mPaused) {
- mPaused = false;
- if (!mEnd && !mClickPaused && mPlayer != null) {
- mPlayer.resume();
- }
- }
- }
-
-}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRecordViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRecordViewHolder.java
index c592f8a9b..8dfdacfaf 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRecordViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRecordViewHolder.java
@@ -16,7 +16,6 @@ import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveRecordPlayActivity;
import com.yunbao.live.adapter.LiveRecordAdapter;
import com.yunbao.live.bean.LiveRecordBean;
import com.yunbao.common.http.LiveHttpConsts;
@@ -127,7 +126,7 @@ public class LiveRecordViewHolder extends AbsUserHomeViewHolder implements OnIte
if (mActionListener != null) {
UserBean userBean = mActionListener.getUserBean();
if (userBean != null) {
- LiveRecordPlayActivity.forward(mContext, url, userBean);
+// LiveRecordPlayActivity.forward(mContext, url, userBean);
}
}
} else {
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
index aceda8ca5..c30b863b6 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
@@ -1,7 +1,10 @@
package com.yunbao.live.views;
import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
+import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_TASK_INLET;
+import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_TASK_INLET1;
+import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
@@ -26,6 +29,7 @@ import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
+import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
@@ -54,8 +58,6 @@ import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
@@ -69,7 +71,6 @@ import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.bean.PrankProgressBean;
-import com.yunbao.common.fragment.GiftWallMainTab1Fragment;
import com.yunbao.common.utils.DebugUtils;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MobclickAgent;
@@ -130,12 +131,10 @@ import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.manager.RandomPkManager;
-import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
-import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RouteUtil;
@@ -158,10 +157,8 @@ import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.ZhuangBanActivity;
-import com.yunbao.live.adapter.ComboAdapter;
import com.yunbao.live.adapter.LiveChatAdapter;
import com.yunbao.live.adapter.LiveRoomFastMessageRecyclerViewAdapter;
import com.yunbao.live.adapter.LiveUserAdapter;
@@ -203,7 +200,6 @@ import com.yunbao.live.presenter.LiveLightAnimPresenter;
import com.yunbao.live.utils.LiveRoomVoteManager;
import com.yunbao.live.utils.LiveTextRender;
import com.yunbao.live.utils.LoadDian9TuUtil;
-import com.yunbao.live.utils.ZeusKt;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -226,8 +222,6 @@ import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.UserInfo;
-import com.bumptech.glide.load.resource.gif.GifDrawable;
-
import pl.droidsonroids.gif.GifImageView;
/**
@@ -442,6 +436,367 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public static SVGAVideoEntity drawableTitleCn;
public static SVGAVideoEntity drawableTitleEn;
public static SVGAVideoEntity drawableBg;
+ private int mDp500 = DpUtil.dp2px(-400);;
+ private boolean isComAll;
+ public void setComAll(boolean isComAll) {
+ this.isComAll = isComAll;
+ }
+
+
+ //提醒用户免费礼物
+ private RelativeLayout new_task_send_gift_notify;
+ private TextView new_task_send_gift_details;
+ private ImageView close_task_send_gift_close;
+
+ //完成了任务
+ private RelativeLayout new_task_gift_notify1;
+ private TextView new_task_gift_details1;
+ private ImageView close_task_receive_close1;
+
+ //完成新人任务,领取专属豪礼
+ private RelativeLayout new_task_gift_notify;
+ private TextView new_task_gift_details;
+ private ImageView close_task_receive_close;
+
+ //首次进入该直播间 关注弹窗
+ private RelativeLayout notify_follow_layout;
+ private ImageView notify_follow_coin;
+ private TextView notify_follow_name;
+ private ImageView follow_first_look;
+ private ImageView close_first_look_follow;
+
+
+ /**
+ * // //提醒用户免费礼物 handleler
+ * */
+ private Handler sendGiftTaskHandler = new Handler();
+ private Runnable sendGiftTaskRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (new_task_send_gift_notify != null) {
+ animatorSendGiftTask(false);
+ sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
+ }
+ }
+ };
+ private ObjectAnimator animator_send_gift_task;
+ public void showSendGiftTaskDetailsNotify() {
+ new_task_send_gift_notify.post(new Runnable() {
+ @Override
+ public void run() {
+ LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) new_task_send_gift_notify.getLayoutParams();
+ params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72);
+ new_task_send_gift_notify.setLayoutParams(params1);
+ }
+ });
+ new_task_send_gift_details.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //跳转到免费礼物
+ ((LiveAudienceActivity) mContext).openGiftWindow();
+ animatorSendGiftTask(false);
+ sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
+ }
+ });
+ close_task_send_gift_close.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ animatorSendGiftTask(false);
+ sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
+ }
+ });
+ sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
+ sendGiftTaskHandler.postDelayed(sendGiftTaskRunnable, 10000);
+ new_task_send_gift_notify.setVisibility(View.VISIBLE);
+ mDp500 = DpUtil.dp2px(-400);
+ animatorSendGiftTask(true);
+ }
+ public void animatorSendGiftTask(boolean isIn) {
+ if (isIn) {
+ animator_send_gift_task = ObjectAnimator.ofFloat(new_task_send_gift_notify, "translationX", mDp500, 0);
+ animator_send_gift_task.setDuration(1000);
+ } else {
+ animator_send_gift_task = ObjectAnimator.ofFloat(new_task_send_gift_notify, "translationX", 0, mDp500);
+ animator_send_gift_task.setDuration(1000);
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ new_task_send_gift_notify.setVisibility(View.GONE);
+ }
+ }, 2000);
+ }
+ animator_send_gift_task.setInterpolator(new LinearInterpolator());
+ animator_send_gift_task.start();
+ }
+
+
+ /**
+ * 完成任务 1
+ * */
+ private Handler firstTaskDetailsHandler1 = new Handler();
+ private Runnable firstTaskDetailsRunnable1 = new Runnable() {
+ @Override
+ public void run() {
+ if (new_task_gift_notify1 != null) {
+ animatorTaskDetails1(false);
+ firstTaskDetailsHandler1.removeCallbacks(firstTaskDetailsRunnable1);
+ }
+ }
+ };
+ private ObjectAnimator animator_first_task_details1;
+ public void showTaskDetailsNotify1(String url) {
+ new_task_gift_notify1.post(new Runnable() {
+ @Override
+ public void run() {
+ LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) new_task_gift_notify1.getLayoutParams();
+ params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72);
+ new_task_gift_notify1.setLayoutParams(params1);
+ }
+ });
+ new_task_gift_details1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showH5Dialog();
+ }
+ });
+
+ close_task_receive_close1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ animatorTaskDetails1(false);
+ firstTaskDetailsHandler1.removeCallbacks(firstTaskDetailsRunnable1);
+ }
+ });
+ firstTaskDetailsHandler1.removeCallbacks(firstTaskDetailsRunnable1);
+ firstTaskDetailsHandler1.postDelayed(firstTaskDetailsRunnable1, 7000);
+ new_task_gift_notify1.setVisibility(View.VISIBLE);
+ mDp500 = DpUtil.dp2px(-400);
+ animatorTaskDetails1(true);
+ }
+ public void animatorTaskDetails1(boolean isIn) {
+ if (isIn) {
+ animator_first_task_details1 = ObjectAnimator.ofFloat(new_task_gift_notify1, "translationX", mDp500, 0);
+ animator_first_task_details1.setDuration(1000);
+ } else {
+ animator_first_task_details1 = ObjectAnimator.ofFloat(new_task_gift_notify1, "translationX", 0, mDp500);
+ animator_first_task_details1.setDuration(1000);
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ new_task_gift_notify1.setVisibility(View.GONE);
+ }
+ }, 2000);
+ }
+ animator_first_task_details1.setInterpolator(new LinearInterpolator());
+ animator_first_task_details1.start();
+ }
+
+
+ /**
+ * 完成任务 2
+ * */
+ private Handler firstTaskDetailsHandler = new Handler();
+ private Runnable firstTaskDetailsRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (new_task_gift_notify != null) {
+ animatorTaskDetails(false);
+ firstTaskDetailsHandler.removeCallbacks(firstTaskDetailsRunnable);
+ }
+ }
+ };
+
+ private ObjectAnimator animator_first_task_details;
+ public void showTaskDetailsNotify() {
+ new_task_gift_notify.post(new Runnable() {
+ @Override
+ public void run() {
+ LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) new_task_gift_notify.getLayoutParams();
+ params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72);
+ new_task_gift_notify.setLayoutParams(params1);
+ }
+ });
+ new_task_gift_details.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showH5Dialog();
+ }
+ });
+ close_task_receive_close.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ animatorTaskDetails(false);
+ firstTaskDetailsHandler.removeCallbacks(firstTaskDetailsRunnable);
+ }
+ });
+ firstTaskDetailsHandler.removeCallbacks(firstTaskDetailsRunnable);
+ firstTaskDetailsHandler.postDelayed(firstTaskDetailsRunnable, 7000);
+ new_task_gift_notify.setVisibility(View.VISIBLE);
+ mDp500 = DpUtil.dp2px(-400);
+ animatorTaskDetails(true);
+ }
+ public void animatorTaskDetails(boolean isIn) {
+ if (isIn) {
+ animator_first_task_details = ObjectAnimator.ofFloat(new_task_gift_notify, "translationX", mDp500, 0);
+ animator_first_task_details.setDuration(1000);
+ } else {
+ animator_first_task_details = ObjectAnimator.ofFloat(new_task_gift_notify, "translationX", 0, mDp500);
+ animator_first_task_details.setDuration(1000);
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ new_task_gift_notify.setVisibility(View.GONE);
+ }
+ }, 2000);
+ }
+ animator_first_task_details.setInterpolator(new LinearInterpolator());
+ animator_first_task_details.start();
+ }
+
+
+ /**
+ * 新人关注主播
+ * */
+ private Handler firstFollowLookHandler = new Handler();
+ private Runnable firstFollowLookRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (notify_follow_layout != null) {
+ animatorFollowFirstLook(false);
+ firstFollowLookHandler.removeCallbacks(firstFollowLookRunnable);
+ if (!nothingCheck || !isComAll) {//没有任何操作
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ showTaskDetailsNotify();
+ }
+ }, 2000);
+ }
+ }
+ }
+ };
+
+ private ObjectAnimator animator_follow_first_look;
+ private boolean nothingCheck = false;
+ public void showFirstLookLiveFollowNotify() {
+ notify_follow_layout.post(new Runnable() {
+ @Override
+ public void run() {
+ LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) notify_follow_layout.getLayoutParams();
+ params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72);
+ notify_follow_layout.setLayoutParams(params1);
+ }
+ });
+ ImgLoader.displayAvatar(mContext, mAvatarUrl, notify_follow_coin);
+ notify_follow_name.setText(mAnchorName);
+ close_first_look_follow.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ nothingCheck = true;
+ animatorFollowFirstLook(false);
+ }
+ });
+ follow_first_look.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ nothingCheck = true;
+ follow_first_look.setImageResource(R.mipmap.icon_live_room_followed);
+ //關注
+ follow();
+ if (((LiveAudienceActivity) mContext).getCountDownTimer() != null) {
+ ((LiveAudienceActivity) mContext).getCountDownTimer().cancel();
+ }
+ animatorFollowFirstLook(false);
+ firstFollowLookHandler.removeCallbacks(firstFollowLookRunnable);
+ }
+ });
+ firstFollowLookHandler.removeCallbacks(firstFollowLookRunnable);
+ firstFollowLookHandler.postDelayed(firstFollowLookRunnable, 7000);
+ notify_follow_layout.setVisibility(View.VISIBLE);
+ mDp500 = DpUtil.dp2px(-400);
+ animatorFollowFirstLook(true);
+ }
+
+ public void animatorFollowFirstLook(boolean isIn) {
+ if (isIn) {
+ animator_follow_first_look = ObjectAnimator.ofFloat(notify_follow_layout, "translationX", mDp500, 0);
+ animator_follow_first_look.setDuration(1000);
+ } else {
+ animator_follow_first_look = ObjectAnimator.ofFloat(notify_follow_layout, "translationX", 0, mDp500);
+ animator_follow_first_look.setDuration(1000);
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ notify_follow_layout.setVisibility(View.GONE);
+ }
+ }, 2000);
+ }
+ animator_follow_first_look.setInterpolator(new LinearInterpolator());
+ animator_follow_first_look.start();
+ }
+
+
+ //向chatList发送一条活动入口消息
+ public void showSendGiftTaskMsg() {
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ LiveChatBean bean = new LiveChatBean();
+ bean.setType(LiveChatBean.TYPE_TO_TASK_INLET);
+ mLiveChatAdapter.insertItem(bean);
+ }
+ }, 1000);
+ if (mLiveRoomHandler != null) {
+ mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_TASK_INLET_LIVE, getNextTime(1000 * 300));
+ }
+ }
+
+
+ //向chatList发送一条活动入口消息
+ public void showSendGiftTaskIMMsg() {
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ LiveChatBean bean = new LiveChatBean();
+ bean.setType(LiveChatBean.TYPE_TO_TASK_INLET1);
+ mLiveChatAdapter.insertItem(bean);
+ }
+ }, 1000);
+ }
+
+ public boolean isShowH5Dialog;
+
+ public void showH5Dialog() {
+ Bundle bundle = new Bundle();
+ bundle.putString("url", CommonAppConfig.HOST + "/h5/activity/pdlNewUes/index.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+"&app_from=PDLive");
+ LiveHDDialogFragment fragment = new LiveHDDialogFragment();
+ fragment.setArguments(bundle);
+ fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
+ fragment.setOnDisListener(new LiveHDDialogFragment.OnDisListener() {
+ @Override
+ public void onDis() {
+ startTaskInletTime();
+ }
+ });
+ }
+ public void startTaskInletTime() {
+ if (!isShowH5Dialog) {
+ firstTaskInletNotify();
+ }
+ isShowH5Dialog = true;
+ }
+
+ /**
+ * 打開活動彈窗 关闭5min后
+ */
+ public void firstTaskInletNotify() {
+ if (mLiveRoomHandler != null) {
+ //取消观看200秒后的定时器-产品需求,只需要存在一个逻辑
+ mLiveRoomHandler.removeMessages(LiveRoomHandler.WHAT_TASK_INLET_LIVE);
+ mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_TASK_INLET_LIVE, getNextTime(1000 * 5));
+ }
+ }
+
public LiveRoomViewHolder setGuardType(int guardType) {
this.guardType = guardType;
@@ -1365,9 +1720,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
topBanner1 = (Banner) findViewById(R.id.top_banner1);
topBanner2 = (Banner) findViewById(R.id.top_banner2);
- if (LivePushTxViewHolder.mTRTCCloud != null || LivePushSwViewHolder.rtcRoom != null) {
+ /* if (LivePushTxViewHolder.mTRTCCloud != null ) {
fans_btn.setVisibility(View.GONE);
- }
+ }*/
mPkRankTopIcon.setVisibility(View.GONE);
goto_room_view = (LinearLayout) findViewById(R.id.goto_room_view);
goto_room_view.setVisibility(View.GONE);
@@ -1456,8 +1811,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
liveHDDialogFragment.setArguments(bundle1);
if(mContext instanceof LiveAudienceActivity){
liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
- }else if(mContext instanceof LiveRyAnchorActivity){
- liveHDDialogFragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}else if(mContext instanceof LiveSwAnchorActivity){
liveHDDialogFragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
@@ -1474,16 +1827,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
});
fragment.setmLiveUid(mLiveUid);
- if(mContext instanceof LiveRyAnchorActivity){
- fragment.show(((LiveRyAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment");
- }else if(mContext instanceof LiveSwAnchorActivity){
+ if(mContext instanceof LiveSwAnchorActivity){
fragment.show(((LiveSwAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment");
}
- if(mContext instanceof LiveRyAnchorActivity){
- com.yunbao.live.activity.LiveRyAnchorActivity.mLiveAnchorViewHolder.closeMenuRed();
- }else if(mContext instanceof LiveSwAnchorActivity){
+ if(mContext instanceof LiveSwAnchorActivity){
com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder.closeMenuRed();
}
+ }else if (bean.getType() == TYPE_TO_TASK_INLET || bean.getType() == TYPE_TO_TASK_INLET1) {
+ L.e("TYPE_TO_TASK_INLET1=" + bean.getType());
+ showH5Dialog();
}else{
showUserDialog(bean.getId());
}
@@ -1707,7 +2059,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
findViewById(R.id.btn_follow).setVisibility(View.GONE);
findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
}
- if (mContext instanceof LiveRyAnchorActivity ||mContext instanceof LiveSwAnchorActivity) {
+ if (mContext instanceof LiveSwAnchorActivity) {
findViewById(R.id.open_sidebar).setVisibility(View.GONE);
findViewById(R.id.btn_follow).setVisibility(View.GONE);
findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
@@ -1834,6 +2186,48 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
recycler_prank.setLayoutManager(new LinearLayoutManager(mContext));
initPrankAdapter();
+
+ notify_follow_layout = (RelativeLayout) findViewById(R.id.notify_follow_layout);
+ notify_follow_layout.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ L.e("其他區域");
+ }
+ });
+ notify_follow_coin = (ImageView) findViewById(R.id.notify_follow_coin);
+ notify_follow_name = (TextView) findViewById(R.id.notify_follow_name);
+ follow_first_look = (ImageView) findViewById(R.id.follow_first_look);
+ close_first_look_follow = (ImageView) findViewById(R.id.close_first_look_follow);
+
+ new_task_gift_notify = (RelativeLayout) findViewById(R.id.new_task_gift_notify);
+ new_task_gift_notify.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ L.e("其他區域");
+ }
+ });
+ new_task_gift_details = (TextView) findViewById(R.id.new_task_gift_details);
+ close_task_receive_close = (ImageView) findViewById(R.id.close_task_receive_close);
+
+ new_task_gift_notify1 = (RelativeLayout) findViewById(R.id.new_task_gift_notify1);
+ new_task_gift_notify1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ L.e("其他區域");
+ }
+ });
+ new_task_gift_details1 = (TextView) findViewById(R.id.new_task_gift_details1);
+ close_task_receive_close1 = (ImageView) findViewById(R.id.close_task_receive_close1);
+
+ new_task_send_gift_notify = (RelativeLayout) findViewById(R.id.new_task_send_gift_notify);
+ new_task_send_gift_notify.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ L.e("其他區域");
+ }
+ });
+ new_task_send_gift_details = (TextView) findViewById(R.id.new_task_send_gift_details);
+ close_task_send_gift_close = (ImageView) findViewById(R.id.close_task_send_gift_close);
}
/**
@@ -2188,7 +2582,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
layoutParams.topMargin = DpUtil.dp2px(240);
dragonImmediateParticipation.setLayoutParams(layoutParams);
}
- if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE && mContext instanceof LiveRyAnchorActivity || mContext instanceof LiveSwAnchorActivity) {
+ if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE && mContext instanceof LiveSwAnchorActivity) {
RelativeLayout.LayoutParams layoutParamsredPacket = (RelativeLayout.LayoutParams) redPacket.getLayoutParams();
layoutParamsredPacket.topMargin = DpUtil.dp2px(160);
redPacket.setLayoutParams(layoutParamsredPacket);
@@ -2197,7 +2591,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
layoutParams.topMargin = DpUtil.dp2px(240);
dragonImmediateParticipationTime.setLayoutParams(layoutParams);
}
- if (mContext instanceof LiveRyAnchorActivity || mContext instanceof LiveSwAnchorActivity) {
+ if (mContext instanceof LiveSwAnchorActivity) {
if (dragonImmediateParticipationTime.getVisibility() == View.GONE) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) redPacket.getLayoutParams();
layoutParams.topMargin = DpUtil.dp2px(160);
@@ -2220,7 +2614,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
redSchedule.setText(stringBuffer.toString());
openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + ""));
}
- if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && (mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity)) {
+ if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && (mContext instanceof LiveSwAnchorActivity )) {
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
anchorTimeHandler.post(anchorTimeRunnable);
}
@@ -2232,7 +2626,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void onViewClicks() {
- if (!(mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity)) {
+ if (!(mContext instanceof LiveSwAnchorActivity )) {
LiveNetManager.get(mContext).redPacketInfo(mLiveUid, redPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback() {
@Override
public void onSuccess(RedPacketInfoModel data) {
@@ -2359,9 +2753,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (d_pk_view != null) {
d_pk_view.setVisibility(View.GONE);
}
- if (LivePushTxViewHolder.mTRTCCloud != null || LivePushSwViewHolder.rtcRoom != null) {
+ /* if (LivePushTxViewHolder.mTRTCCloud != null ) {
fans_btn.setVisibility(View.GONE);
- }
+ }*/
mRedVal.setVisibility(View.GONE);
mBlueVal.setVisibility(View.GONE);
mPkRankTopIcon.setVisibility(View.GONE);
@@ -2371,6 +2765,35 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
showAnchorSayAndCallAnchor();
}
+
+ /**
+ * 首次进入直播间
+ */
+ public void firstLookLiveNotify() {
+ if (mLiveRoomHandler != null) {
+ mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_FIRST_LOOK_LIVE, getNextTime(50000));
+ }
+ }
+
+ /**
+ * 首次进入直播间
+ */
+ public void firstLook5MinLiveNotify() {
+ if (mLiveRoomHandler != null) {
+ mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_LOOK_5_MIN_LIVE, getNextTime(1000 * 60 * 5));
+ }
+ }
+
+ /**
+ * 观看200秒之后
+ */
+ public void firstTaskInlet1Notify() {
+ if (mLiveRoomHandler != null) {
+ mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_TASK_INLET_LIVE, getNextTime(1000 * 200));
+ }
+ }
+
+
/**
* 重置数据
*/
@@ -2381,6 +2804,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
pa_pao_layout.setVisibility(View.GONE);
combo_layout.setVisibility(View.GONE);
+ mLiveRoomHandler.removeMessages(LiveRoomHandler.WHAT_ANCHOR_GOD_SHOW_HIDE);
resetViewGone();
visibility = false;
pkUidTmp = "";
@@ -3429,7 +3853,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
bundle.putString("toUid", toUid);
bundle.putInt("isAttention", isAttention);
bundle.putBoolean("isLive", isAnchor);
- bundle.putBoolean("SBW", !(mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity));
+ bundle.putBoolean("SBW", !(mContext instanceof LiveSwAnchorActivity ));
giftWallDialog.setArguments(bundle);
giftWallDialog.show(((AbsActivity) mContext).getSupportFragmentManager(), "GiftWallDialog");
@@ -3460,10 +3884,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
});
initPkRank();
- if (LivePushTxViewHolder.mTRTCCloud != null) {
-
- } else {
- }
}
public void setDelOtherInfo() {
@@ -3795,7 +4215,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
//直播间 粉丝排行榜
openMedalRankWindow();
} else if (i == R.id.btn_guard) {
- ((LiveActivity) mContext).openNewGuardListWindow((mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity));
+ ((LiveActivity) mContext).openNewGuardListWindow((mContext instanceof LiveSwAnchorActivity));
} else if (i == R.id.btn_red_pack) {
((LiveActivity) mContext).openRedPackListWindow();
@@ -3803,13 +4223,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
((LiveActivity) mContext).openPrizePoolWindow();
} else if (i == R.id.user_more) {
MobclickAgent.onEvent(mContext, "live_room_audience_list", "直播间上面点观众列表按钮");
- ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity);
} else if (i == R.id.hot_btn) {
- ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity );
} else if (i == R.id.noble_seat) {
MobclickAgent.onEvent(mContext, "live_room_noble", "贵族按钮");
- ((LiveActivity) mContext).openUserMoreListWindow(1, false, true, mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openUserMoreListWindow(1, false, true, mContext instanceof LiveSwAnchorActivity );
} else if (i == R.id.btn_close) {
// if (sudGameMin!=null&&sudGameMin.getVisibility()==View.VISIBLE) {
// new XPopup.Builder(mContext)
@@ -3842,7 +4262,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} else if (i == R.id.user_guard) {
MobclickAgent.onEvent(mContext, "anchor_avatar_guard", "守护按钮");
// ((LiveActivity) mContext).openUserMoreListWindow(2, true);
- ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity );
}
if (i == R.id.lt_trickery) {
showTrickeryDialog();
@@ -3867,7 +4287,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
* @param in 展示的view
*/
private void changeMsgView(View out, View in) {
- if (mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity) {
+ if (mContext instanceof LiveSwAnchorActivity ) {
return;
}
if (in.getVisibility() == View.VISIBLE) {
@@ -4098,24 +4518,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}
- } else if (mContext instanceof LiveRyAnchorActivity) {
- if (forAct == 1) {
- //是否关注0==没关注
- if (isAttention == 0) {
- if (isStayRoomfive) {
- showFollowDialog(mNameText, mAvatarUrl, mContext);
- } else {
- LiveRyAnchorActivity.backIndex = 1;
- ((LiveRyAnchorActivity) mContext).onBackPressed();
- }
- } else {
- LiveRyAnchorActivity.backIndex = 1;
- ((LiveRyAnchorActivity) mContext).onBackPressed();
- }
- } else {
- LiveRyAnchorActivity.backIndex = 1;
- ((LiveRyAnchorActivity) mContext).onBackPressed();
- }
}
}
@@ -4869,6 +5271,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private static final int WHAT_ANCHOR_PAUSE = 4;//主播切后台
private static final int WHAT_ANCHOR_LIGHT = 5;//主播飘心
private static final int WHAT_ANCHOR_CHECK_LIVE = 6;//主播checkLive
+ private static final int WHAT_FIRST_LOOK_LIVE = 7;//用户首次进入该直播间计时
+ private static final int WHAT_LOOK_5_MIN_LIVE = 8;//用户首次进入该直播间计时
+ private static final int WHAT_TASK_INLET_LIVE = 9;//打开活动页
+ static final int WHAT_ANCHOR_GOD_SHOW_HIDE = 10; //延迟十秒收起女神说
public LiveRoomHandler(LiveRoomViewHolder liveRoomViewHolder) {
mLiveRoomViewHolder = new WeakReference<>(liveRoomViewHolder).get();
@@ -4893,6 +5299,28 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
case WHAT_ANCHOR_CHECK_LIVE:
mLiveRoomViewHolder.anchorCheckLive();
break;
+
+ case WHAT_FIRST_LOOK_LIVE:
+ Log.i("xinrenguanbo", "WHAT_FIRST_LOOK_LIVE: ");
+
+ if (isAttention == 0) {
+ mLiveRoomViewHolder.showFirstLookLiveFollowNotify();
+ } else {
+ mLiveRoomViewHolder.showTaskDetailsNotify();
+ }
+ break;
+ case WHAT_LOOK_5_MIN_LIVE:
+ Log.i("xinrenguanbo", "WHAT_LOOK_5_MIN_LIVE: ");
+
+ mLiveRoomViewHolder.showSendGiftTaskDetailsNotify();
+ break;
+ case WHAT_TASK_INLET_LIVE:
+ Log.i("xinrenguanbo", "WHAT_TASK_INLET_LIVE: ");
+ mLiveRoomViewHolder.showSendGiftTaskMsg();
+ break;
+ case WHAT_ANCHOR_GOD_SHOW_HIDE:
+ mLiveRoomViewHolder.hideAnchorSay();
+ break;
}
}
}
@@ -5011,6 +5439,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
RouteUtil.forwardBattlePass();
return;
}
+ if (mBannerList4.get(p).getLink().equals("NewUser") || mBannerList4.get(p).getType() == 999) {
+ showH5Dialog();
+ return;
+ }
+
if (TextUtils.equals("特惠首冲", mBannerList4.get(p).getName())) {
Map map_ekv = new HashMap();
@@ -5241,7 +5674,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
lt_trickster_salvation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity) {
+ if (mContext instanceof LiveSwAnchorActivity) {
dialog.dismiss();
return;
}
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 d54131c7b..c701be428 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
@@ -46,7 +46,6 @@ import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.bean.WishlistModel;
@@ -222,8 +221,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (PKing == false) {
if (isSw) {
((LiveSwAnchorActivity) mContext).openLinkMicAnchorWindow(true);
- } else {
- ((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
@@ -300,8 +297,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private void close() {
if (isSw) {
((LiveSwAnchorActivity) mContext).closeLive();
- } else {
- ((LiveRyAnchorActivity) mContext).closeLive();
}
}
@@ -320,8 +315,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
}
if (isSw) {
((LiveSwAnchorActivity) mContext).showFunctionDialog();
- } else {
- ((LiveRyAnchorActivity) mContext).showFunctionDialog();
}
}
@@ -357,8 +350,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private void applyLinkMicPk() {
if (isSw) {
((LiveSwAnchorActivity) mContext).applyLinkMicPk();
- } else {
- ((LiveRyAnchorActivity) mContext).applyLinkMicPk();
}
}
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 1d1524deb..da942fd1f 100644
--- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
+++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
@@ -15,7 +15,6 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -28,12 +27,11 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.lzf.easyfloat.EasyFloat;
-import com.lzf.easyfloat.enums.ShowPattern;
import com.lzf.easyfloat.permission.PermissionUtils;
import com.lzf.easyfloat.utils.LifecycleUtils;
-import com.yunbao.common.dialog.DebugDialog;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.DebugUtils;
+import com.yunbao.common.utils.LogUtil;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
@@ -76,7 +74,6 @@ import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
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;
@@ -109,27 +106,20 @@ import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveOpenSuccessEvent;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
-import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
import com.yunbao.live.socket.SocketClient;
import com.yunbao.live.socket.SocketMessageListener;
import com.yunbao.live.socket.SocketRyChatUtil;
-import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwChatUtil;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.socket.SocketSendBean;
import com.yunbao.live.utils.LiveImDeletUtil;
-import com.yunbao.live.utils.LiveTextRender;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
-import cn.rongcloud.rtc.api.RCRTCEngine;
-import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
-import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
-import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.LiveFloatView;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.rong.imlib.IRongCallback;
@@ -181,7 +171,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//主播与主播PK逻辑
private LiveSwLinkMicPkPresenter mLiveSwLinkMicPkPresenter;
- private LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;
+// private LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;
//直播间的类型 普通 密码 门票 计时等
@@ -191,7 +181,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//直播结束页面
private LiveEndViewHolder mLiveEndViewHolder;
private SocketSwClient mSocketSwClient;
- private SocketRyClient mSocketRyClient;
+// private SocketRyClient mSocketRyClient;
private SocketClient mSocketClient;
private String mDanmuPrice;//弹幕价格
@@ -368,11 +358,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void run() {
try {
Log.e("ImgLoader1", data.getAvatar());
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.clearData();
- mLiveRyLinkMicPkPresenter.release();
- mLiveRyLinkMicPkPresenter = null;
- }
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.clearData();
@@ -400,7 +385,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLivePlayViewHolder = new LivePlaySwViewHolder(mContext, playContainer, mLiveBean.getLandscape());
} else {
- mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
+// mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
}
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager(), isSw);
@@ -411,8 +396,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveSwLinkMicPkPresenter = new LiveSwLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
mLiveSwLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
} else {
- mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
- mLiveRyLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
+// mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
+// mLiveRyLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
}
mLivePlayViewHolder.initSwEngine(mLiveBean.getUid());
mLivePlayViewHolder.addToParent();
@@ -440,16 +425,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveSwLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
}
} else {
- if (mLiveRyLinkMicPkPresenter == null) {
- mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
- mLiveRyLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
- }
}
//去除主播离开画面
- if (LivePlayRyViewHolder.leave != null) {
+ /* if (LivePlayRyViewHolder.leave != null) {
LivePlayRyViewHolder.leave.setVisibility(View.GONE);
- }
+ }*/
if (LivePlaySwViewHolder.leave != null) {
LivePlaySwViewHolder.leave.setVisibility(View.GONE);
}
@@ -489,13 +470,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLiveSwLinkMicPkPresenter.setLiveUid(data.getUid(), "");
} else {
- mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), "");
+// mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), "");
}
if (isSw) {
mSocketSwClient = new SocketSwClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
} else {
- mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
+// mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
}
if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.setSocketClient(mSocketClient);
@@ -676,9 +657,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (LivePlaySwViewHolder.leave != null) {
LivePlaySwViewHolder.leave.setVisibility(View.VISIBLE);
}
- if (LivePlayRyViewHolder.leave != null) {
- LivePlayRyViewHolder.leave.setVisibility(View.VISIBLE);
- }
}
//判断是否有连麦,要显示连麦窗口
String linkMicUid = data.getEnterRoomInfo().getLinkmicUid();
@@ -757,7 +735,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLiveSwLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
} else {
- mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
+// mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
}
isShowPrank = false;
} else if (!pkInfo.getString("end_pk_time").equals("0")) {
@@ -776,7 +754,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLiveSwLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
} else {
- mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
+// mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
}
isShowPrank = false;
} else {
@@ -906,6 +884,25 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
//初始化整蠱列表
mLiveRoomViewHolder.initPrankProgress(isShowPrank?1:2);
+ Log.i("xinrenguanbo", "Test .......");
+
+ if("1".equals(data.getEnterRoomInfo().getIsNewUser())){
+ Log.i("xinrenguanbo", "Test ...111....");
+
+ //检测是否是首次观看该直播间
+ if("1".equals(data.getEnterRoomInfo().getIsFirstEntry())){
+ Log.i("xinrenguanbo", "首次观看该直播间: ");
+ mLiveRoomViewHolder.firstLookLiveNotify();
+ }
+ //判断是否有免费礼物
+ if("0".equals(data.getNewPeopleTask().getTask().getSendgift())){
+ Log.i("xinrenguanbo", "有免费礼物: ");
+
+ mLiveRoomViewHolder.firstLook5MinLiveNotify();
+ }
+ //观看200秒之后,推送活动入口im消息
+ mLiveRoomViewHolder.firstTaskInlet1Notify();
+ }
}
@@ -949,10 +946,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.clearData();
mLiveRoomViewHolder.countDownTimerTrickery = null;
}
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.clearData();
- mLiveRyLinkMicPkPresenter.release();
- }
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.clearData();
mLiveSwLinkMicPkPresenter.release();
@@ -962,7 +955,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder = null;
mLiveLinkMicPresenter = null;
mLiveLinkMicAnchorPresenter = null;
- mLiveRyLinkMicPkPresenter = null;
mLiveSwLinkMicPkPresenter = null;
mLivePlayViewHolder = null;
}
@@ -990,10 +982,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.cancelAllAnim();
}
//断开socket
- if (mSocketRyClient != null) {
- mSocketRyClient.disConnect();
- mSocketRyClient = null;
- }
if (mSocketSwClient != null) {
mSocketSwClient.disConnect();
mSocketSwClient = null;
@@ -1010,11 +998,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveLinkMicAnchorPresenter.clearData();
mLiveLinkMicAnchorPresenter.release();
}
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.clearData();
- mLiveRyLinkMicPkPresenter.release();
- mLiveRyLinkMicPkPresenter = null;
- }
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.clearData();
mLiveSwLinkMicPkPresenter.release();
@@ -1048,7 +1031,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder = null;
mLiveLinkMicPresenter = null;
mLiveLinkMicAnchorPresenter = null;
- mLiveRyLinkMicPkPresenter = null;
if (PermissionUtils.checkPermission(mContext) && !kick) {
LiveFloatView.getInstance()
.cacheLiveData(mLiveBean, mLiveType, isSw, mLiveTypeVal)
@@ -1218,16 +1200,16 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
} else {
- if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) {
+ /* if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) {
return;
}
ToastUtil.show("下麥中,稍等.....");
RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {
- /**
+ *//**
* 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。
* SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。
- */
+ *//*
@Override
public void onKicked() {
@@ -1270,16 +1252,16 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
- /**
+ *//**
* 当切换失败且不影响当前角色继续音视频时回调
* @param errorCode 失败错误码
- */
+ *//*
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "下麦失败" + errorCode);
}
- });
+ });*/
}
}
@@ -1526,9 +1508,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveSwLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
}
} else {
- if (mLiveRyLinkMicPkPresenter != null) {
+ /* if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
- }
+ }*/
}
}
@@ -1543,13 +1525,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
} else {
- if (mLiveRyLinkMicPkPresenter != null) {
+ /*if (mLiveRyLinkMicPkPresenter != null) {
if (mLiveUid.equals(leftUid + "")) {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
} else {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
}
- }
+ }*/
}
}
@@ -1809,11 +1791,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法
}
} else {
- if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
+ /* if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = true;
mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法
- }
+ }*/
}
if (mLivePlayViewHolder != null) {
@@ -1846,12 +1828,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
} else {
- if (mLiveRyLinkMicPkPresenter != null) {
+ /* if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i);
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.resetViewGone();
}
- }
+ }*/
}
if (mLiveRoomViewHolder != null) {
mLivePlayViewHolder.setLiveBeanLandscape(landscape);
@@ -1885,10 +1867,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//mLiveRoomViewHolder.setDelOtherInfo();
}
} else {
- if (mLiveRyLinkMicPkPresenter != null) {
+ /* if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid);
//mLiveRoomViewHolder.setDelOtherInfo();
- }
+ }*/
}
}
@@ -2086,11 +2068,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mEnd = true;
//断开socket
- if (mSocketRyClient != null) {
- mSocketRyClient.disConnect();
- mSocketRyClient = null;
- }
-
if (mSocketSwClient != null) {
mSocketSwClient.disConnect();
mSocketSwClient = null;
@@ -2308,6 +2285,19 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
+ public void setNewTaskPush(String uid,String url) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.showTaskDetailsNotify1(url);
+ }
+ }
+
+ public void setNewTaskIM(String uid) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.showSendGiftTaskIMMsg();
+ }
+ }
+
+
/**
* 全服喇叭
*
diff --git a/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java b/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java
index 8234d581c..3e31490fe 100644
--- a/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java
@@ -382,6 +382,14 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
});
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (mAdapter != null) {
+ mRefreshView.initData();
+ }
+ }
+
//非单聊列表适配
private void setSysApt() {
if (SystemMessageActivity.type.equals("1") || SystemMessageActivity.type.equals("4")) {
diff --git a/live/src/main/java/com/yunbao/live/views/TopBannerCustomViewHolder.java b/live/src/main/java/com/yunbao/live/views/TopBannerCustomViewHolder.java
index f38d9000c..689dfe0a3 100644
--- a/live/src/main/java/com/yunbao/live/views/TopBannerCustomViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/TopBannerCustomViewHolder.java
@@ -36,6 +36,7 @@ public class TopBannerCustomViewHolder implements BannerViewHolder {
view = LayoutInflater.from(context).inflate(R.layout.view_live_top_banner_wish, null);
ImageView wishlistIcon = view.findViewById(R.id.wishlist_icon);
TextView wishlistName = view.findViewById(R.id.wishlist_name);
+ wishlistName.setSelected(true);
TextView wishlistProgress = view.findViewById(R.id.wishlist_progress);
ImgLoader.display(context, data.getWishlistIcon(), wishlistIcon);
wishlistName.setText(data.getWishlistName());
diff --git a/live/src/main/res/drawable/bg_live_item_an.xml b/live/src/main/res/drawable/bg_live_item_an.xml
new file mode 100644
index 000000000..f94242069
--- /dev/null
+++ b/live/src/main/res/drawable/bg_live_item_an.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/live/src/main/res/drawable/bg_live_room_mic_num.xml b/live/src/main/res/drawable/bg_live_room_mic_num.xml
new file mode 100644
index 000000000..daa9cd940
--- /dev/null
+++ b/live/src/main/res/drawable/bg_live_room_mic_num.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/live/src/main/res/drawable/bg_live_room_tricky_hint_join.xml b/live/src/main/res/drawable/bg_live_room_tricky_hint_join.xml
new file mode 100644
index 000000000..08050cd92
--- /dev/null
+++ b/live/src/main/res/drawable/bg_live_room_tricky_hint_join.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/live/src/main/res/drawable/border_hui.xml b/live/src/main/res/drawable/border_hui.xml
new file mode 100644
index 000000000..b53902982
--- /dev/null
+++ b/live/src/main/res/drawable/border_hui.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/live/src/main/res/drawable/edit_background_f7.xml b/live/src/main/res/drawable/edit_background_f7.xml
new file mode 100644
index 000000000..8a376a4a7
--- /dev/null
+++ b/live/src/main/res/drawable/edit_background_f7.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/live/src/main/res/layout/activity_live_trtcanchor.xml b/live/src/main/res/layout/activity_live_trtcanchor.xml
index 176fc5fc4..40955b02b 100644
--- a/live/src/main/res/layout/activity_live_trtcanchor.xml
+++ b/live/src/main/res/layout/activity_live_trtcanchor.xml
@@ -7,12 +7,12 @@
android:orientation="vertical"
tools:context=".activity.LiveTRTCAnchorActivity">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/live/src/main/res/layout/activity_sys_msg.xml b/live/src/main/res/layout/activity_sys_msg.xml
index ed48bd926..1060f4c77 100644
--- a/live/src/main/res/layout/activity_sys_msg.xml
+++ b/live/src/main/res/layout/activity_sys_msg.xml
@@ -7,7 +7,7 @@
\ No newline at end of file
diff --git a/live/src/main/res/layout/item_live_report_head.xml b/live/src/main/res/layout/item_live_report_head.xml
index 34c3ffe37..a196b0f08 100644
--- a/live/src/main/res/layout/item_live_report_head.xml
+++ b/live/src/main/res/layout/item_live_report_head.xml
@@ -1,11 +1,36 @@
-
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+
+
+
+
+
+
+
diff --git a/live/src/main/res/layout/item_live_task.xml b/live/src/main/res/layout/item_live_task.xml
index 0b6f73597..a3d10875a 100644
--- a/live/src/main/res/layout/item_live_task.xml
+++ b/live/src/main/res/layout/item_live_task.xml
@@ -37,7 +37,8 @@
android:background="@drawable/background_6cbe53"
android:paddingStart="14dp"
android:paddingTop="4dp"
- android:paddingEnd="4dp"
+ android:gravity="center"
+ android:paddingEnd="14dp"
android:paddingBottom="4dp"
android:textColor="#FFFFFF"
android:textSize="10sp"
diff --git a/live/src/main/res/layout/item_sys_msg.xml b/live/src/main/res/layout/item_sys_msg.xml
index 2a6f72b00..ee1f783ad 100644
--- a/live/src/main/res/layout/item_sys_msg.xml
+++ b/live/src/main/res/layout/item_sys_msg.xml
@@ -6,10 +6,26 @@
android:layout_height="wrap_content"
android:orientation="vertical">
+
+
+
+
+
-
+
@@ -92,15 +102,15 @@
+ android:src="@mipmap/icon_more" />
@@ -109,10 +119,9 @@
android:layout_width="7dp"
android:layout_height="7dp"
android:layout_alignParentEnd="true"
- android:layout_marginTop="5dp"
- android:layout_marginEnd="5dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginEnd="10dp"
app:cardBackgroundColor="#FF0000"
- android:visibility="gone"
app:cardCornerRadius="20dp" />
diff --git a/live/src/main/res/layout/item_sys_msg_new.xml b/live/src/main/res/layout/item_sys_msg_new.xml
index 91b385ac7..0c7fd2bae 100644
--- a/live/src/main/res/layout/item_sys_msg_new.xml
+++ b/live/src/main/res/layout/item_sys_msg_new.xml
@@ -71,6 +71,7 @@
android:layout_weight="1"
android:maxLines="2"
android:text="標題"
+ android:ellipsize="end"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
diff --git a/live/src/main/res/layout/sim_live_room_anchor_say.xml b/live/src/main/res/layout/sim_live_room_anchor_say.xml
index be2b46051..a82f24eb9 100644
--- a/live/src/main/res/layout/sim_live_room_anchor_say.xml
+++ b/live/src/main/res/layout/sim_live_room_anchor_say.xml
@@ -21,12 +21,12 @@
-
-
-
-
@@ -28,13 +28,13 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
-
-
-
-
-
diff --git a/live/src/main/res/layout/view_live_record_play.xml b/live/src/main/res/layout/view_live_record_play.xml
deleted file mode 100644
index 4d26c8814..000000000
--- a/live/src/main/res/layout/view_live_record_play.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml
index a88d7aeae..892e610a0 100644
--- a/live/src/main/res/layout/view_live_room.xml
+++ b/live/src/main/res/layout/view_live_room.xml
@@ -1492,6 +1492,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ android:layout_gravity="center"
+ app:layout_constraintTop_toBottomOf="@id/title"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ android:layout_marginTop="2dp"
+ />
-
+
立即前往
加入
守護任務
+
+ 舉報結果通知
+ 通知
+ 上傳圖片
+ 舉報內容補充
+ 若您有其它補充信息,請在說明框中描述~
+ 已收到您的補充信息
+ 提交成功
+
+ 點擊\n前往
+ 您有一份獎勵可領取,速速前往!
+ 看了這麼久,送ta一份免費禮物吧 ~ 完成首次送禮任務還可以領取精美獎品!
+ 查看禮物
+ 完成新人任務,可領多重專屬豪禮!
+ 詳情
+ 喜歡主播就關注ta吧~
+ 點擊查看
+