zb端多人Pk合流完成,Pk结束完成

This commit is contained in:
18401019693 2022-12-08 17:29:29 +08:00
parent 7ebd935eba
commit 4cd4939c58
11 changed files with 236 additions and 155 deletions

View File

@ -10,9 +10,9 @@ ext {
manifestPlaceholders = [
//
// serverHost : "https://napi.yaoulive.com",
serverHost : "https://napi.yaoulive.com",
//
serverHost : "https://ceshi.yaoulive.com",
// serverHost : "https://ceshi.yaoulive.com",
//
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -1359,6 +1359,11 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLiveRyLinkMicPkPresenter.upDataPkScore(event.getPkScores(), event.getUid(), event.getTime());
}
break;
case PK_TIME_COUNT:
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.endDRGif();
}
break;
}
}

View File

@ -227,8 +227,9 @@ public class LiveAudienceEvent extends BaseModel {
LINK_MIC_CLOSE(43, "主播关闭连麦房"),
SOCKET_LIVE_DRPK_SET_PK_VIEW(44, "setPkview"),
SOCKET_LIVE_DRPK_SET_PK_END_VIEW(45, "setPkEndview"),
LEAVE_DR_ROOM(44, "结束多人PK"),
LEAVE_PK_SCORE(45, "PK排名");
LEAVE_DR_ROOM(46, "结束多人PK"),
LEAVE_PK_SCORE(47, "PK排名"),
PK_TIME_COUNT(48, "多人PK结束");
private int type;
private String name;

View File

@ -99,6 +99,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
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_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 int PK_TIME_MAX = 60 * 15;//pk时间 15分钟
private static final int PK_TIME_MAX_2 = 60;//惩罚时间 1分钟
@ -222,6 +223,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
case WHAT_PK_TIME:
changePkTime();
break;
}
}
};
@ -259,8 +261,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
case WHAT_PK_WAIT_SEND:
onSendPkWait();
break;
case WHAT_PK_TIME:
changePkTime();
case WHAT_PK_TIME2:
pkCountdownTimer();
break;
}
}
@ -1211,7 +1213,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
livePushRyViewHolder.dr3_preview.removeAllViews();
livePushRyViewHolder.cameraPreview3.removeAllViews();
leaveHandler.removeCallbacks(leaveRunnable);
livePushRyViewHolder.timeTitle.setVisibility(View.GONE);
livePushRyViewHolder.mPreView.removeView(detailsView1);
}
};
@ -1255,16 +1258,16 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void onSuccess(int code, String msg, String[] info) {
Log.i(TAG, "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
JSONObject datas = JSONObject.parseObject(info[0]);
boolean agree=true;
boolean agree = true;
if (datas.getIntValue("pk_num_day") <= 0) {
ToastUtil.show("多人PK次数已用完");
agree=false;
agree = false;
}
boolean finalAgree = agree;
rtcRoom.getLocalUser().responseJoinOtherRoom(mApplyUid, mApplyUid, agree, true, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
if(finalAgree == true){
if (finalAgree == true) {
HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("roomid", u.getId())
@ -1842,7 +1845,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
* @param streams 必须为视频流列表
* @return
*/
public static RCRTCMixConfig create_Custom_MixConfig(boolean isCrop, List<RCRTCInputStream> streams) {
private RCRTCMixConfig create_Custom_MixConfig(boolean isCrop, List<RCRTCInputStream> streams) {
Log.e("视频合流", streams.toString());
Log.e("视频合流", "视频长度:" + streams.size());
RCRTCMixConfig config = new RCRTCMixConfig();
//1. 设置自定义合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.CUSTOM);
@ -1870,7 +1875,27 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
//(请参照画布和声音配置示例代码)
//3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高
ArrayList<RCRTCMixConfig.CustomLayoutList.CustomLayout> list = new ArrayList<>();
config.setCustomLayouts(list);
if (streams.size() == 1) {
//user1的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video
videoLayout1.setX(0); //X 坐标
videoLayout1.setY(0); //Y 坐标
videoLayout1.setWidth(480); // 视频窗口的宽
videoLayout1.setHeight(720); // 视频窗口的高
list.add(videoLayout1);
//user2的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video
videoLayout2.setX(480); //X 坐标
videoLayout2.setY(0); //Y 坐标
videoLayout2.setWidth(480); // 视频窗口的宽
videoLayout2.setHeight(720); // 视频窗口的高
list.add(videoLayout2);
} else if (streams.size() == 2) {
//user1的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
list.add(videoLayout1);
@ -1880,52 +1905,62 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
videoLayout1.setWidth(480); // 视频窗口的宽
videoLayout1.setHeight(720); // 视频窗口的高
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的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
list.add(videoLayout2);
videoLayout2.setVideoStream(streams.get(i)); // RCRTCStream#MediaType 必须是Video
videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video
videoLayout2.setX(480); //X 坐标
videoLayout2.setY(0); //Y 坐标
videoLayout2.setWidth(480); // 视频窗口的宽
videoLayout2.setHeight(720); // 视频窗口的高
Log.e("ttt1112", "0" + "VS" + streams.get(i).getUserId());
} else if (i == 1) {
videoLayout2.setHeight(360); // 视频窗口的高
list.add(videoLayout2);
//user3的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout3 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
list.add(videoLayout3);
videoLayout3.setVideoStream(streams.get(i)); // RCRTCStream#MediaType 必须是Video
videoLayout3.setX(720); //X 坐标
videoLayout3.setY(0); //Y 坐标
videoLayout3.setWidth(240); // 视频窗口的宽
videoLayout3.setVideoStream(streams.get(1)); // RCRTCStream#MediaType 必须是Video
videoLayout3.setX(480); //X 坐标
videoLayout3.setY(360); //Y 坐标
videoLayout3.setWidth(480); // 视频窗口的宽
videoLayout3.setHeight(360); // 视频窗口的高
Log.e("ttt1112", "1" + "VS" + streams.get(i).getUserId());
list.add(videoLayout3);
} else if (streams.size() == 3) {
//user1的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video
videoLayout1.setX(0); //X 坐标
videoLayout1.setY(0); //Y 坐标
videoLayout1.setWidth(480); // 视频窗口的宽
videoLayout1.setHeight(720); // 视频窗口的高
list.add(videoLayout1);
//user2的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video
videoLayout2.setX(480); //X 坐标
videoLayout2.setY(0); //Y 坐标
videoLayout2.setWidth(480); // 视频窗口的宽
videoLayout2.setHeight(360); // 视频窗口的高
list.add(videoLayout2);
//user3的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout3 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
videoLayout3.setVideoStream(streams.get(1)); // RCRTCStream#MediaType 必须是Video
videoLayout3.setX(480); //X 坐标
videoLayout3.setY(360); //Y 坐标
videoLayout3.setWidth(480); // 视频窗口的宽
videoLayout3.setHeight(360); // 视频窗口的高
list.add(videoLayout3);
} else if (i == 2) {
//user3的视频流
RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout4 = new RCRTCMixConfig.CustomLayoutList.CustomLayout();
list.add(videoLayout4);
videoLayout4.setVideoStream(streams.get(i)); // RCRTCStream#MediaType 必须是Video
videoLayout4.setX(480); //X 坐标
videoLayout4.setVideoStream(streams.get(2)); // RCRTCStream#MediaType 必须是Video
videoLayout4.setX(0); //X 坐标
videoLayout4.setY(360); //Y 坐标
videoLayout4.setWidth(240); // 视频窗口的宽
videoLayout4.setWidth(480); // 视频窗口的宽
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;
}
@ -2285,6 +2320,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
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) {
@ -2464,4 +2503,28 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
/**
* 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

@ -428,7 +428,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
}
public static void setViewUP(int i) {
public void setViewUP(int i) {
if (mVideoView == null) return;
Log.e("", "整理" + i);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();

View File

@ -94,6 +94,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
private ViewGroup liveActivityContainer;
public FrameLayout timeTitle;
public TextView textTime;
public LivePushRyViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@ -344,6 +345,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
leave = (ImageView) findViewById(R.id.leave);
dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
timeTitle = (FrameLayout) findViewById(R.id.time_title);
textTime = (TextView) findViewById(R.id.text_time);
dr_pk_view.setVisibility(View.GONE);
cameraPreview3.setVisibility(View.GONE);
btn_close = (TextView) findViewById(R.id.btn_close);

View File

@ -269,7 +269,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
static RoundedImageView mic_ico1;
static RoundedImageView mic_ico2;
static GifImageView dr_pk_end_gif;
private GifImageView dr_pk_end_gif;
private SVGAImageView gift_svga;
public static Handler mHandler;
@ -442,11 +442,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
endDRGif();
// endDRGif();
}
}
public static void endDRGif() {
public void endDRGif() {
dr_pk_end_gif.setVisibility(View.VISIBLE);
RequestOptions options = new RequestOptions().skipMemoryCache(true);//配置
Glide.with(Contexts).asGif()
.apply(options)//应用配置

View File

@ -129,7 +129,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//侧滑布局
// private DrawerLayout drawerLayout;
//直播间拆分布局
private LiveRoomPlayViewHolder mLivePlayViewHolder;
private LivePlayRyViewHolder mLivePlayViewHolder;
//头部布局
public LiveRoomViewHolder mLiveRoomViewHolder;
//底部布局
@ -480,16 +480,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (!TextUtils.isEmpty(pkPull) && mLiveLinkMicAnchorPresenter != null) {
mLiveLinkMicAnchorPresenter.onLinkMicAnchorPlayUrl(pkUid, pkPull);
}
} else {
if (mLivePlayViewHolder instanceof LivePlayTxViewHolder) {
((LivePlayTxViewHolder) mLivePlayViewHolder).setAnchorLinkMic(true, 0);
}
}
}
if (data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) {
LivePlayRyViewHolder.setViewUP(1);
mLivePlayViewHolder.setViewUP(1);
}
if (mLiveRoomViewHolder != null) {
@ -497,7 +493,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了
LivePlayRyViewHolder.setViewUP(2);
mLivePlayViewHolder.setViewUP(2);
//pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
@ -511,7 +507,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.pkHandler = true;
mLiveRoomViewHolder.initPkRank(null);
}
LivePlayRyViewHolder.setViewUP(3);
mLivePlayViewHolder.setViewUP(3);
//pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
@ -526,7 +522,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.initPkRank(null);
}
LivePlayRyViewHolder.setViewUP(4);
mLivePlayViewHolder.setViewUP(4);
mLiveRoomViewHolder.UpPkBar(pkInfo.getJSONArray("userlist"), mLiveBean.getUid(), pkInfo.getIntValue("drpk_time"));
}
@ -1563,9 +1559,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void onLinkMicTxAccEvent(LinkMicTxAccEvent e) {
if (mLivePlayViewHolder != null && mLivePlayViewHolder instanceof LivePlayTxViewHolder) {
((LivePlayTxViewHolder) mLivePlayViewHolder).onLinkMicTxAccEvent(e.isLinkMic());
}
}
/**
@ -1574,9 +1568,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* @param linkMic true开始连麦 false断开连麦
*/
public void onLinkMicTxAnchor(boolean linkMic) {
if (mLivePlayViewHolder != null && mLivePlayViewHolder instanceof LivePlayTxViewHolder) {
((LivePlayTxViewHolder) mLivePlayViewHolder).setAnchorLinkMic(linkMic, 5000);
}
}
/**

View File

@ -47,6 +47,9 @@
android:layout_marginStart="5.33dp"
android:layout_marginTop="3.3dp"
android:background="@drawable/background_pk_time"
android:ellipsize="end"
android:maxEms="6"
android:maxLines="1"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"
@ -102,6 +105,9 @@
android:layout_marginTop="3.3dp"
android:layout_marginEnd="5.33dp"
android:background="@drawable/background_pk_time"
android:ellipsize="end"
android:maxEms="6"
android:maxLines="1"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"
@ -126,6 +132,9 @@
android:layout_marginStart="5.33dp"
android:layout_marginBottom="3.3dp"
android:background="@drawable/background_pk_time"
android:ellipsize="end"
android:maxEms="6"
android:maxLines="1"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"
@ -181,6 +190,9 @@
android:layout_marginEnd="5.33dp"
android:layout_marginBottom="3.3dp"
android:background="@drawable/background_pk_time"
android:ellipsize="end"
android:maxEms="6"
android:maxLines="1"
android:paddingStart="6dp"
android:paddingTop="4.33dp"
android:paddingEnd="6dp"

View File

@ -183,6 +183,7 @@
android:visibility="gone">
<TextView
android:id="@+id/text_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"

View File

@ -1541,12 +1541,6 @@
android:textColor="@color/white"
android:textSize="12sp" />
<pl.droidsonroids.gif.GifImageView
android:id="@+id/dr_pk_end_gif"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<LinearLayout
android:layout_width="match_parent"
@ -2282,4 +2276,14 @@
android:layout_height="30dp"
android:visibility="visible" />
</LinearLayout>
<pl.droidsonroids.gif.GifImageView
android:id="@+id/dr_pk_end_gif"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_marginTop="160dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:src="@mipmap/drpkend"
android:visibility="gone" />
</RelativeLayout>