Skip to content

Commit

Permalink
Update pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/playe…
Browse files Browse the repository at this point in the history
…r/controls/PlayerTimeSlider.kt

Co-authored-by: Gaëtan Muller <[email protected]>
  • Loading branch information
StaehliJ and MGaetan89 committed Feb 20, 2024
1 parent 402742f commit e5b7e37
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,11 @@ fun PlayerTimeSlider(
progressTracker: ProgressTrackerState = rememberProgressTrackerState(player = player, smoothTracker = true),
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
) {
val coroutineScope = rememberCoroutineScope()
val durationFlow = remember(player) {
player.durationAsFlow().map { durationMs ->
if (durationMs == C.TIME_UNSET) Duration.ZERO
else durationMs.milliseconds
}.stateIn(coroutineScope, SharingStarted.Lazily, ZERO)
val durationMs by player.durationAsState()
val duration = remember(durationMs) {
if (durationMs == C.TIME_UNSET) ZERO
else durationMs.milliseconds
}
val duration by durationFlow.collectAsState()
val currentProgress by progressTracker.progress.collectAsState()
val currentProgressPercent = currentProgress.inWholeMilliseconds / player.duration.coerceAtLeast(1).toFloat()
val bufferPercentage by player.currentBufferedPercentageAsState()
Expand Down

0 comments on commit e5b7e37

Please sign in to comment.