Exit early progressive loads if the load task is canceled

Add an check when loading progressive media in case the load
is canceled. If the player is released very early, the progressive
media period may carry on with the initial loading unnecessarily.

PiperOrigin-RevId: 586288385
This commit is contained in:
christosts 2023-11-29 03:58:16 -08:00 committed by Copybara-Service
parent 3204313f13
commit 3d1d8f4439

View File

@ -1027,6 +1027,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
long position = positionHolder.position; long position = positionHolder.position;
dataSpec = buildDataSpec(position); dataSpec = buildDataSpec(position);
long length = dataSource.open(dataSpec); long length = dataSource.open(dataSpec);
if (loadCanceled) {
break;
}
if (length != C.LENGTH_UNSET) { if (length != C.LENGTH_UNSET) {
length += position; length += position;
onLengthKnown(); onLengthKnown();