多人Pk功能撤回

This commit is contained in:
18401019693 2022-12-10 16:20:13 +08:00
parent eef852c283
commit 284b9784d6
17 changed files with 276 additions and 1219 deletions

View File

@ -116,8 +116,9 @@ import java.util.List;
public class LiveAudienceActivity extends LiveActivity { public class LiveAudienceActivity extends LiveActivity {
private static final String TAG = "LiveAudienceActivity"; private static final String TAG = "LiveAudienceActivity";
public static String anyway;
public JSONObject pkInfo; public JSONObject pkInfo;
public static LiveAudienceActivity liveAudienceActivity;
// 竖直滑动 ViewPager // 竖直滑动 ViewPager
private VerticalViewPager verticalViewPager; private VerticalViewPager verticalViewPager;
@ -139,7 +140,7 @@ public class LiveAudienceActivity extends LiveActivity {
private LiveBean mLiveBean; private LiveBean mLiveBean;
//当前直播间下标 //当前直播间下标
private int mCurrentItem, mCurrentPage; private int mCurrentItem, mCurrentPage;
private PortraitLiveManager manager; private static PortraitLiveManager manager;
private int mLastPosition = -1; private int mLastPosition = -1;
private ViewGroup mViewGroup; private ViewGroup mViewGroup;
@ -165,6 +166,7 @@ public class LiveAudienceActivity extends LiveActivity {
protected void main() { protected void main() {
Bus.getOn(this); Bus.getOn(this);
super.main(); super.main();
liveAudienceActivity = this;
CrashSaveBean.getInstance().addEnterRoom(); CrashSaveBean.getInstance().addEnterRoom();
mProcessResultUtil = new ProcessResultUtil(this); mProcessResultUtil = new ProcessResultUtil(this);
Intent intent = getIntent(); Intent intent = getIntent();
@ -215,12 +217,12 @@ public class LiveAudienceActivity extends LiveActivity {
manager.setBackIndex(backIndex); manager.setBackIndex(backIndex);
} }
public LiveRoomPlayViewHolder getmLivePlayViewHolder() { public static LiveRoomPlayViewHolder getmLivePlayViewHolder() {
return manager == null ? null : manager.getmLivePlayViewHolder(); return manager == null ? null : manager.getmLivePlayViewHolder();
} }
public void setCurrentItem(int index) { public static void setCurrentItem(int index) {
manager.mViewPager.setCurrentItem(index); manager.mViewPager.setCurrentItem(index);
} }
@ -1230,11 +1232,7 @@ public class LiveAudienceActivity extends LiveActivity {
} }
break; break;
case LEAVE_PK_SCORE:
if (manager != null) {
manager.upDataPkScore(event.getPkScores(), event.getTime());
}
break;
case PK_TIME_COUNT: case PK_TIME_COUNT:
if (manager != null) { if (manager != null) {
manager.endDRGif(); manager.endDRGif();

View File

@ -5,6 +5,8 @@ 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.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK_RANDOM; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK_RANDOM;
import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView;
import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_dr_pk_nub; import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_dr_pk_nub;
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk; import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk;
import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk_view; import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk_view;
@ -20,6 +22,7 @@ import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -54,9 +57,11 @@ import com.yunbao.common.utils.BitmapUtil;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DateFormatUtil; import com.yunbao.common.utils.DateFormatUtil;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LogUtil; import com.yunbao.common.utils.LogUtil;
import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
@ -305,7 +310,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
if (code == 0) { if (code == 0) {
btn_start_dr_pk.setVisibility(View.VISIBLE); btn_start_dr_pk.setVisibility(View.VISIBLE);
// dr_pk_view.setVisibility(View.VISIBLE); dr_pk_view.setVisibility(View.VISIBLE);
final SocketSendBean msg1 = new SocketSendBean() final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LIVE_DRPK) .param("_method_", SOCKET_LIVE_DRPK)
.param("action", 9) .param("action", 9)
@ -325,7 +330,18 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
@Override @Override
public void onSuccess(Message message) { public void onSuccess(Message message) {
isDRPK = 1; isDRPK = 1;
btn_start_dr_pk_view.setVisibility(View.VISIBLE); btn_start_dr_pk_view.setVisibility(View.VISIBLE);
dr_pk_view.setVisibility(View.VISIBLE);
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);
dr_pk_view.setLayoutParams(params);
mPreView.setLayoutParams(params);
} }
@Override @Override
@ -1438,11 +1454,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLiveRyLinkMicPkPresenter.leaveDRRoom(); mLiveRyLinkMicPkPresenter.leaveDRRoom();
} }
break; break;
case LEAVE_PK_SCORE:
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.upDataPkScore(event.getPkScores(), event.getUid(), event.getTime());
}
break;
case PK_TIME_COUNT: case PK_TIME_COUNT:
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.endDRGif(); mLiveRoomViewHolder.endDRGif();
@ -1451,7 +1463,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
case DISCONNEXT_PK_TIME: case DISCONNEXT_PK_TIME:
if (mLivePushViewHolder != null) { if (mLivePushViewHolder != null) {
mLivePushViewHolder.changeToBig(); mLivePushViewHolder.changeToBig();
mLivePushViewHolder.closeButtonGone();
} }
break; break;
} }

View File

@ -5,7 +5,9 @@ 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_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK; import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView;
import static com.yunbao.live.views.LivePushRyViewHolder.contexts; import static com.yunbao.live.views.LivePushRyViewHolder.contexts;
import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
import static com.yunbao.live.views.LivePushRyViewHolder.rcrtcLiveInfo; import static com.yunbao.live.views.LivePushRyViewHolder.rcrtcLiveInfo;
import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom; import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom;
import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL; import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL;
@ -60,6 +62,7 @@ import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.bean.LivePKUserListBean;
import com.yunbao.live.custom.ProgressTextView; import com.yunbao.live.custom.ProgressTextView;
import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.interfaces.ILiveLinkMicViewHolder;
import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketRyLinkMicPkUtil; import com.yunbao.live.socket.SocketRyLinkMicPkUtil;
import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.socket.SocketSendBean;
@ -110,7 +113,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
private static final int WHAT_PK_WAIT_RECEIVE = 0;//收到pk申请等待 what private static final int WHAT_PK_WAIT_RECEIVE = 0;//收到pk申请等待 what
private static final int WHAT_PK_WAIT_SEND = 1;//发送pk申请等待 what private static final int WHAT_PK_WAIT_SEND = 1;//发送pk申请等待 what
private static final int WHAT_PK_TIME = 2;//pk时间变化 what private static final int WHAT_PK_TIME = 2;//pk时间变化 what
private static final int WHAT_PK_TIME2 = 22;//pk时间变化 what
private static final int LINK_MIC_COUNT_MAX = 10; private static final int LINK_MIC_COUNT_MAX = 10;
private static int PK_TIME_MAX = 60 * 15;//pk时间 15分钟 private static int PK_TIME_MAX = 60 * 15;//pk时间 15分钟
private static final int PK_TIME_MAX_2 = 60;//惩罚时间 1分钟 private static final int PK_TIME_MAX_2 = 60;//惩罚时间 1分钟
@ -144,12 +146,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
private String mSelfStream; private String mSelfStream;
private int mPkTimeFromServer; private int mPkTimeFromServer;
public static TRTCCloud mTRTCCloud1; public static TRTCCloud mTRTCCloud1;
private View detailsView1, detailsView2, detailsView3, detailsView4;
private LinearLayout detailsLinearLayout1, detailsLinearLayout2, detailsLinearLayout3, detailsLinearLayout4;
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
private TextView textPkName1, textPkName2, textPkName3, textPkName4;
private TextView textGrade1, textGrade2, textGrade3, textGrade4;
private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
public LivePushRyViewHolder livePushRyViewHolder; public LivePushRyViewHolder livePushRyViewHolder;
@ -201,7 +197,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
}; };
public LiveRyLinkMicPkPresenter(Context context, LiveRoomPlayViewHolder linkMicViewHolder, boolean isAnchor, View root) { public LiveRyLinkMicPkPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, View root) {
mContext = context; mContext = context;
mIsAnchor = isAnchor; mIsAnchor = isAnchor;
mRoot = root; mRoot = root;
@ -234,50 +230,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
case WHAT_PK_TIME: case WHAT_PK_TIME:
changePkTime(); changePkTime();
break; break;
}
}
};
}
public LiveRyLinkMicPkPresenter(Context context, LivePushRyViewHolder linkMicViewHolder, boolean isAnchor, View root) {
mContext = context;
mIsAnchor = isAnchor;
mRoot = root;
mPkContainer = linkMicViewHolder.getPkContainer();
livePushRyViewHolder = linkMicViewHolder;
mPkTimeString1 = "";
mPkTimeString2 = WordUtil.getString(R.string.live_pk_time_2);
//从本地取数据
String pkTime = CommonAppConfig.getInstance().getAnchorPkTime();
if (!pkTime.isEmpty()) {
try {
int time = Integer.parseInt(pkTime) * 60;
if (time > 0) {
PK_TIME_MAX = time;
}
} catch (Exception e) {
e.printStackTrace();
}
}
Log.d("PK_TIME_MAX", "" + PK_TIME_MAX);
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case WHAT_PK_WAIT_RECEIVE:
onApplyPkWait();
break;
case WHAT_PK_WAIT_SEND:
onSendPkWait();
break;
case WHAT_PK_TIME2:
pkCountdownTimer();
break;
case WHAT_PK_TIME:
changePkTime();
break;
} }
} }
}; };
@ -376,8 +328,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
params.weight = 1; params.weight = 1;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
livePushRyViewHolder.camera.setLayoutParams(params); LivePushRyViewHolder.mPreView.setLayoutParams(params);
livePushRyViewHolder.mPreView1.setLayoutParams(params); LivePushRyViewHolder.mPreView1.setLayoutParams(params);
} }
Log.i("tts", s1); Log.i("tts", s1);
@ -529,36 +481,35 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
RCRTCVideoView remoteView = new RCRTCVideoView(mContext); RCRTCVideoView remoteView = new RCRTCVideoView(mContext);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
livePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.mPreView1.removeAllViews(); LivePushRyViewHolder.dr1_preview.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.mPreView1.addView(remoteView); LivePushRyViewHolder.dr1_preview.addView(remoteView);
} else if (i == 2) { } else if (i == 2) {
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
// RCRTCVideoView remoteView = new RCRTCVideoView(mContext); RCRTCVideoView remoteView = new RCRTCVideoView(mContext);
// ((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
// //todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
// LivePushRyViewHolder.dr2_preview.removeAllViews(); LivePushRyViewHolder.dr2_preview.removeAllViews();
// remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
// LivePushRyViewHolder.dr2_preview.addView(remoteView); LivePushRyViewHolder.dr2_preview.addView(remoteView);
} else if (i == 3) { } else if (i == 3) {
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
// RCRTCVideoView remoteView = new RCRTCVideoView(mContext); RCRTCVideoView remoteView = new RCRTCVideoView(mContext);
// ((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
// //todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
// LivePushRyViewHolder.dr3_preview.removeAllViews(); LivePushRyViewHolder.dr3_preview.removeAllViews();
// remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
// LivePushRyViewHolder.dr3_preview.addView(remoteView); LivePushRyViewHolder.dr3_preview.addView(remoteView);
} else if (i == 4) { } else if (i == 4) {
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
// RCRTCVideoView remoteView = new RCRTCVideoView(mContext); RCRTCVideoView remoteView = new RCRTCVideoView(mContext);
// ((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
// //todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
// LivePushRyViewHolder.dr4_preview.removeAllViews(); LivePushRyViewHolder.dr4_preview.removeAllViews();
// remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
// LivePushRyViewHolder.dr4_preview.addView(remoteView); LivePushRyViewHolder.dr4_preview.addView(remoteView);
} }
//如果要订阅所有远端用户的流保存所有流信息方便后面统一订阅 //如果要订阅所有远端用户的流保存所有流信息方便后面统一订阅
inputStreamList.add(stream); inputStreamList.add(stream);
@ -686,9 +637,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
RCRTCVideoView remoteView = new RCRTCVideoView(contexts); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.mPreView1.removeAllViews(); // LivePushRyViewHolder.mPreView1.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.mPreView1.addView(remoteView); LivePushRyViewHolder.mPreView1.addView(remoteView);
} }
//如果要订阅所有远端用户的流保存所有流信息方便后面统一订阅 //如果要订阅所有远端用户的流保存所有流信息方便后面统一订阅
inputStreamList.add(stream); inputStreamList.add(stream);
@ -766,9 +717,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
params.weight = 1; params.weight = 1;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
livePushRyViewHolder.camera.setLayoutParams(params); LivePushRyViewHolder.mPreView.setLayoutParams(params);
livePushRyViewHolder.mPreView1.setLayoutParams(params); LivePushRyViewHolder.mPreView1.setLayoutParams(params);
livePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE); LivePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE);
final SocketSendBean msg1 = new SocketSendBean() final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK) .param("_method_", SOCKET_LINK_MIC_PK)
@ -810,9 +761,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
params.weight = 1; params.weight = 1;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
livePushRyViewHolder.camera.setLayoutParams(params); LivePushRyViewHolder.mPreView.setLayoutParams(params);
livePushRyViewHolder.mPreView1.setLayoutParams(params); LivePushRyViewHolder.mPreView1.setLayoutParams(params);
livePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE); LivePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE);
LivePushRyViewHolder.btn_close.setVisibility(View.VISIBLE); LivePushRyViewHolder.btn_close.setVisibility(View.VISIBLE);
JSONObject msg1 = new JSONObject(); JSONObject msg1 = new JSONObject();
@ -839,9 +790,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
RCRTCVideoView remoteView = new RCRTCVideoView(contexts); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.mPreView1.removeAllViews(); // LivePushRyViewHolder.mPreView1.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.mPreView1.addView(remoteView); LivePushRyViewHolder.mPreView1.addView(remoteView);
} }
//如果要订阅所有远端用户的流保存所有流信息方便后面统一订阅 //如果要订阅所有远端用户的流保存所有流信息方便后面统一订阅
inputStreamList.add(stream); inputStreamList.add(stream);
@ -1102,7 +1053,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/** /**
* 退出多人PK * 退出多人PK
*/ */
public void leaveDRRoom() { public static void leaveDRRoom() {
Log.e("ry", "退出多人OKKK" + inputStreamList.size()); Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0; isDRPK = 0;
for (int i = 0; i < inputStreamList.size(); i++) { for (int i = 0; i < inputStreamList.size(); i++) {
@ -1172,31 +1123,25 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
} }
leaveHandler.post(leaveRunnable); new Handler(Looper.getMainLooper()).post(new Runnable() {
}
private Handler leaveHandler = new Handler(Looper.getMainLooper());
private Runnable leaveRunnable = new Runnable() {
@Override
public void run() { public void run() {
//恢复全屏画面 //恢复全屏画面
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.topMargin = 0; params.topMargin = 0;
livePushRyViewHolder.camera.setLayoutParams(params); mPreView.setLayoutParams(params);
livePushRyViewHolder.dr_pk_view.setVisibility(View.GONE); dr_pk_view.setVisibility(View.GONE);
inputStreamList.clear(); inputStreamList.clear();
inputStreamList1.clear(); inputStreamList1.clear();
//删除之前其他主播的画面 //删除之前其他主播的画面
livePushRyViewHolder.dr1_preview.removeAllViews(); LivePushRyViewHolder.dr1_preview.removeAllViews();
livePushRyViewHolder.dr3_preview.removeAllViews(); LivePushRyViewHolder.dr2_preview.removeAllViews();
livePushRyViewHolder.cameraPreview3.removeAllViews(); LivePushRyViewHolder.dr3_preview.removeAllViews();
leaveHandler.removeCallbacks(leaveRunnable); LivePushRyViewHolder.dr4_preview.removeAllViews();
livePushRyViewHolder.timeTitle.setVisibility(View.GONE); }
livePushRyViewHolder.mPreView.removeView(detailsView1); });
livePushRyViewHolder.cameraPreview3.setVisibility(View.GONE);
} }
};
/** /**
* 随机PK拒绝对话框 * 随机PK拒绝对话框
@ -1584,28 +1529,15 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() { public void run() {
//把多人PK的View显示出来 //把多人PK的View显示出来
if (livePushRyViewHolder.dr_pk_view.getVisibility() == View.GONE) { if (dr_pk_view.getVisibility() == View.GONE) {
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
params.weight = 1; params.weight = 1;
params.topMargin = DpUtil.dp2px(123); params.topMargin = DpUtil.dp2px(123);
livePushRyViewHolder.dr_pk_view.setLayoutParams(params); dr_pk_view.setLayoutParams(params);
livePushRyViewHolder.camera.setLayoutParams(params); mPreView.setLayoutParams(params);
livePushRyViewHolder.dr_pk_view.setVisibility(View.VISIBLE); 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); Log.e("ry", "多人接受成功" + mApplyUid);
@ -1618,99 +1550,37 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
Log.e("ry", i + "收到" + stream.getMediaType() + "实打实打算" + rcrtcOtherRoom.getRemoteUsers().get(i).getUserId()); Log.e("ry", i + "收到" + stream.getMediaType() + "实打实打算" + rcrtcOtherRoom.getRemoteUsers().get(i).getUserId());
if (stream.getMediaType() == RCRTCMediaType.VIDEO) { if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
if (inputStreamList.size() == 0) { if (inputStreamList.size() == 0) {
livePushRyViewHolder.dr1_preview.setVisibility(View.VISIBLE);
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
RCRTCVideoView remoteView = new RCRTCVideoView(mContext); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.dr1_preview.removeAllViews(); LivePushRyViewHolder.dr1_preview.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.dr1_preview.addView(remoteView); LivePushRyViewHolder.dr1_preview.addView(remoteView);
LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@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) {
}
});
} else if (inputStreamList.size() == 1) { } else if (inputStreamList.size() == 1) {
livePushRyViewHolder.dr3_preview.setVisibility(View.VISIBLE);
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
RCRTCVideoView remoteView = new RCRTCVideoView(mContext); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.dr3_preview.removeAllViews(); LivePushRyViewHolder.dr2_preview.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.dr3_preview.addView(remoteView); LivePushRyViewHolder.dr2_preview.addView(remoteView);
LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@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) { } else if (inputStreamList.size() == 2) {
livePushRyViewHolder.cameraPreview3.setVisibility(View.VISIBLE);
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
RCRTCVideoView remoteView = new RCRTCVideoView(mContext); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.cameraPreview3.removeAllViews(); LivePushRyViewHolder.dr3_preview.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.cameraPreview3.addView(remoteView); LivePushRyViewHolder.dr3_preview.addView(remoteView);
} else if (inputStreamList.size() == 3) {
LiveNetManager.get(mContext).getLiveInfo(uid, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() { //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
@Override RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
public void onSuccess(LiveInfoModel data) { ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); //todo 本demo只演示添加1个远端用户的视图
detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3); LivePushRyViewHolder.dr4_preview.removeAllViews();
linearGrade3 = detailsView3.findViewById(R.id.linear_grade3); remoteView.setScalingType(SCALE_ASPECT_FILL);
textPkName3 = detailsView3.findViewById(R.id.text_pk_name3); LivePushRyViewHolder.dr4_preview.addView(remoteView);
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); inputStreamList.add(stream);
} }
@ -1776,31 +1646,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener); rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener);
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() { 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 (int i = 0; i < rcrtcOtherRoom.getRemoteUsers().size(); i++) {
//遍历远端用户发布的资源列表 //遍历远端用户发布的资源列表
@ -1808,96 +1653,37 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
Log.e("ry111", stream.getMediaType() + ""); Log.e("ry111", stream.getMediaType() + "");
if (stream.getMediaType() == RCRTCMediaType.VIDEO) { if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
if (inputStreamList.size() == 0) { if (inputStreamList.size() == 0) {
livePushRyViewHolder.dr1_preview.setVisibility(View.VISIBLE);
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
RCRTCVideoView remoteView = new RCRTCVideoView(contexts); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.dr1_preview.removeAllViews(); LivePushRyViewHolder.dr1_preview.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.dr1_preview.addView(remoteView); LivePushRyViewHolder.dr1_preview.addView(remoteView);
LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@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) { } else if (inputStreamList.size() == 1) {
livePushRyViewHolder.dr3_preview.setVisibility(View.VISIBLE);
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
RCRTCVideoView remoteView = new RCRTCVideoView(contexts); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.dr3_preview.removeAllViews(); LivePushRyViewHolder.dr2_preview.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.dr3_preview.addView(remoteView); LivePushRyViewHolder.dr2_preview.addView(remoteView);
LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@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) { } else if (inputStreamList.size() == 2) {
livePushRyViewHolder.cameraPreview3.setVisibility(View.VISIBLE);
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
RCRTCVideoView remoteView = new RCRTCVideoView(contexts); RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
((RCRTCVideoInputStream) stream).setVideoView(remoteView); ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
//todo 本demo只演示添加1个远端用户的视图 //todo 本demo只演示添加1个远端用户的视图
livePushRyViewHolder.cameraPreview3.removeAllViews(); LivePushRyViewHolder.dr3_preview.removeAllViews();
remoteView.setScalingType(SCALE_ASPECT_FILL); remoteView.setScalingType(SCALE_ASPECT_FILL);
livePushRyViewHolder.cameraPreview3.addView(remoteView); LivePushRyViewHolder.dr3_preview.addView(remoteView);
} else if (inputStreamList.size() == 3) {
LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() { //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
@Override RCRTCVideoView remoteView = new RCRTCVideoView(contexts);
public void onSuccess(LiveInfoModel data) { ((RCRTCVideoInputStream) stream).setVideoView(remoteView);
detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); //todo 本demo只演示添加1个远端用户的视图
detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3); LivePushRyViewHolder.dr4_preview.removeAllViews();
linearGrade3 = detailsView3.findViewById(R.id.linear_grade3); remoteView.setScalingType(SCALE_ASPECT_FILL);
textPkName3 = detailsView3.findViewById(R.id.text_pk_name3); LivePushRyViewHolder.dr4_preview.addView(remoteView);
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); inputStreamList.add(stream);
@ -1957,9 +1743,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
* @param streams 必须为视频流列表 * @param streams 必须为视频流列表
* @return * @return
*/ */
private RCRTCMixConfig create_Custom_MixConfig(boolean isCrop, List<RCRTCInputStream> streams) { public static RCRTCMixConfig create_Custom_MixConfig(boolean isCrop, List<RCRTCInputStream> streams) {
Log.e("视频合流", streams.toString());
Log.e("视频合流", "视频长度:" + streams.size());
RCRTCMixConfig config = new RCRTCMixConfig(); RCRTCMixConfig config = new RCRTCMixConfig();
//1. 设置自定义合流布局模式 //1. 设置自定义合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.CUSTOM); config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.CUSTOM);
@ -1987,92 +1771,62 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
//(请参照画布和声音配置示例代码) //(请参照画布和声音配置示例代码)
//3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高 //3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高
ArrayList<RCRTCMixConfig.CustomLayoutList.CustomLayout> list = new ArrayList<>(); ArrayList<RCRTCMixConfig.CustomLayoutList.CustomLayout> list = new ArrayList<>();
config.setCustomLayouts(list);
if (streams.size() == 1) {
//user1的视频流 //user1的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
list.add(videoLayout1);
videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video
videoLayout1.setX(0); //X 坐标 videoLayout1.setX(0); //X 坐标
videoLayout1.setY(0); //Y 坐标 videoLayout1.setY(0); //Y 坐标
videoLayout1.setWidth(480); // 视频窗口的宽 videoLayout1.setWidth(480); // 视频窗口的宽
videoLayout1.setHeight(720); // 视频窗口的高 videoLayout1.setHeight(720); // 视频窗口的高
list.add(videoLayout1);
for (int i = 0; i < streams.size(); i++) {
Log.e("tttts,", "a" + i + "cccc" + streams.size());
Log.e("tttts", streams.get(i).getUserId() + "");
if (i == 0) {
//user2的视频流 //user2的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); 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); list.add(videoLayout2);
videoLayout2.setVideoStream(streams.get(i)); // RCRTCStream#MediaType 必须是Video
} 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.setX(480); //X 坐标
videoLayout2.setY(0); //Y 坐标 videoLayout2.setY(0); //Y 坐标
videoLayout2.setWidth(480); // 视频窗口的宽 videoLayout2.setWidth(240); // 视频窗口的宽
videoLayout2.setHeight(360); // 视频窗口的高 videoLayout2.setHeight(360); // 视频窗口的高
list.add(videoLayout2); Log.e("ttt1112", "0" + "VS" + streams.get(i).getUserId());
} else if (i == 1) {
//user3的视频流 //user3的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout3 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); 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); list.add(videoLayout3);
videoLayout3.setVideoStream(streams.get(i)); // RCRTCStream#MediaType 必须是Video
} else if (streams.size() == 3) { videoLayout3.setX(720); //X 坐标
//user1的视频流 videoLayout3.setY(0); //Y 坐标
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); videoLayout3.setWidth(240); // 视频窗口的宽
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); // 视频窗口的高 videoLayout3.setHeight(360); // 视频窗口的高
list.add(videoLayout3); Log.e("ttt1112", "1" + "VS" + streams.get(i).getUserId());
} else if (i == 2) {
//user3的视频流 //user3的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout4 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); 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); list.add(videoLayout4);
videoLayout4.setVideoStream(streams.get(i)); // RCRTCStream#MediaType 必须是Video
videoLayout4.setX(480); //X 坐标
videoLayout4.setY(360); //Y 坐标
videoLayout4.setWidth(240); // 视频窗口的宽
videoLayout4.setHeight(360); // 视频窗口的高
Log.e("ttt1112", "2" + "VS" + streams.get(i).getUserId());
} else if (i == 3) {
//user3的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout4 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
list.add(videoLayout4);
videoLayout4.setVideoStream(streams.get(i)); // RCRTCStream#MediaType 必须是Video
videoLayout4.setX(720); //X 坐标
videoLayout4.setY(360); //Y 坐标
videoLayout4.setWidth(240); // 视频窗口的宽
videoLayout4.setHeight(360); // 视频窗口的高
Log.e("ttt1112", "3" + "VS" + streams.get(i).getUserId());
}
} }
config.setCustomLayouts(list);
return config; return config;
} }
@ -2196,8 +1950,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer); mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
mLiveLinkMicPkViewHolder.addToParent(); mLiveLinkMicPkViewHolder.addToParent();
mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor); mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
if (mContext instanceof LiveAudienceActivity) { if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkview(); LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
} }
} }
@ -2315,8 +2069,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void run() { public void run() {
// try { // try {
// Thread.sleep(4000); // Thread.sleep(4000);
if (mContext instanceof LiveAudienceActivity) { if (mContext instanceof LiveAudienceActivity && LiveAudienceActivity.getmLivePlayViewHolder() != null) {
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkEndview(); LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
} }
// } catch (InterruptedException e) { // } catch (InterruptedException e) {
// e.printStackTrace(); // e.printStackTrace();
@ -2353,7 +2107,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
if (mIsAnchor) { if (mIsAnchor) {
((LiveRyAnchorActivity) mContext).setPkBtnVisible(true); ((LiveRyAnchorActivity) mContext).setPkBtnVisible(true);
} }
// ToastUtil.show(R.string.link_mic_refuse_pk); ToastUtil.show(R.string.link_mic_refuse_pk);
} }
/** /**
@ -2419,224 +2173,4 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void setSelfStream(String selfStream) { public void setSelfStream(String selfStream) {
mSelfStream = 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) {
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;
pkCountdownTimer();
}
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();
}
}
} }

View File

@ -3,6 +3,8 @@ package com.yunbao.live.socket;
import static com.blankj.utilcode.util.SnackbarUtils.dismiss; import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
import static com.blankj.utilcode.util.ViewUtils.runOnUiThread; import static com.blankj.utilcode.util.ViewUtils.runOnUiThread;
import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK; import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom;
import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom; import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom;
import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot; import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
@ -278,58 +280,41 @@ public class SocketRyClient {
} }
//收到对方同意多人PK邀请 //收到对方同意多人PK邀请
else if (action3 == 2) { else if (action3 == 2) {
// UserBean u = new UserBean(); UserBean u = new UserBean();
//// u.setUserNiceName(map.getString("uname")); // u.setUserNiceName(map.getString("uname"));
// u.setId(map.getString("uid")); u.setId(map.getString("uid"));
// mListener.onLinkDRMicPkApplyOk(u); mListener.onLinkDRMicPkApplyOk(u);
} else if (action3 == 6) {//开始Pk } else if (action3 == 6) {
if (LiveRoomViewHolder.mHandler != null) { if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
} }
// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time")); 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) { if (livePushRyViewHolder == null) {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
);
} }
} else if (action3 == 5) { } else if (action3 == 5) {
// endDRGif(); // endDRGif();
LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE); LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE);
if (LiveRyAnchorActivity.mLiveAnchorViewHolder != null) { if (LiveRyAnchorActivity.mLiveAnchorViewHolder != null) {
dr_pk_view.setVisibility(View.GONE);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
params.topMargin = 0; params.topMargin = 0;
Bus.get().post(new LiveAudienceEvent() LivePushRyViewHolder.mPreView.setLayoutParams(params);
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM)); leaveDRRoom();
isDRPK = 0; isDRPK = 0;
} else { } else {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview(); LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW)
);
} }
//創建了多人房間 //創建了多人房間
} else if (action3 == 3) { } else if (action3 == 3) {
/* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) { if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
}*/ }
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
);
isDRPK = 1; isDRPK = 1;
} else if (action3 == 10) { } else if (action3 == 10) {
if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) { if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
);
} }
} }
@ -916,12 +901,7 @@ public class SocketRyClient {
mListener.onSendGift(receiveGiftBean); mListener.onSendGift(receiveGiftBean);
} }
if (map.getIntValue("drpk_status") == 1) { if (map.getIntValue("drpk_status") == 1) {
Bus.get().post(new LiveAudienceEvent() LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE)
.setPkScores(map.getJSONArray("userlist"))
.setUid(mLiveUid)
.setTime(0));
// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);
} }
} }
@ -1070,8 +1050,16 @@ public class SocketRyClient {
break; break;
case 5://PK时候断开连麦的回调 case 5://PK时候断开连麦的回调
if (rtcRoom != null) { if (rtcRoom != null) {
Bus.get().post(new LiveAudienceEvent() if (LivePushRyViewHolder.mPreView1 != null) {
.setType(LiveAudienceEvent.LiveAudienceType.DISCONNEXT_PK_TIME)); LivePushRyViewHolder.mPreView1.removeAllViews();
LivePushRyViewHolder.mPreView1.setVisibility(View.GONE);
isDRPK = 0;
leaveDRRoom();
}
LivePushRyViewHolder.btn_close.setVisibility(View.GONE);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
params.topMargin = 0;
LivePushRyViewHolder.mPreView.setLayoutParams(params);
//断开连麦 //断开连麦
HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout") HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout")
.execute(new HttpCallback() { .execute(new HttpCallback() {

View File

@ -32,10 +32,9 @@ public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushV
protected ViewGroup mLeftContainer; protected ViewGroup mLeftContainer;
protected ViewGroup mRightContainer; protected ViewGroup mRightContainer;
protected ViewGroup mPkContainer; protected ViewGroup mPkContainer;
public FrameLayout mPreView, mPreView1, cameraPreview3, dr1_preview, dr2_preview, dr3_preview, dr4_preview; public static FrameLayout mPreView,mPreView1,dr1_preview,dr2_preview,dr3_preview,dr4_preview;
public ImageView leave; public static ImageView leave;
protected boolean mOpenCamera;//是否选择了相机 protected boolean mOpenCamera;//是否选择了相机
public LinearLayout camera;
//倒计时 //倒计时
protected TextView mCountDownText; protected TextView mCountDownText;

View File

@ -12,23 +12,18 @@ import android.media.AudioManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.EasyFloat;
import com.lzy.okserver.OkDownload; import com.lzy.okserver.OkDownload;
import com.lzy.okserver.download.DownloadTask; import com.lzy.okserver.download.DownloadTask;
@ -38,23 +33,19 @@ import com.tencent.live2.V2TXLivePlayerObserver;
import com.tencent.live2.impl.V2TXLivePlayerImpl; import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView; import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.bean.CrashSaveBean; import com.yunbao.common.bean.CrashSaveBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.event.LiveAudienceEvent;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -156,7 +147,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mLoading = findViewById(R.id.loading); mLoading = findViewById(R.id.loading);
mLoading2 = findViewById(R.id.loading2); mLoading2 = findViewById(R.id.loading2);
mCover = (ImageView) findViewById(R.id.cover); mCover = (ImageView) findViewById(R.id.cover);
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
vHeight = mScreenWdith * 720 / 960; vHeight = mScreenWdith * 720 / 960;
@ -436,7 +426,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
public void setViewUP(int i) { public static void setViewUP(int i) {
if (mVideoView == null) return; if (mVideoView == null) return;
Log.e("", "整理" + i); Log.e("", "整理" + i);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
@ -542,18 +532,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params.addRule(RelativeLayout.ALIGN_TOP); params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout(); mVideoView.requestLayout();
} }
if (detailsView != null) {
mVideoView.removeView(detailsView);
detailsView = null;
}
} }
public void removeDetailView(){
if (detailsView != null) {
mVideoView.removeView(detailsView);
detailsView = null;
}
}
@Override @Override
public ViewGroup getSmallContainer() { public ViewGroup getSmallContainer() {
@ -1040,131 +1020,4 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
}); });
} }
private int mPkTimeCount = 0;
private Handler countdownHandler = new Handler();
private View detailsView = null;
private FrameLayout timeTitle;
private TextView textTime;
private TextView textPkName1, textPkName2, textPkName3, textPkName4;
private TextView textGrade1, textGrade2, textGrade3, textGrade4;
private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
/**
* PK倒计时
*/
public void upDataPkScore(JSONArray pkScores, int time) {
if (detailsView == null) {
detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
timeTitle = detailsView.findViewById(R.id.time_title);
textTime = detailsView.findViewById(R.id.text_time);
linearGrade1 = detailsView.findViewById(R.id.lin_pk1);
linearGrade2 = detailsView.findViewById(R.id.lin_pk2);
linearGrade3 = detailsView.findViewById(R.id.lin_pk3);
linearGrade4 = detailsView.findViewById(R.id.lin_pk4);
textPkName1 = detailsView.findViewById(R.id.text_pk_name1);
textPkName2 = detailsView.findViewById(R.id.text_pk_name2);
textPkName3 = detailsView.findViewById(R.id.text_pk_name3);
textPkName4 = detailsView.findViewById(R.id.text_pk_name4);
textGrade1 = detailsView.findViewById(R.id.text_grade1);
textGrade2 = detailsView.findViewById(R.id.text_grade2);
textGrade3 = detailsView.findViewById(R.id.text_grade3);
textGrade4 = detailsView.findViewById(R.id.text_grade4);
imageGrade1 = detailsView.findViewById(R.id.image_grade1);
imageGrade2 = detailsView.findViewById(R.id.image_grade2);
imageGrade3 = detailsView.findViewById(R.id.image_grade3);
imageGrade4 = detailsView.findViewById(R.id.image_grade4);
linearGrade1.setVisibility(View.GONE);
linearGrade2.setVisibility(View.GONE);
linearGrade3.setVisibility(View.GONE);
linearGrade4.setVisibility(View.GONE);
mVideoView.addView(detailsView);
}
for (int i = 0; i < pkScores.size(); i++) {
JSONObject score = pkScores.getJSONObject(i);
String userNiceName = score.getString("user_nicename");
long userScore = score.getLong("score");
int resScore = R.mipmap.icon_livepk_no1;
if (userScore == 0 && !score.containsKey("paiming")) {
resScore = R.mipmap.icon_livepk_no1;
} else {
if (score.containsKey("paiming")) {
int ranking = score.getIntValue("paiming");
switch (ranking) {
case 1:
resScore = R.mipmap.icon_livepk_no1;
break;
case 2:
resScore = R.mipmap.icon_livepk_no2;
break;
case 3:
resScore = R.mipmap.icon_livepk_no3;
break;
case 4:
resScore = R.mipmap.icon_livepk_no4;
break;
}
}
}
if (i == 0) {
linearGrade1.setVisibility(View.VISIBLE);
textPkName1.setText(userNiceName);
ImgLoader.display(mContext, resScore, imageGrade1);
textGrade1.setText(String.valueOf(userScore));
} else if (i == 1) {
linearGrade2.setVisibility(View.VISIBLE);
textPkName2.setText(userNiceName);
ImgLoader.display(mContext, resScore, imageGrade2);
textGrade2.setText(String.valueOf(userScore));
} else if (i == 2) {
linearGrade4.setVisibility(View.VISIBLE);
textPkName4.setText(userNiceName);
ImgLoader.display(mContext, resScore, imageGrade4);
textGrade4.setText(String.valueOf(userScore));
} else if (i == 3) {
linearGrade3.setVisibility(View.VISIBLE);
textPkName3.setText(userNiceName);
ImgLoader.display(mContext, resScore, imageGrade3);
textGrade3.setText(String.valueOf(userScore));
}
}
if (time > 0) {
mPkTimeCount = time;
timeTitle.setVisibility(View.VISIBLE);
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
}
}
private Runnable countdownRunnable = new Runnable() {
@Override
public void run() {
mPkTimeCount--;
if (mPkTimeCount > 0) {//
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
} else {
timeTitle.setVisibility(View.GONE);
countdownHandler.removeCallbacks(countdownRunnable);
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
}
}
};
/**
* 获取下一秒钟的时间
*/
private long getNextSecondTime() {
long now = SystemClock.uptimeMillis();
return now + (1000 - now % 1000);
}
} }

