From 2e6efc69e8f17edcf64e1ac69dc515ebfe02a963 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Mon, 9 Jan 2023 22:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=92=AD=E6=94=BE=E5=99=A83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../live/utils/LiveExoPlayerManager.java | 10 ++++---- .../live/views/LivePlayRyViewHolder.java | 24 +++++++------------ 2 files changed, 13 insertions(+), 21 deletions(-) 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 2372f156a..24898ddc1 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java @@ -39,11 +39,11 @@ public class LiveExoPlayerManager { public LiveExoPlayerManager(Context mContext) { DefaultLoadControl control = new DefaultLoadControl.Builder() .setPrioritizeTimeOverSizeThresholds(false) - .setBackBuffer(15_000, true) - .setBufferDurationsMs(150, - 5_000, - 50, - 100) + .setBackBuffer(120_000, true) + .setBufferDurationsMs(500, + 60_000, + 150, + 200) .build(); player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build(); player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build(); 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 2e0e1a5b9..586dd7575 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -244,7 +244,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { @Override public void setLiveEnterRoomNewModel(EnterRoomNewModel 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); if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) { mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); - if (landscape == VIDEO_VERTICAL) { + if (landscape == VIDEO_VERTICAL && !isPk) { 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"); } } else if (!url.contains(videoFps[0] + ".flv")) { @@ -311,7 +311,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void switchStream(String url, int playModel) { srcUrl = url; 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")) { mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); if (landscape == VIDEO_VERTICAL && !isPk) { @@ -342,7 +342,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { @Override public void switchStreamPk(boolean 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; mPlayer.setViewResizeMode(false); String url; @@ -502,24 +503,15 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { Log.i("收收收", landscape + ""); isPk = false; tmpPk = false; + switchStreamPk(false); if (landscape == 2) { Log.i("收到socket--->", "还原9:16"); - String url = srcUrl; - switchStreamPk(false); - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.topMargin = 0; mVideoView.requestLayout(); } 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(); params.height = vHeight; params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); @@ -1166,7 +1158,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { Player.Listener.super.onIsPlayingChanged(isPlaying); if (isPlaying) { hideCover(); - Log.i(TAG, "onIsPlayingChanged: 开始播放"); + Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = "+waitNextUrl); OkDownload.getInstance().startAll(); if (loadingListener != null) { loadingListener.onPlayer();