新增播放定时器,播放后10秒未播放就重新加载播放

This commit is contained in:
zlzw 2023-01-14 14:30:34 +08:00
parent 1bbab7ac9e
commit 5d7cff6707

View File

@ -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,6 +366,7 @@ public class LiveExoPlayerManager {
player1.release();
player2.release();
}
public void clearUrl() {
url = "";
}