mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Make sure ExoPlayerAssetLoader's progress is not more than 100
PiperOrigin-RevId: 742710076
This commit is contained in:
parent
3fddf4376c
commit
812e078310
@ -272,8 +272,10 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
|
|||||||
public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) {
|
public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) {
|
||||||
if (progressState == PROGRESS_STATE_AVAILABLE) {
|
if (progressState == PROGRESS_STATE_AVAILABLE) {
|
||||||
long durationMs = player.getDuration();
|
long durationMs = player.getDuration();
|
||||||
long positionMs = player.getCurrentPosition();
|
// The player position can become greater than the duration. This happens if the player is
|
||||||
progressHolder.progress = min((int) (positionMs * 100 / durationMs), 99);
|
// using a StandaloneMediaClock because the renderers have ended.
|
||||||
|
long positionMs = min(player.getCurrentPosition(), durationMs);
|
||||||
|
progressHolder.progress = (int) (positionMs * 100 / durationMs);
|
||||||
}
|
}
|
||||||
return progressState;
|
return progressState;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user