Make sure ExoPlayerAssetLoader's progress is not more than 100

PiperOrigin-RevId: 742710076
This commit is contained in:
kimvde 2025-04-01 08:27:55 -07:00 committed by Copybara-Service
parent 3fddf4376c
commit 812e078310

View File

@ -272,8 +272,10 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) {
if (progressState == PROGRESS_STATE_AVAILABLE) {
long durationMs = player.getDuration();
long positionMs = player.getCurrentPosition();
progressHolder.progress = min((int) (positionMs * 100 / durationMs), 99);
// The player position can become greater than the duration. This happens if the player is
// using a StandaloneMediaClock because the renderers have ended.
long positionMs = min(player.getCurrentPosition(), durationMs);
progressHolder.progress = (int) (positionMs * 100 / durationMs);
}
return progressState;
}