I want make ExoPlayer if the internet speed is good to play high resolution vice versa to play in low resolution. I also used bandwitmether with default or custom initial bandwith estimate and AdaptiveTrackSelection.Factory. How can fix it to play only specified internet quality, because defaultBandwithmeter gives false bitrate. Thanks in advance
val trackSelector : DefaultTrackSelector = DefaultTrackSelector(context
).apply {
setParameters(buildUponParameters().setAllowMultipleAdaptiveSelections(true).setForceHighestSupportedBitrate(false).setForceLowestBitrate(false))
}
private val simpleCache: SimpleCache = MyApp.simpleCache
val loadControl: LoadControl = DefaultLoadControl.Builder()
.setAllocator(DefaultAllocator(true, 16))
.setBufferDurationsMs(
MIN_BUFFER_DURATION,
MAX_BUFFER_DURATION,
MIN_PLAYBACK_START_BUFFER,
MIN_PLAYBACK_RESUME_BUFFER
)
.build()
init {
val b2 = context.resources.configuration.locale.country
Log.e("vag", b2.toString())
httpDataSourceFactory = DefaultHttpDataSource.Factory()
.setAllowCrossProtocolRedirects(true)
defaultDataSourceFactory = DefaultDataSource.Factory(
context, httpDataSourceFactory
)
cacheDataSourceFactory = CacheDataSource.Factory()
.setCache(simpleCache)
.setUpstreamDataSourceFactory(httpDataSourceFactory)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
bindingVideos.masterExoPlayer.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM);
currentExoPlayer = ExoPlayer.Builder(context).setLoadControl(loadControl).setTrackSelector(trackSelector)
.build()
bindingVideos.masterExoPlayer.player = currentExoPlayer
}