调整播放器3

This commit is contained in:
Yutousama 2023-01-09 22:36:51 +08:00
parent e2761049e5
commit 2e6efc69e8
2 changed files with 13 additions and 21 deletions

View File

@ -39,11 +39,11 @@ public class LiveExoPlayerManager {
public LiveExoPlayerManager(Context mContext) { public LiveExoPlayerManager(Context mContext) {
DefaultLoadControl control = new DefaultLoadControl.Builder() DefaultLoadControl control = new DefaultLoadControl.Builder()
.setPrioritizeTimeOverSizeThresholds(false) .setPrioritizeTimeOverSizeThresholds(false)
.setBackBuffer(15_000, true) .setBackBuffer(120_000, true)
.setBufferDurationsMs(150, .setBufferDurationsMs(500,
5_000, 60_000,
50, 150,
100) 200)
.build(); .build();
player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build(); player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build(); player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();

View File

@ -244,7 +244,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override @Override
public void setLiveEnterRoomNewModel(EnterRoomNewModel data) { public void setLiveEnterRoomNewModel(EnterRoomNewModel data) {
super.setLiveEnterRoomNewModel(data); super.setLiveEnterRoomNewModel(data);
isPk=data.getEnterRoomInfo().getIsconnection().equals("1"); isPk = data.getEnterRoomInfo().getIsconnection().equals("1");
} }
/** /**
@ -282,9 +282,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Log.i(TAG, "play" + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape" + videoLandscape); Log.i(TAG, "play" + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape" + videoLandscape);
if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) { if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
if (landscape == VIDEO_VERTICAL) { if (landscape == VIDEO_VERTICAL && !isPk) {
waitNextUrl = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv"); waitNextUrl = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
} else if (landscape == VIDEO_HORIZONTAL) { } else if (landscape == VIDEO_HORIZONTAL || isPk) {
waitNextUrl = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv"); waitNextUrl = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
} }
} else if (!url.contains(videoFps[0] + ".flv")) { } else if (!url.contains(videoFps[0] + ".flv")) {
@ -311,7 +311,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void switchStream(String url, int playModel) { public void switchStream(String url, int playModel) {
srcUrl = url; srcUrl = url;
PLAY_MODEL = playModel; PLAY_MODEL = playModel;
Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape + " ispk = " + isPk+" bean = "+roomModel.getEnterRoomInfo().getIsconnection()); Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape + " ispk = " + isPk + " bean = " + roomModel.getEnterRoomInfo().getIsconnection());
if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) { if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
if (landscape == VIDEO_VERTICAL && !isPk) { if (landscape == VIDEO_VERTICAL && !isPk) {
@ -342,7 +342,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override @Override
public void switchStreamPk(boolean isPk) { public void switchStreamPk(boolean isPk) {
super.switchStreamPk(isPk); super.switchStreamPk(isPk);
if (isPk && !tmpPk) { Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2" + this.isPk);
if (isPk && !tmpPk || this.isPk) {
tmpPk = true; tmpPk = true;
mPlayer.setViewResizeMode(false); mPlayer.setViewResizeMode(false);
String url; String url;
@ -502,24 +503,15 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Log.i("收收收", landscape + ""); Log.i("收收收", landscape + "");
isPk = false; isPk = false;
tmpPk = false; tmpPk = false;
switchStreamPk(false);
if (landscape == 2) { if (landscape == 2) {
Log.i("收到socket--->", "还原916"); Log.i("收到socket--->", "还原916");
String url = srcUrl;
switchStreamPk(false);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0; params.topMargin = 0;
mVideoView.requestLayout(); mVideoView.requestLayout();
} else { } else {
String url = srcUrl;
if (PLAY_MODEL != -1) {
url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
}
mPlayer.setViewResizeMode(false);
mPlayer.switchUrl(url);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight; params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
@ -1166,7 +1158,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Player.Listener.super.onIsPlayingChanged(isPlaying); Player.Listener.super.onIsPlayingChanged(isPlaying);
if (isPlaying) { if (isPlaying) {
hideCover(); hideCover();
Log.i(TAG, "onIsPlayingChanged: 开始播放"); Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = "+waitNextUrl);
OkDownload.getInstance().startAll(); OkDownload.getInstance().startAll();
if (loadingListener != null) { if (loadingListener != null) {
loadingListener.onPlayer(); loadingListener.onPlayer();