View File

@ -37,7 +37,6 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
@ -92,13 +91,11 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
public TencentTRTCBeautyManager tencentTRTCBeautyManager; public TencentTRTCBeautyManager tencentTRTCBeautyManager;
public static Context contexts; public static Context contexts;
public static TextView btn_close; public static TextView btn_close;
public LinearLayout dr_pk_view; public static LinearLayout dr_pk_view;
public static RCRTCRoom rtcRoom; public static RCRTCRoom rtcRoom;
public static RCRTCLiveInfo rcrtcLiveInfo; public static RCRTCLiveInfo rcrtcLiveInfo;
private ViewGroup liveActivityContainer; private ViewGroup liveActivityContainer;
public FrameLayout timeTitle;
public TextView textTime;
public LivePushRyViewHolder(Context context, ViewGroup parentView) { public LivePushRyViewHolder(Context context, ViewGroup parentView) {
super(context, parentView); super(context, parentView);
@ -364,19 +361,14 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
public void init() { public void init() {
super.init(); super.init();
mPreView = (FrameLayout) findViewById(R.id.camera_preview); mPreView = (FrameLayout) findViewById(R.id.camera_preview);
camera = (LinearLayout) findViewById(R.id.camera);
mPreView1 = (FrameLayout) findViewById(R.id.camera_preview1); mPreView1 = (FrameLayout) findViewById(R.id.camera_preview1);
cameraPreview3 = (FrameLayout) findViewById(R.id.camera_preview3);
dr1_preview = (FrameLayout) findViewById(R.id.dr1_preview); dr1_preview = (FrameLayout) findViewById(R.id.dr1_preview);
dr2_preview = (FrameLayout) findViewById(R.id.dr2_preview); dr2_preview = (FrameLayout) findViewById(R.id.dr2_preview);
dr3_preview = (FrameLayout) findViewById(R.id.dr3_preview); dr3_preview = (FrameLayout) findViewById(R.id.dr3_preview);
dr4_preview = (FrameLayout) findViewById(R.id.dr4_preview); dr4_preview = (FrameLayout) findViewById(R.id.dr4_preview);
leave = (ImageView) findViewById(R.id.leave); leave = (ImageView) findViewById(R.id.leave);
dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view); 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); dr_pk_view.setVisibility(View.GONE);
cameraPreview3.setVisibility(View.GONE);
btn_close = (TextView) findViewById(R.id.btn_close); btn_close = (TextView) findViewById(R.id.btn_close);
mMainHandler = new Handler(Looper.getMainLooper()); mMainHandler = new Handler(Looper.getMainLooper());
btn_close.setOnClickListener(new View.OnClickListener() { btn_close.setOnClickListener(new View.OnClickListener() {
@ -416,7 +408,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
mPreView1.setVisibility(View.GONE); mPreView1.setVisibility(View.GONE);
inputStreamList.clear(); inputStreamList.clear();
inputStreamList1.clear(); inputStreamList1.clear();
changeToBig();
} }
}); });
} }
@ -622,28 +613,19 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
params.width = mPreView.getWidth() / 2; params.width = mPreView.getWidth() / 2;
params.height = DpUtil.dp2px(250); params.height = DpUtil.dp2px(250);
params.topMargin = DpUtil.dp2px(130); params.topMargin = DpUtil.dp2px(130);
camera.setLayoutParams(params); mPreView.setLayoutParams(params);
} }
} }
@Override @Override
public void changeToBig() { public void changeToBig() {
if (camera != null) { if (mPreView != null) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) camera.getLayoutParams(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mPreView.getLayoutParams();
params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.width = ViewGroup.LayoutParams.MATCH_PARENT;
params.height = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT;
params.topMargin = 0; params.topMargin = 0;
camera.setLayoutParams(params); mPreView.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 @Override

View File

@ -4,7 +4,9 @@ import static com.yunbao.live.activity.LiveActivity.mLiveUid;
import static com.yunbao.live.activity.LiveRyAnchorActivity.PKing; import static com.yunbao.live.activity.LiveRyAnchorActivity.PKing;
import static com.yunbao.live.activity.LiveRyAnchorActivity.pk_nub; import static com.yunbao.live.activity.LiveRyAnchorActivity.pk_nub;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.START_MESSAGE; import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.START_MESSAGE;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE; import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -141,8 +143,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
.execute(new HttpCallback() { .execute(new HttpCallback() {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
Bus.get().post(new LiveAudienceEvent() leaveDRRoom();
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM));
PKing = false; PKing = false;
} }

View File

@ -22,7 +22,6 @@ import androidx.drawerlayout.widget.DrawerLayout;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils; import com.blankj.utilcode.util.GsonUtils;
import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.EasyFloat;
@ -130,7 +129,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//侧滑布局 //侧滑布局
// private DrawerLayout drawerLayout; // private DrawerLayout drawerLayout;
//直播间拆分布局 //直播间拆分布局
private LivePlayRyViewHolder mLivePlayViewHolder; private LiveRoomPlayViewHolder mLivePlayViewHolder;
//头部布局 //头部布局
public LiveRoomViewHolder mLiveRoomViewHolder; public LiveRoomViewHolder mLiveRoomViewHolder;
//底部布局 //底部布局
@ -296,7 +295,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mask.setVisibility(View.VISIBLE); mask.setVisibility(View.VISIBLE);
mLivePlayViewHolder.setLiveBean(mLiveBean); mLivePlayViewHolder.setLiveBean(mLiveBean);
mLivePlayViewHolder.removeDetailView();
mLivePlayViewHolder.setCover(mLiveBean.getAvatar()); mLivePlayViewHolder.setCover(mLiveBean.getAvatar());
mLivePlayViewHolder.play(mLiveBean.getPull()); mLivePlayViewHolder.play(mLiveBean.getPull());
mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() { mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() {
@ -487,7 +485,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) { if (data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) {
mLivePlayViewHolder.setViewUP(1); LivePlayRyViewHolder.setViewUP(1);
} }
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
@ -495,7 +493,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
} }
if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了 if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了
mLivePlayViewHolder.setViewUP(2); LivePlayRyViewHolder.setViewUP(2);
//pk排名数据 //pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class); LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
@ -509,7 +507,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.pkHandler = true; mLiveRoomViewHolder.pkHandler = true;
mLiveRoomViewHolder.initPkRank(null); mLiveRoomViewHolder.initPkRank(null);
} }
mLivePlayViewHolder.setViewUP(3); LivePlayRyViewHolder.setViewUP(3);
//pk排名数据 //pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class); LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
@ -524,8 +522,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.initPkRank(null); mLiveRoomViewHolder.initPkRank(null);
} }
mLivePlayViewHolder.setViewUP(4); LivePlayRyViewHolder.setViewUP(4);
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
mLiveRoomViewHolder.UpPkBar(pkInfo.getJSONArray("userlist"), mLiveBean.getUid(), pkInfo.getIntValue("drpk_time"));
} }
//守护相关 //守护相关
mLiveGuardInfo = new LiveGuardInfo(); mLiveGuardInfo = new LiveGuardInfo();
@ -1736,31 +1735,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mViewPager.setCanScroll(enableScroll); mViewPager.setCanScroll(enableScroll);
} }
/**
* 用户端多人Pk
*
* @param pkScores
* @param time
*/
public void upDataPkScore(JSONArray pkScores, int time) {
if (mLivePlayViewHolder != null) {
String liveId = mLiveBean.getUid();
JSONObject liveModel = null;
//调整数据
int index = 0;
for (int i = 0; i < pkScores.size(); i++) {
JSONObject score = pkScores.getJSONObject(i);
if (TextUtils.equals(score.getString("id"), liveId)) {
liveModel = score;
index = i;
}
}
pkScores.remove(index);
pkScores.add(0, liveModel);
mLivePlayViewHolder.upDataPkScore(pkScores, time);
}
}
public void endDRGif() { public void endDRGif() {
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#60000000" />
<corners android:radius="7.17dp" />
</shape>

View File

@ -1,252 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--左上-->
<LinearLayout
android:id="@+id/lin_pk1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:id="@+id/linear_grade1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5.33dp"
android:layout_marginTop="4.67dp"
android:background="@drawable/background_pk_time"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/image_grade1"
android:layout_width="10.67dp"
android:layout_height="10.67dp"
android:layout_marginStart="2.67dp"
android:layout_marginTop="1.67dp"
android:layout_marginEnd="4.33dp"
android:layout_marginBottom="1.67dp"
android:src="@mipmap/icon_livepk_no1" />
<TextView
android:id="@+id/text_grade1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6.76dp"
android:text="000"
android:textColor="@color/white"
android:textSize="8sp" />
</LinearLayout>
<TextView
android:id="@+id/text_pk_name1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5.33dp"
android:layout_marginTop="3.3dp"
android:background="@drawable/background_pk_time"
android:maxLines="1"
android:ellipsize="end"
android:maxWidth="50dp"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"
android:paddingBottom="4.33dp"
android:text="我方"
android:textColor="@color/white"
android:textSize="8sp" />
</LinearLayout>
<!--右上-->
<LinearLayout
android:id="@+id/lin_pk2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:gravity="end"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:id="@+id/linear_grade2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4.67dp"
android:layout_marginEnd="5.33dp"
android:background="@drawable/background_pk_time"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/image_grade2"
android:layout_width="10.67dp"
android:layout_height="10.67dp"
android:layout_marginStart="2.67dp"
android:layout_marginTop="1.67dp"
android:layout_marginEnd="4.33dp"
android:layout_marginBottom="1.67dp"
android:src="@mipmap/icon_livepk_no2" />
<TextView
android:id="@+id/text_grade2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6.76dp"
android:text="000"
android:textColor="@color/white"
android:textSize="8sp" />
</LinearLayout>
<TextView
android:id="@+id/text_pk_name2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.3dp"
android:layout_marginEnd="5.33dp"
android:background="@drawable/background_pk_time"
android:ellipsize="end"
android:maxWidth="50dp"
android:maxLines="1"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"
android:paddingBottom="4.33dp"
android:text="我方"
android:textColor="@color/white"
android:textSize="8sp" />
</LinearLayout>
<!--左下-->
<LinearLayout
android:id="@+id/lin_pk3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/text_pk_name3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5.33dp"
android:layout_marginBottom="3.3dp"
android:background="@drawable/background_pk_time"
android:maxLines="1"
android:ellipsize="end"
android:maxWidth="50dp"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"
android:paddingBottom="4.33dp"
android:text="我方"
android:textColor="@color/white"
android:textSize="8sp" />
<LinearLayout
android:id="@+id/linear_grade3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5.33dp"
android:layout_marginBottom="4.67dp"
android:background="@drawable/background_pk_time"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/image_grade3"
android:layout_width="10.67dp"
android:layout_height="10.67dp"
android:layout_marginStart="2.67dp"
android:layout_marginTop="1.67dp"
android:layout_marginEnd="4.33dp"
android:layout_marginBottom="1.67dp"
android:src="@mipmap/icon_livepk_no3" />
<TextView
android:id="@+id/text_grade3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6.76dp"
android:text="000"
android:textColor="@color/white"
android:textSize="8sp" />
</LinearLayout>
</LinearLayout>
<!--右下-->
<LinearLayout
android:id="@+id/lin_pk4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:gravity="end"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/text_pk_name4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5.33dp"
android:layout_marginBottom="3.3dp"
android:background="@drawable/background_pk_time"
android:maxLines="1"
android:ellipsize="end"
android:maxWidth="50dp"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"
android:paddingBottom="4.33dp"
android:text="我方"
android:textColor="@color/white"
android:textSize="8sp" />
<LinearLayout
android:id="@+id/linear_grade4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5.33dp"
android:layout_marginBottom="4.67dp"
android:background="@drawable/background_pk_time"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/image_grade4"
android:layout_width="10.67dp"
android:layout_height="10.67dp"
android:layout_marginStart="2.67dp"
android:layout_marginTop="1.67dp"
android:layout_marginEnd="4.33dp"
android:layout_marginBottom="1.67dp"
android:src="@mipmap/icon_livepk_no3" />
<TextView
android:id="@+id/text_grade4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6.76dp"
android:text="000"
android:textColor="@color/white"
android:textSize="8sp" />
</LinearLayout>
</LinearLayout>
<!--PK时间-->
<FrameLayout
android:id="@+id/time_title"
android:layout_width="70dp"
android:layout_height="18dp"
android:layout_gravity="center_horizontal"
android:background="@mipmap/live_pk_time_bg"
android:visibility="gone">
<TextView
android:id="@+id/text_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/pk_time"
android:textColor="@color/white"
android:textSize="10sp" />
</FrameLayout>
</FrameLayout>

View File

@ -1,35 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> android:orientation="horizontal">
<LinearLayout
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout <FrameLayout
android:id="@+id/camera_preview" android:id="@+id/camera_preview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent"/>
android:layout_weight="1" />
<FrameLayout
android:id="@+id/camera_preview3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<FrameLayout <FrameLayout
android:id="@+id/camera_preview1" android:id="@+id/camera_preview1"
@ -37,13 +22,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"/> android:visibility="gone"/>
<LinearLayout <LinearLayout android:id="@+id/dr_pk_view"
android:id="@+id/dr_pk_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/camera_preview"
android:layout_marginTop="130dp" android:layout_marginTop="130dp"
android:orientation="vertical" android:orientation="vertical">
android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -53,16 +37,16 @@
<FrameLayout <FrameLayout
android:id="@+id/dr1_preview" android:id="@+id/dr1_preview"
android:layout_width="0dp" android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent"
android:background="@mipmap/live_icon_vacancy"/> android:background="@mipmap/live_icon_vacancy"/>
<FrameLayout <FrameLayout
android:id="@+id/dr2_preview" android:id="@+id/dr2_preview"
android:layout_width="0dp" android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent"
android:background="@mipmap/live_icon_vacancy"/> android:background="@mipmap/live_icon_vacancy"/>
</LinearLayout> </LinearLayout>
@ -75,14 +59,14 @@
<FrameLayout <FrameLayout
android:id="@+id/dr3_preview" android:id="@+id/dr3_preview"
android:layout_width="0dp" android:layout_width="100dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@mipmap/live_icon_vacancy"/> android:background="@mipmap/live_icon_vacancy"/>
<FrameLayout <FrameLayout
android:id="@+id/dr4_preview" android:id="@+id/dr4_preview"
android:layout_width="0dp" android:layout_width="100dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@mipmap/live_icon_vacancy"/> android:background="@mipmap/live_icon_vacancy"/>
@ -92,6 +76,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout
@ -100,40 +85,46 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
</FrameLayout> </FrameLayout>
<LinearLayout <LinearLayout
android:visibility="gone"
android:id="@+id/layout_surface" android:id="@+id/layout_surface"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clickable="true" android:clickable="true"
android:orientation="vertical" android:orientation="vertical">
android:visibility="gone">
<SurfaceView <SurfaceView
android:id="@+id/surface_view" android:id="@+id/surface_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
/>
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout
android:id="@+id/pk_container" android:id="@+id/pk_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="270dp" android:layout_height="270dp"
android:layout_marginTop="130dp"> android:layout_marginTop="130dp"
>
<com.yunbao.live.custom.MyFrameLayout4 <com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/left_container" android:id="@+id/left_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="20dp" /> android:layout_marginBottom="20dp"
/>
<com.yunbao.live.custom.MyFrameLayout4 <com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/right_container" android:id="@+id/right_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="right" android:layout_gravity="right"
android:layout_marginBottom="20dp" /> android:layout_marginBottom="20dp"
/>
</FrameLayout> </FrameLayout>
@ -142,27 +133,27 @@
android:id="@+id/small_container" android:id="@+id/small_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="120dp" android:layout_marginBottom="120dp"
app:mfl3_ratio="0.25" /> app:mfl3_ratio="0.25"
/>
<TextView <TextView android:id="@+id/btn_close"
android:id="@+id/btn_close"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:layout_marginTop="120dp" android:layout_marginTop="120dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:background="@drawable/background_dedede" android:layout_alignParentRight="true"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:paddingRight="8dp"
android:paddingBottom="5dp"
android:text="結束連麥" android:text="結束連麥"
android:textColor="@color/color_white"
android:textSize="13sp" android:textSize="13sp"
android:visibility="gone" /> android:textColor="@color/color_white"
android:visibility="gone"
android:background="@drawable/background_dedede"/>
<ImageView <ImageView
@ -170,26 +161,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:scaleType="centerCrop"
android:src="@mipmap/zslk" android:src="@mipmap/zslk"
android:visibility="gone" /> android:visibility="gone"
android:scaleType="centerCrop"/>
<FrameLayout
android:id="@+id/time_title"
android:layout_width="60dp"
android:layout_height="16.67dp"
android:layout_centerHorizontal="true"
android:background="@mipmap/live_pk_time_bg"
android:visibility="gone">
<TextView
android:id="@+id/text_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/pk_time"
android:textColor="@color/white"
android:textSize="8sp" />
<!-- 详情-->
</FrameLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -36,7 +36,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/start_pk" android:text="開始PK"
android:textColor="#ffffffff" android:textColor="#ffffffff"
android:textSize="12sp" /> android:textSize="12sp" />
@ -44,7 +44,7 @@
android:id="@+id/btn_dr_pk_nub" android:id="@+id/btn_dr_pk_nub"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/number_of_remaining_times" android:text="剩餘次數:0"
android:textColor="#ffe1e1e1" android:textColor="#ffe1e1e1"
android:textSize="8sp" /> android:textSize="8sp" />
@ -67,7 +67,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="@string/invite_anchor" android:text="邀請
主播"
android:textColor="#ffffffff" android:textColor="#ffffffff"
android:textSize="10sp" /> android:textSize="10sp" />
@ -86,7 +87,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="@string/end_pk" android:text="結束
PK"
android:textColor="#ffb1b1b1" android:textColor="#ffb1b1b1"
android:textSize="10sp" /> android:textSize="10sp" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB