From 518e57ee44a84b9c39d6f1954efa9f1d7ede6c19 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 10 Jan 2023 15:35:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B7=B2=E7=BB=8F=E5=9C=A8?= =?UTF-8?q?=E5=A4=9A=E4=BA=BAPK=E6=97=B6=E4=B8=8D=E5=86=8D=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=BB=98=E8=AE=A4=E6=B5=81=E5=88=86=E8=BE=A8=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/utils/LiveExoPlayerManager.java | 14 ++++++++++---- .../yunbao/live/views/LivePlayRyViewHolder.java | 15 +++++++++------ 2 files changed, 19 insertions(+), 10 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 24898ddc1..3eb0dea13 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java @@ -34,7 +34,7 @@ public class LiveExoPlayerManager { private int playBufferIndex = 0;//卡顿计数器 private final Handler handler; private static double log_buffer_time = 0, log_buffer_max_time; - private String url; + private String url=""; public LiveExoPlayerManager(Context mContext) { DefaultLoadControl control = new DefaultLoadControl.Builder() @@ -71,6 +71,10 @@ public class LiveExoPlayerManager { mainView.requestLayout(); } + public boolean isViewResizeModeToPhone() { + return mainView.getResizeMode() == AspectRatioFrameLayout.RESIZE_MODE_ZOOM; + } + private void setAnalyticsListener() { player1.addAnalyticsListener(new AnalyticsListener() { @Override @@ -240,6 +244,7 @@ public class LiveExoPlayerManager { * @param url 地址 */ public void startUrl(String url) { + if(url.equals(this.url))return; Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode()); this.url = url; isSwitchUrl = true; @@ -260,7 +265,8 @@ public class LiveExoPlayerManager { * @param url 地址 */ public void switchUrl(String url) { - Log.i(TAG, "switchUrl: " + url); + if(url.equals(this.url))return; + Log.i(TAG, "switchUrl: " + url +" src : "+this.url); this.url = url; playBufferIndex = 0; isSwitchUrl = true; @@ -322,8 +328,8 @@ public class LiveExoPlayerManager { } public String getUrl() { - if(url==null){ - url=""; + if (url == null) { + url = ""; } return url; } 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 586dd7575..941b827f2 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -283,9 +283,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) { mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); if (landscape == VIDEO_VERTICAL && !isPk) { - waitNextUrl = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv"); + url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv"); } else if (landscape == VIDEO_HORIZONTAL || isPk) { - waitNextUrl = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv"); + url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv"); } } else if (!url.contains(videoFps[0] + ".flv")) { mPlayer.setViewResizeMode(false); @@ -342,9 +342,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { @Override public void switchStreamPk(boolean isPk) { super.switchStreamPk(isPk); - Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2" + this.isPk); + Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2 = " + this.isPk); + if(this.isPk&&tmpPk)return; if (isPk && !tmpPk || this.isPk) { - tmpPk = true; mPlayer.setViewResizeMode(false); String url; if (PLAY_MODEL != -1) { @@ -352,8 +352,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } else { url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv"); } - waitNextUrl = url; + if (!tmpPk) { + waitNextUrl = url; + } mPlayer.switchUrl(srcUrl); + tmpPk = true; } else if (!isPk) { tmpPk = false; if (landscape == VIDEO_VERTICAL && PLAY_MODEL != -1) { @@ -1158,7 +1161,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { Player.Listener.super.onIsPlayingChanged(isPlaying); if (isPlaying) { hideCover(); - Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = "+waitNextUrl); + Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = " + waitNextUrl); OkDownload.getInstance().startAll(); if (loadingListener != null) { loadingListener.onPlayer();