diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt index 00029476a..104b0f2ec 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/controls/PlayerTimeSlider.kt @@ -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()