Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Hold the cover until the Canvas has a frame

Lelonio5d1b101b4d70
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 940b5f7..78d7ef2 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -124,7 +124,8 @@
"Bash(git commit -q -m 'Reverb released on pause, notification opens the player, no black Canvas *)",
"Bash(git commit -q -m 'Wait for a track before opening the player; drop the cover stand-in *)",
"Bash(git commit -q -m 'Deliver the notification intent; blur what the sheets actually cover *)",
- "Bash(git commit -q -m 'An icon made of the app'\\\\''s own glass *)"
+ "Bash(git commit -q -m 'An icon made of the app'\\\\''s own glass *)",
+ "Bash(git commit -q -m 'Hold the cover until the Canvas has a frame *)"
]
}
}
diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
index 3b771d1..a7f86b8 100644
--- a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logl
j
h/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ����3  ����3i
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  嬸��3  ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  ����3� ����3n
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  嬸��3� ����3n
l
-j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  ����3� �����3[
+j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  嬸��3� �����3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  ����3�� ����3_
+W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  欸��3�� ����3_
]
-[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  ����3d
+[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  欸��3d
b
-`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  ����3 @ ����3e
+`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  欸��3 @ ����3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  ����3�� ����3i
+a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  欸��3�� ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  ����3 �" ����3o
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  欸��3 �" ����3o
m
-k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  ����3
+k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  欸��3
� ����3b
`
-^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  ����3  ( ����3g
+^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  欸��3  ( ����3g
e
-c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  ����3  b ����3D
+c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  欸��3  b ����3D
B
-@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  ����3 � �Ȅ��3
\ No newline at end of file
+@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  欸��3 � �Ȅ��3
\ No newline at end of file
diff --git a/app/src/main/java/dev/emanuele/spot/ui/player/CanvasSurface.kt b/app/src/main/java/dev/emanuele/spot/ui/player/CanvasSurface.kt
index 6c7b1e4..81f94ff 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/player/CanvasSurface.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/player/CanvasSurface.kt
@@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.viewinterop.AndroidView
@@ -40,7 +41,19 @@ import dev.emanuele.spot.R
*/
@UnstableApi
@Composable
-fun CanvasSurface(url: String, isPlaying: Boolean, modifier: Modifier = Modifier) {
+fun CanvasSurface(
+ url: String,
+ isPlaying: Boolean,
+ modifier: Modifier = Modifier,
+ /**
+ * Called when there is actually a picture on the surface.
+ *
+ * Between `prepare()` and the first decoded frame a TextureView is empty,
+ * and on a slow connection that is a second or more of nothing where the
+ * cover used to be. The caller keeps the cover up until this fires.
+ */
+ onFirstFrame: () -> Unit = {},
+) {
val context = LocalContext.current
val exoPlayer = remember(url) {
@@ -58,6 +71,17 @@ fun CanvasSurface(url: String, isPlaying: Boolean, modifier: Modifier = Modifier
exoPlayer.playWhenReady = isPlaying
}
+ val ready = rememberUpdatedState(onFirstFrame)
+ DisposableEffect(exoPlayer) {
+ val listener = object : Player.Listener {
+ override fun onRenderedFirstFrame() {
+ ready.value()
+ }
+ }
+ exoPlayer.addListener(listener)
+ onDispose { exoPlayer.removeListener(listener) }
+ }
+
DisposableEffect(exoPlayer) {
onDispose { exoPlayer.release() }
}
diff --git a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt
index 474cc5a..54962b4 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerScreen.kt
@@ -165,6 +165,15 @@ fun PlayerScreen(
// than a recomposition of the player.
val canvasShift = remember { mutableFloatStateOf(0f) }
+ // Whether the clip has put a frame on screen yet.
+ //
+ // A Canvas is known about — the URL arrives with the track — well before it
+ // has decoded anything, and in between the surface is empty. Opening the
+ // player onto that gap showed a blank middle where the cover belongs, so
+ // the cover stays until this turns true and the clip fades in over it.
+ // Reset per track: the next one starts from nothing again.
+ var canvasReady by remember(canvas?.url) { mutableStateOf(false) }
+
// The Canvas gets a layer of its own so the glass over it refracts the clip
// rather than the app's blurred artwork. It is combined with the app
// backdrop rather than replacing it, because with no Canvas this layer is
@@ -208,11 +217,22 @@ fun PlayerScreen(
}
.layerBackdrop(canvasBackdrop),
) {
+ // Held at zero until the first frame, then faded up. Without this
+ // the clip's own surface appears the instant it decodes, which next
+ // to a cover crossfading out reads as two separate events.
+ val clipAlpha by animateFloatAsState(
+ targetValue = if (canvasReady) 1f else 0f,
+ animationSpec = tween(420),
+ label = "clipAlpha",
+ )
+
Crossfade(
targetState = canvas,
animationSpec = tween(500),
label = "canvas",
- modifier = Modifier.fillMaxSize(),
+ modifier = Modifier
+ .fillMaxSize()
+ .graphicsLayer { alpha = if (canvas?.isVideo == true) clipAlpha else 1f },
) { clip ->
when {
clip == null -> Unit
@@ -229,6 +249,7 @@ fun PlayerScreen(
clip.isVideo && LocalGlassEnabled.current -> CanvasSurface(
url = clip.url,
isPlaying = state.isPlaying,
+ onFirstFrame = { canvasReady = true },
modifier = Modifier.fillMaxSize(),
)
@@ -324,7 +345,11 @@ fun PlayerScreen(
PlayerPanel.EFFECTS -> Stage.EFFECTS
PlayerPanel.QUEUE -> Stage.QUEUE
PlayerPanel.NONE ->
- if (canvas == null) Stage.COVER else Stage.CANVAS
+ if (canvas == null || !canvasReady) {
+ Stage.COVER
+ } else {
+ Stage.CANVAS
+ }
},
animationSpec = tween(320),
label = "stage",