From 3d1d8f4439f194029d1522137b7f428e96bf61b3 Mon Sep 17 00:00:00 2001 From: christosts Date: Wed, 29 Nov 2023 03:58:16 -0800 Subject: [PATCH] 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 --- .../media3/exoplayer/source/ProgressiveMediaPeriod.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaPeriod.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaPeriod.java index 834a4b29ad..b1b7ab607d 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaPeriod.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaPeriod.java @@ -1027,6 +1027,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; long position = positionHolder.position; dataSpec = buildDataSpec(position); long length = dataSource.open(dataSpec); + if (loadCanceled) { + break; + } if (length != C.LENGTH_UNSET) { length += position; onLengthKnown();