Enable constant bitrate seeking

This commit is contained in:
Niels van Velzen 2024-08-13 14:25:34 +02:00 committed by Niels van Velzen
parent 9ac58e22fb
commit e65492c254
2 changed files with 5 additions and 2 deletions

View File

@ -191,6 +191,8 @@ public class VideoManager {
httpDataSourceFactory.setReadTimeoutMs(30 * 1000);
DefaultDataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context, httpDataSourceFactory);
exoPlayerBuilder.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory, extractorsFactory));
extractorsFactory.setConstantBitrateSeekingEnabled(true);
extractorsFactory.setConstantBitrateSeekingAlwaysEnabled(true);
return exoPlayerBuilder;
}

View File

@ -84,14 +84,15 @@ class ExoPlayerBackend(
}
),
DefaultExtractorsFactory().apply {
val isLowRamDevice =
context.getSystemService<ActivityManager>()?.isLowRamDevice == true
val isLowRamDevice = context.getSystemService<ActivityManager>()?.isLowRamDevice == true
setTsExtractorTimestampSearchBytes(
when (isLowRamDevice) {
true -> TS_SEARCH_BYTES_LM
false -> TS_SEARCH_BYTES_HM
}
)
setConstantBitrateSeekingEnabled(true)
setConstantBitrateSeekingAlwaysEnabled(true)
}
))
.setPauseAtEndOfMediaItems(true)