From 2e3f8760b51293dd1e56eaa1d9fc973cd01cc95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Wed, 21 Feb 2024 11:18:27 +0100 Subject: [PATCH 1/3] Ignore unknown video size --- .../ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt index 7dd7d5100..7f93e8b50 100644 --- a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt +++ b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt @@ -25,6 +25,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.filterNot import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge @@ -291,9 +292,12 @@ fun Player.videoSizeAsFlow(): Flow = callbackFlow { * * @param defaultAspectRatio Aspect ratio when [Player.getVideoSize] is unknown or audio. */ -fun Player.getAspectRatioAsFlow(defaultAspectRatio: Float): Flow = videoSizeAsFlow().map { - it.computeAspectRatio(defaultAspectRatio) -} +fun Player.getAspectRatioAsFlow(defaultAspectRatio: Float): Flow = + videoSizeAsFlow() + .filterNot { it == VideoSize.UNKNOWN } + .map { + it.computeAspectRatio(defaultAspectRatio) + } /** * Get track selection parameters as flow [Player.getTrackSelectionParameters] From 683e0c0c6bd22700566225bb8b952c114acb9d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Thu, 22 Feb 2024 13:17:03 +0100 Subject: [PATCH 2/3] Update pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gaƫtan Muller --- .../main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt index 7f93e8b50..9c386c278 100644 --- a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt +++ b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt @@ -298,6 +298,7 @@ fun Player.getAspectRatioAsFlow(defaultAspectRatio: Float): Flow = .map { it.computeAspectRatio(defaultAspectRatio) } + .onEmpty { emit(defaultAspectRatio) } /** * Get track selection parameters as flow [Player.getTrackSelectionParameters] From 4762d31cf93307c201f89833b79b729f9ea5a21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Thu, 22 Feb 2024 13:20:09 +0100 Subject: [PATCH 3/3] Fix import --- .../main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt index 9c386c278..4f142e0b2 100644 --- a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt +++ b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PlayerCallbackFlow.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.flow.filterNot import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge +import kotlinx.coroutines.flow.onEmpty import kotlinx.coroutines.flow.transformLatest import kotlinx.coroutines.isActive import kotlin.time.Duration