update 清晰度切换

This commit is contained in:
zlzw 2022-12-29 13:13:05 +08:00
parent 00c3e0cb77
commit 5db84c1e61
7 changed files with 96 additions and 7 deletions

View File

@ -127,8 +127,10 @@ public class CustomDrawerPopupView extends DrawerPopupView {
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.system_notice), new ViewClicksAntiShake.ViewClicksCallBack() { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.system_notice), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
// dismiss(); dismiss();
if (callBack != null) {
callBack.systemNotice();
}
} }

View File

@ -12,16 +12,28 @@ import com.yunbao.common.R;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class LiveClarityCustomPopup extends BottomPopupView implements View.OnClickListener { 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 int selectClarity = 1;
private RelativeLayout lineSd, lineHd, lineFhd; private RelativeLayout lineSd, lineHd, lineFhd;
private ImageView iconSd, iconHd, iconFhd; private ImageView iconSd, iconHd, iconFhd;
private int banSelect;
public int getSelectClarity() { public int getSelectClarity() {
return selectClarity; 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) { public LiveClarityCustomPopup(@NonNull Context context, int selectClarity) {
super(context); super(context);
if (selectClarity == -1) {
selectClarity = 0;
}
this.selectClarity = selectClarity; this.selectClarity = selectClarity;
} }
@ -75,6 +87,12 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
selectClarity(selectClarity); selectClarity(selectClarity);
dismiss(); dismiss();
}); });
if (banSelect == BAN_720) {
lineFhd.setEnabled(false);
lineHd.setEnabled(false);
} else if (banSelect == BAN_1080) {
lineFhd.setEnabled(false);
}
} }
/** /**

View File

@ -864,7 +864,7 @@ public class LiveAudienceActivity extends LiveActivity {
public void systemNotice() { public void systemNotice() {
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()
.setBean(mLiveBean) .setBean(mLiveBean)
.setType(LiveAudienceEvent.LiveAudienceType.NOTICE)); .setType(LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO));
} }
@Override @Override

View File

@ -256,7 +256,8 @@ public class LiveAudienceEvent extends BaseModel {
UP_PK_TWO(51, "PK头像信息"), UP_PK_TWO(51, "PK头像信息"),
CUSTOM_FULL_SERVICE_NOTIFY(51, "全服通知"), CUSTOM_FULL_SERVICE_NOTIFY(51, "全服通知"),
CHANGE_VIEW(52, "更改连胜位置"), CHANGE_VIEW(52, "更改连胜位置"),
UPDATA_ROBOT(53, "更新机器人消息"); UPDATA_ROBOT(53, "更新机器人消息"),
LIVE_VIDEO(54, "画质选择");
private int type; private int type;
private String name; private String name;

View File

@ -134,6 +134,7 @@ public class LiveExoPlayerManager {
} }
public void switchUrl(String url) { public void switchUrl(String url) {
Log.i(TAG, "switchUrl: "+url);
isSwitchUrl = true; isSwitchUrl = true;
getNextPlayer().setMediaItem(createMediaItem(url)); getNextPlayer().setMediaItem(createMediaItem(url));
getNextPlayer().prepare(); getNextPlayer().prepare();

View File

@ -30,9 +30,13 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Tracks; import com.google.android.exoplayer2.Tracks;
import com.google.android.exoplayer2.video.VideoSize; 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.lzf.easyfloat.EasyFloat;
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.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;
@ -40,9 +44,11 @@ import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.ScreenDimenUtil;
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.common.views.LiveClarityCustomPopup;
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 com.yunbao.live.utils.LiveExoPlayerManager; import com.yunbao.live.utils.LiveExoPlayerManager;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -132,6 +138,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override @Override
public void init() { public void init() {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
Bus.getOn(this);
mRoot = (ViewGroup) findViewById(R.id.root); mRoot = (ViewGroup) findViewById(R.id.root);
mSmallContainer = (ViewGroup) findViewById(R.id.small_container); mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
mLeftContainer = (ViewGroup) findViewById(R.id.left_container); mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
@ -390,10 +397,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
});*/ });*/
MediaItem item = createMediaItem(url); MediaItem item = createMediaItem(url);
if (mPlayer.isPlaying()) { if (mPlayer.isPlaying()) {
ToastUtil.show("set 2"); ToastUtil.show("set 2 画质="+playModel);
mPlayer.switchUrl(url); mPlayer.switchUrl(url);
} else { } else {
ToastUtil.show("set 1"); ToastUtil.show("set 1 画质="+playModel);
mPlayer.startUrl(url); mPlayer.startUrl(url);
} }
/* if (mPlayer.isPlaying()) { /* if (mPlayer.isPlaying()) {
@ -431,6 +438,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mPlayer.stop(); mPlayer.stop();
mPlayer.release(); mPlayer.release();
} }
Bus.getOff(this);
EventBus.getDefault().unregister(this);
L.e(TAG, "release------->"); 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();
}
}
/** /**
* 把观众转换成主播 * 把观众转换成主播
*/ */

View File

@ -20,7 +20,7 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
public static int PLAY_MODEL = PLAY_MODEL_DEF; 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[] 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"}; public static final String[] videoFps = new String[]{"_24", "_30"};
OnMicCallback onMicCallback;//连麦回调 OnMicCallback onMicCallback;//连麦回调