From 5d7cff6707c2adb767528718d381741a3c103da3 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Sat, 14 Jan 2023 14:30:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=92=AD=E6=94=BE=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E5=99=A8=EF=BC=8C=E6=92=AD=E6=94=BE=E5=90=8E10?= =?UTF-8?q?=E7=A7=92=E6=9C=AA=E6=92=AD=E6=94=BE=E5=B0=B1=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/utils/LiveExoPlayerManager.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 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 d074070ee..bbcddb532 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java @@ -46,8 +46,8 @@ public class LiveExoPlayerManager { 150, 200) .build(); - player1 = new ExoPlayer.Builder(mContext).build(); - player2 = new ExoPlayer.Builder(mContext).build(); + player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build(); + player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build(); player1.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING); player2.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING); @@ -158,6 +158,7 @@ public class LiveExoPlayerManager { mainView.setPlayer(player1); status = MODEL_PLAY1; isSwitchUrl = false; + handler.removeCallbacks(buffRunnable); if (getNextPlayer().isPlaying()) { getNextPlayer().stop(); } @@ -229,6 +230,7 @@ public class LiveExoPlayerManager { if (getNextPlayer().isPlaying()) { getNextPlayer().stop(); } + handler.removeCallbacks(buffRunnable); isSwitchUrl = false; if (listener != null) { listener.onIsPlayingChanged(true); @@ -268,6 +270,7 @@ public class LiveExoPlayerManager { public void startUrl(String url) { if (url != null && url.equals(this.url)) return; Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode()); + handler.removeCallbacks(buffRunnable); this.url = url; isSwitchUrl = true; playBufferIndex = 0; @@ -279,6 +282,7 @@ public class LiveExoPlayerManager { getNowPlayer().setMediaItem(createMediaItem(url)); getNowPlayer().prepare(); getNowPlayer().play(); + handler.postDelayed(buffRunnable, 10000); } /** @@ -340,6 +344,8 @@ public class LiveExoPlayerManager { public void replay() { Log.i(TAG, "replay: 重载播放"); + getNowPlayer().stop(); + getNextPlayer().stop(); String tmp = url; url = null; startUrl(tmp); @@ -360,8 +366,9 @@ public class LiveExoPlayerManager { player1.release(); player2.release(); } - public void clearUrl(){ - url=""; + + public void clearUrl() { + url = ""; } public String getUrl() {