Skip to content

Commit

Permalink
Ignore unknown video size
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Feb 21, 2024
1 parent db93449 commit 844f430
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -292,9 +293,12 @@ fun Player.videoSizeAsFlow(): Flow<VideoSize> = callbackFlow {
*
* @param defaultAspectRatio Aspect ratio when [Player.getVideoSize] is unknown or audio.
*/
fun Player.getAspectRatioAsFlow(defaultAspectRatio: Float): Flow<Float> = videoSizeAsFlow().map {
it.computeAspectRatio(defaultAspectRatio)
}
fun Player.getAspectRatioAsFlow(defaultAspectRatio: Float): Flow<Float> =
videoSizeAsFlow()
.filterNot { it == VideoSize.UNKNOWN }
.map {
it.computeAspectRatio(defaultAspectRatio)
}

/**
* Get track selection parameters as flow [Player.getTrackSelectionParameters]
Expand Down

0 comments on commit 844f430

Please sign in to comment.