From 5db84c1e61ce5ff6ee0764a3ec592a9d2870f17c Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 29 Dec 2022 13:13:05 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=B8=85=E6=99=B0=E5=BA=A6=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/views/CustomDrawerPopupView.java | 6 +- .../common/views/LiveClarityCustomPopup.java | 18 +++++ .../live/activity/LiveAudienceActivity.java | 2 +- .../yunbao/live/event/LiveAudienceEvent.java | 3 +- .../live/utils/LiveExoPlayerManager.java | 1 + .../live/views/LivePlayRyViewHolder.java | 71 ++++++++++++++++++- .../live/views/LiveRoomPlayViewHolder.java | 2 +- 7 files changed, 96 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java index ab2199dbd..c5c23580c 100644 --- a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java +++ b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java @@ -127,8 +127,10 @@ public class CustomDrawerPopupView extends DrawerPopupView { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.system_notice), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { -// dismiss(); - + dismiss(); + if (callBack != null) { + callBack.systemNotice(); + } } diff --git a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java index 13ec97ca9..edf5ec993 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java @@ -12,16 +12,28 @@ import com.yunbao.common.R; import com.yunbao.common.views.weight.ViewClicksAntiShake; public class LiveClarityCustomPopup extends BottomPopupView implements View.OnClickListener { + public static final int BAN_720 = 1; + public static final int BAN_1080 = 2; private int selectClarity = 1; private RelativeLayout lineSd, lineHd, lineFhd; private ImageView iconSd, iconHd, iconFhd; + private int banSelect; public int getSelectClarity() { return selectClarity; } + public LiveClarityCustomPopup(@NonNull Context context, int selectClarity, int banSelect) { + super(context); + this.selectClarity = selectClarity; + this.banSelect = banSelect; + } + public LiveClarityCustomPopup(@NonNull Context context, int selectClarity) { super(context); + if (selectClarity == -1) { + selectClarity = 0; + } this.selectClarity = selectClarity; } @@ -75,6 +87,12 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl selectClarity(selectClarity); dismiss(); }); + if (banSelect == BAN_720) { + lineFhd.setEnabled(false); + lineHd.setEnabled(false); + } else if (banSelect == BAN_1080) { + lineFhd.setEnabled(false); + } } /** diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 135739ce7..d817ab129 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -864,7 +864,7 @@ public class LiveAudienceActivity extends LiveActivity { public void systemNotice() { Bus.get().post(new LiveAudienceEvent() .setBean(mLiveBean) - .setType(LiveAudienceEvent.LiveAudienceType.NOTICE)); + .setType(LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO)); } @Override diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index 8e5daccd3..204abebf2 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -256,7 +256,8 @@ public class LiveAudienceEvent extends BaseModel { UP_PK_TWO(51, "PK头像信息"), CUSTOM_FULL_SERVICE_NOTIFY(51, "全服通知"), CHANGE_VIEW(52, "更改连胜位置"), - UPDATA_ROBOT(53, "更新机器人消息"); + UPDATA_ROBOT(53, "更新机器人消息"), + LIVE_VIDEO(54, "画质选择"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java index 2ccc0d15e..9e0bf571b 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java @@ -134,6 +134,7 @@ public class LiveExoPlayerManager { } public void switchUrl(String url) { + Log.i(TAG, "switchUrl: "+url); isSwitchUrl = true; getNextPlayer().setMediaItem(createMediaItem(url)); getNextPlayer().prepare(); diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 4e2e01176..253d33e02 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -30,9 +30,13 @@ import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Tracks; import com.google.android.exoplayer2.video.VideoSize; +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.core.BasePopupView; +import com.lxj.xpopup.interfaces.XPopupCallback; import com.lzf.easyfloat.EasyFloat; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.L; @@ -40,9 +44,11 @@ import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.LiveClarityCustomPopup; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.utils.LiveExoPlayerManager; import org.greenrobot.eventbus.EventBus; @@ -132,6 +138,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { @Override public void init() { EventBus.getDefault().register(this); + Bus.getOn(this); mRoot = (ViewGroup) findViewById(R.id.root); mSmallContainer = (ViewGroup) findViewById(R.id.small_container); mLeftContainer = (ViewGroup) findViewById(R.id.left_container); @@ -390,10 +397,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { });*/ MediaItem item = createMediaItem(url); if (mPlayer.isPlaying()) { - ToastUtil.show("set 2"); + ToastUtil.show("set 2 画质="+playModel); mPlayer.switchUrl(url); } else { - ToastUtil.show("set 1"); + ToastUtil.show("set 1 画质="+playModel); mPlayer.startUrl(url); } /* if (mPlayer.isPlaying()) { @@ -431,6 +438,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { mPlayer.stop(); mPlayer.release(); } + Bus.getOff(this); + EventBus.getDefault().unregister(this); L.e(TAG, "release------->"); } @@ -782,6 +791,64 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onOpenDrawer(LiveAudienceEvent event) { + if (event.getType() == LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO) { + int ban = PLAY_MODEL == PLAY_MODEL_720 ? LiveClarityCustomPopup.BAN_1080 : PLAY_MODEL == PLAY_MODEL_480 ? LiveClarityCustomPopup.BAN_720 : 0; + LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, PLAY_MODEL); + new XPopup.Builder(mContext) + .setPopupCallback(new XPopupCallback() { + @Override + public void onCreated(BasePopupView popupView) { + + } + + @Override + public void beforeShow(BasePopupView popupView) { + + } + + @Override + public void onShow(BasePopupView popupView) { + + } + + @Override + public void onDismiss(BasePopupView popupView) { + int selectClarity = liveClarityCustomPopup.getSelectClarity(); + play(srcUrl, selectClarity); + } + + @Override + public void beforeDismiss(BasePopupView popupView) { + + } + + @Override + public boolean onBackPressed(BasePopupView popupView) { + return false; + } + + @Override + public void onKeyBoardStateChanged(BasePopupView popupView, int height) { + + } + + @Override + public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) { + + } + + @Override + public void onClickOutside(BasePopupView popupView) { + + } + }) + .asCustom(liveClarityCustomPopup) + .show(); + } + } + /** * 把观众转换成主播 */ diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java index b9ee9a46c..ffb150b0b 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java @@ -20,7 +20,7 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL public static int PLAY_MODEL = PLAY_MODEL_DEF; public static final String[] videoRatioHorizontal = new String[]{"_640_480", "_1280_720", "_1920_1080", "_180_180"}; - public static final String[] videoRatioVertical = new String[]{"_480_640", "_1280_960", "_1080_1920", "_180_180"}; + public static final String[] videoRatioVertical = new String[]{"_480_640", "_720_1280", "_1080_1920", "_180_180"}; public static final String[] videoFps = new String[]{"_24", "_30"}; OnMicCallback onMicCallback;//连麦回调