ExoPlayer, how to load bigger parts of remote audio files
Answer of @Massimo is correct but the way is deprecated
use something like this
DefaultLoadControl.Builder()
.setBufferDurationsMs(
DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
30_000,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
)
I've found the solution. Since I'm not finding other related questions, I'll answer to my question (I hope someone will need it in the future):
The right object to configure is the LoadControl
passed to the ExoPlayerFactory
when creating the ExoPlayer
object:
Original answer (deprecated):
val loadControl = DefaultLoadControl(
DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE),
5 * 60 * 1000, // this is it!
10 * 60 * 1000,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS.toLong(),
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS.toLong()
)
exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl)
The updated answer:
val bandwidthMeter = DefaultBandwidthMeter.Builder(context).build()
val trackSelectionFactory = AdaptiveTrackSelection.Factory()
val trackSelector = DefaultTrackSelector(trackSelectionFactory)
val loadControl = DefaultLoadControl.Builder()
.setAllocator(DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE))
.setBufferDurationsMs(
5 * 60 * 1000, // this is it!
10 * 60 * 1000,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
)
.setTargetBufferBytes(DefaultLoadControl.DEFAULT_TARGET_BUFFER_BYTES)
.setPrioritizeTimeOverSizeThresholds(DefaultLoadControl.DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS)
.createDefaultLoadControl()
exoPlayer = ExoPlayerFactory.newSimpleInstance(
context,
DefaultRenderersFactory(context),
trackSelector,
loadControl,
null,
bandwidthMeter)
The doc where it is explained.