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() {