Skip to content

Commit

Permalink
added default load control (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
KawsarDev authored Feb 20, 2024
1 parent a74b9e9 commit eba7746
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2032,4 +2049,4 @@ class CustomCastButton : MediaRouteButton {
true
}
}
}
}

0 comments on commit eba7746

Please sign in to comment.