From d9235610f09eaae70308f59ad9270d527de13065 Mon Sep 17 00:00:00 2001 From: laolu Date: Thu, 23 Jul 2026 12:12:56 -0400 Subject: [PATCH 1/5] Remember previous volume value when muting Previously, muting and unmuting would put the slider at max volume regardless of what the previous value was. Add logic to remember this previous value so when unmuting, the volume returns to what it was beforehand. --- .../maxrave/simpmusic/ui/screen/MiniPlayer.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt index d09f96111..f1fc5c0b1 100644 --- a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt +++ b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt @@ -841,11 +841,24 @@ fun MiniPlayer( ) } } + var previousVolumeValue by rememberSaveable { + mutableFloatStateOf(1f) + } + LaunchedEffect(controllerState.volume) { + if (controllerState.volume > 1f) { + previousVolumeValue = controllerState.volume + } + } IconButton( onClick = { // Toggle mute/unmute - val newVolume = if (controllerState.volume > 0f) 0f else 1f - sharedViewModel.onUIEvent(UIEvent.UpdateVolume(newVolume)) + if (controllerState.volume > 0f) { + previousVolumeValue = controllerState.volume + sharedViewModel.onUIEvent(UIEvent.UpdateVolume(0f)) + } + else { + sharedViewModel.onUIEvent(UIEvent.UpdateVolume(previousVolumeValue.coerceAtLeast(0.1f))) + } }, ) { Icon( @@ -882,6 +895,7 @@ fun MiniPlayer( onValueChange = { isVolumeSliding = true volumeValue = it + if (it > 0f) previousVolumeValue = it }, valueRange = 0f..1f, modifier = From 315fa9f50653680608c0725828e6daf120ef21a8 Mon Sep 17 00:00:00 2001 From: laolu Date: Thu, 23 Jul 2026 12:12:56 -0400 Subject: [PATCH 2/5] Remember previous volume value when muting Previously, muting and unmuting would put the slider at max volume regardless of what the previous value was. Add logic to remember this previous value so when unmuting, the volume returns to what it was beforehand. --- .../maxrave/simpmusic/ui/screen/MiniPlayer.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt index d09f96111..22b26854c 100644 --- a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt +++ b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt @@ -841,11 +841,24 @@ fun MiniPlayer( ) } } + var previousVolumeValue by rememberSaveable { + mutableFloatStateOf(1f) + } + LaunchedEffect(controllerState.volume) { + if (controllerState.volume > 0f) { + previousVolumeValue = controllerState.volume + } + } IconButton( onClick = { // Toggle mute/unmute - val newVolume = if (controllerState.volume > 0f) 0f else 1f - sharedViewModel.onUIEvent(UIEvent.UpdateVolume(newVolume)) + if (controllerState.volume > 0f) { + previousVolumeValue = controllerState.volume + sharedViewModel.onUIEvent(UIEvent.UpdateVolume(0f)) + } + else { + sharedViewModel.onUIEvent(UIEvent.UpdateVolume(previousVolumeValue.coerceAtLeast(0.1f))) + } }, ) { Icon( @@ -882,6 +895,7 @@ fun MiniPlayer( onValueChange = { isVolumeSliding = true volumeValue = it + if (it > 0f) previousVolumeValue = it }, valueRange = 0f..1f, modifier = From 475ea01a3a07e32b0316ca9b2cf1953e6141bbf9 Mon Sep 17 00:00:00 2001 From: laolu Date: Thu, 23 Jul 2026 14:14:31 -0400 Subject: [PATCH 3/5] Fix else formatting --- .../kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt index 22b26854c..aaee120e5 100644 --- a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt +++ b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt @@ -855,8 +855,7 @@ fun MiniPlayer( if (controllerState.volume > 0f) { previousVolumeValue = controllerState.volume sharedViewModel.onUIEvent(UIEvent.UpdateVolume(0f)) - } - else { + } else { sharedViewModel.onUIEvent(UIEvent.UpdateVolume(previousVolumeValue.coerceAtLeast(0.1f))) } }, From b85cc7f0abb3df44cd2b5356c7499f0ad0226853 Mon Sep 17 00:00:00 2001 From: laoluogun <161969905+laoluogun@users.noreply.github.com> Date: Sat, 25 Jul 2026 09:22:50 -0400 Subject: [PATCH 4/5] Initiliaze previous volume to 10% Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt index aaee120e5..a1b45e8fd 100644 --- a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt +++ b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt @@ -841,9 +841,9 @@ fun MiniPlayer( ) } } - var previousVolumeValue by rememberSaveable { - mutableFloatStateOf(1f) - } +var previousVolumeValue by rememberSaveable { + mutableFloatStateOf(controllerState.volume.coerceAtLeast(0.1f)) +} LaunchedEffect(controllerState.volume) { if (controllerState.volume > 0f) { previousVolumeValue = controllerState.volume From 9f0dccd62f7fc75c09563a26fe277c52f546d9c1 Mon Sep 17 00:00:00 2001 From: laolu Date: Sat, 25 Jul 2026 09:33:37 -0400 Subject: [PATCH 5/5] Add cap to volume value when unmuting --- .../kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt index a1b45e8fd..a4ae807bf 100644 --- a/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt +++ b/composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/ui/screen/MiniPlayer.kt @@ -841,9 +841,9 @@ fun MiniPlayer( ) } } -var previousVolumeValue by rememberSaveable { - mutableFloatStateOf(controllerState.volume.coerceAtLeast(0.1f)) -} + var previousVolumeValue by rememberSaveable { + mutableFloatStateOf(controllerState.volume.coerceAtLeast(0.1f)) + } LaunchedEffect(controllerState.volume) { if (controllerState.volume > 0f) { previousVolumeValue = controllerState.volume @@ -856,7 +856,7 @@ var previousVolumeValue by rememberSaveable { previousVolumeValue = controllerState.volume sharedViewModel.onUIEvent(UIEvent.UpdateVolume(0f)) } else { - sharedViewModel.onUIEvent(UIEvent.UpdateVolume(previousVolumeValue.coerceAtLeast(0.1f))) + sharedViewModel.onUIEvent(UIEvent.UpdateVolume(previousVolumeValue.coerceIn(0.1f, 1f))) } }, ) {