diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index 7f7a445980a..e86c560c5dd 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -61,6 +61,7 @@ import androidx.media3.exoplayer.util.EventLogger import androidx.media3.session.MediaSession import androidx.media3.ui.* import androidx.media3.ui.CaptionStyleCompat.* +import androidx.media3.exoplayer.DefaultLoadControl import androidx.mediarouter.app.MediaRouteButton import ani.dantotsu.* import ani.dantotsu.R @@ -1448,10 +1449,26 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL private fun buildExoplayer() { //Player + val DEFAULT_MIN_BUFFER_MS = 600000 + val DEFAULT_MAX_BUFFER_MS = 600000 + val BUFFER_FOR_PLAYBACK_MS = 2500 + val BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS = 5000 + + val loadControl = DefaultLoadControl.Builder() + .setBackBuffer(1000 * 60 * 2, true) + .setBufferDurationsMs( + DEFAULT_MIN_BUFFER_MS, + DEFAULT_MAX_BUFFER_MS, + BUFFER_FOR_PLAYBACK_MS, + BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS + ) + .build() + hideSystemBars() exoPlayer = ExoPlayer.Builder(this) .setMediaSourceFactory(DefaultMediaSourceFactory(cacheFactory)) .setTrackSelector(trackSelector) + .setLoadControl(loadControl) .build().apply { playWhenReady = true this.playbackParameters = this@ExoplayerView.playbackParameters @@ -2032,4 +2049,4 @@ class CustomCastButton : MediaRouteButton { true } } -} \ No newline at end of file +}