From e1a5b9c07932239b0795ef4e848e656f5559c313 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 20 Aug 2025 21:26:59 -0400 Subject: [PATCH] Waits for the player to load and sets the current position of the audio --- .../service/playback/composable/wavefront/Waveform.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/wavefront/Waveform.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/wavefront/Waveform.kt index c0ef0c865..2b0c6bd47 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/wavefront/Waveform.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/composable/wavefront/Waveform.kt @@ -82,6 +82,12 @@ fun Waveform( pollCurrentDuration(it).collect { value -> waveformProgress.floatValue = value } } } + + LaunchedEffect(Unit) { + delay(500) + val position = mediaControllerState.controller?.let { it.currentPosition / it.duration.toFloat() } ?: 0f + waveformProgress.floatValue = position + } } private fun pollCurrentDuration(controller: MediaController) =