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
(cherry picked from commit 3d1d8f4439f194029d1522137b7f428e96bf61b3)
This commit is contained in:
christosts 2023-11-29 03:58:16 -08:00 committed by microkatz
parent d68c36e082
commit 3f3287aba3

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();