新增直播播放缓冲超过2秒就刷新播放流

This commit is contained in:
zlzw 2023-01-11 18:06:51 +08:00
parent 1244010c3d
commit 5f2dda021a

View File

@ -46,8 +46,8 @@ public class LiveExoPlayerManager {
150,
200)
.build();
player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
player1 = new ExoPlayer.Builder(mContext).build();
player2 = new ExoPlayer.Builder(mContext).build();
player1.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
player2.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
@ -115,6 +115,7 @@ public class LiveExoPlayerManager {
public void run() {
playBufferIndex = 0;
listener.onPlaybackStateChanged(Player.STATE_BUFFERING);
replay();
}
};
@ -134,7 +135,7 @@ public class LiveExoPlayerManager {
} else if (playbackState == Player.STATE_BUFFERING && status == MODEL_PLAY1 && !isSwitchUrl) {
if (listener != null) {
if (playBufferIndex++ == 0) {
handler.postDelayed(buffRunnable, 1000);
handler.postDelayed(buffRunnable, 2000);
}
}
}
@ -205,7 +206,7 @@ public class LiveExoPlayerManager {
} else if (playbackState == Player.STATE_BUFFERING && status == MODEL_PLAY2 && !isSwitchUrl) {
if (listener != null) {
if (playBufferIndex++ == 0) {
handler.postDelayed(buffRunnable, 1000);
handler.postDelayed(buffRunnable, 2000);
}
}
}
@ -337,6 +338,7 @@ public class LiveExoPlayerManager {
}
public void replay() {
Log.i(TAG, "replay: 重载播放");
String tmp = url;
url = null;
startUrl(tmp);