From 844f4306b63029aa746d487ed999935694b2ffa4 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] 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 49bd84c79..09cf406f6 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 @@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.emptyFlow +import kotlinx.coroutines.flow.filterNot import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge @@ -292,9 +293,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]