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..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,11 +841,23 @@ fun MiniPlayer( ) } } + var previousVolumeValue by rememberSaveable { + mutableFloatStateOf(controllerState.volume.coerceAtLeast(0.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.coerceIn(0.1f, 1f))) + } }, ) { Icon( @@ -882,6 +894,7 @@ fun MiniPlayer( onValueChange = { isVolumeSliding = true volumeValue = it + if (it > 0f) previousVolumeValue = it }, valueRange = 0f..1f, modifier =