Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.
Kotlin alternativeandroidandroid-applicationclientglassmorphisminnertubelibrespotliquid-glassspotifyspotify-connectspotifyapiyoutube-musicyoutube-playerytdlnis
Say when a song is still loading
Lelonio733fa1dd0c80
diff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.ktindex dea228c..d4e696c 100644--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt@@ -2226,7 +2226,11 @@ private fun NavHostController.switchTab(route: String) {}private fun Player.togglePlay() {- if (isPlaying) pause() else play()+ // playWhenReady, not isPlaying: a track that is still being fetched is not+ // playing, so asking isPlaying made every tap during a load another play —+ // the listener could tap five times and never stop it. This alternates from+ // the first tap, and the last one wins.+ if (playWhenReady) pause() else play()}/** off → all → one → off, the order every player uses. */diff --git a/app/src/main/java/dev/lelonio/square/ui/player/FloatingMiniPlayer.kt b/app/src/main/java/dev/lelonio/square/ui/player/FloatingMiniPlayer.ktindex aa2abd5..34c255a 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/FloatingMiniPlayer.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/FloatingMiniPlayer.kt@@ -30,6 +30,7 @@ import androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.width+import androidx.compose.material3.CircularProgressIndicatorimport androidx.compose.material3.Iconimport androidx.compose.material3.IconButtonimport androidx.compose.material3.MaterialTheme@@ -227,14 +228,27 @@ fun FloatingMiniPlayer(onClick = onTogglePlay,modifier = Modifier.size(if (inline) 36.dp else ControlSize),) {- Icon(- if (state.isPlaying) PhosphorIcons.Fill.Pause else PhosphorIcons.Fill.Play,- contentDescription = stringResource(- if (state.isPlaying) R.string.pause else R.string.play,- ),- tint = contentColor,- modifier = Modifier.size(if (inline) 20.dp else 24.dp),- )+ // The same ring the full player draws, for the same reason: a+ // track being fetched can take long enough that a tap on play+ // looks like nothing happened. Around the icon rather than in+ // its place, so the button stays where it is and stays pressable.+ Box(contentAlignment = Alignment.Center) {+ if (state.isBuffering) {+ CircularProgressIndicator(+ color = contentColor.copy(alpha = 0.5f),+ strokeWidth = 1.5.dp,+ modifier = Modifier.size(if (inline) 30.dp else 34.dp),+ )+ }+ Icon(+ if (state.wantsPlay) PhosphorIcons.Fill.Pause else PhosphorIcons.Fill.Play,+ contentDescription = stringResource(+ if (state.wantsPlay) R.string.pause else R.string.play,+ ),+ tint = contentColor,+ modifier = Modifier.size(if (inline) 20.dp else 24.dp),+ )+ }}}diff --git a/app/src/main/java/dev/lelonio/square/ui/player/MiniPlayer.kt b/app/src/main/java/dev/lelonio/square/ui/player/MiniPlayer.ktindex 9a05291..62a4674 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/MiniPlayer.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/MiniPlayer.kt@@ -254,7 +254,7 @@ fun MiniPlayer()}Crossfade(- state.isPlaying,+ state.wantsPlay,animationSpec = tween(180),label = "playPause",) { playing ->diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.ktindex 3995af7..5c5a7d3 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt@@ -1446,7 +1446,7 @@ internal fun Controls()}Crossfade(- state.isPlaying,+ state.wantsPlay,animationSpec = tween(180),label = "playPause",) { playing ->diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.ktindex 78454d7..a571df9 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerState.kt@@ -27,6 +27,16 @@ data class PlaybackState(val artist: String = "",val artworkUrl: String? = null,val isPlaying: Boolean = false,+ /**+ * What the listener asked for, which is not always what is happening.+ *+ * A track being fetched is not playing yet, and the play button read that+ * as "still paused": every tap during a load meant play again, so the load+ * could not be called off and the button that says pause never appeared.+ * The glyph and the tap both follow this; [isPlaying] stays the fact, for+ * the things that follow the sound rather than the intent.+ */+ val wantsPlay: Boolean = false,val isBuffering: Boolean = false,val durationMs: Long = 0,val hasNext: Boolean = false,@@ -171,6 +181,7 @@ fun rememberPlaybackState(artist = metadata.artist?.toString().orEmpty(),artworkUrl = metadata.artworkUri?.toString(),isPlaying = player.isPlaying,+ wantsPlay = player.playWhenReady,isBuffering = player.playbackState == Player.STATE_BUFFERING,durationMs = metadata.durationMs ?: player.duration.coerceAtLeast(0),hasNext = player.hasNextMediaItem(),