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.

Take the square cover, and let a tap while paused start playing

Leloniod2322083d457
diff --git a/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin b/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
index 4765012..6f10538 100644
--- a/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logc
a
_/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �Ӝ��3  ��߈�3`
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ����3  ��߈�3`
^
-\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build.json  �Ӝ��3� ��߈�3e
+\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build.json  ����3� ��߈�3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build_mini.json  �Ӝ��3� ��߈�3R
+a/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build_mini.json  ����3� ��߈�3R
P
-N/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja  �Ӝ��3� ��߈�3V
+N/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja  ����3� ��߈�3V
T
-R/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja.txt  �Ӝ��3[
+R/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja.txt  ����3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build_file_index.txt  �Ӝ��3 @ ��߈�3\
+W/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build_file_index.txt  ����3 @ ��߈�3\
Z
-X/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json  �Ӝ��3֚ ��߈�3`
+X/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json  ����3֚ ��߈�3`
^
-\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json.bin  �Ӝ��3 �" ��߈�3f
+\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json.bin  ����3 �" ��߈�3f
d
-b/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/metadata_generation_command.txt  �Ӝ��3
+b/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/metadata_generation_command.txt  ����3
� ��߈�3Y
W
-U/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/prefab_config.json  �Ӝ��3  ( ��߈�3^
+U/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/prefab_config.json  ����3  ( ��߈�3^
\
-Z/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/symbol_folder_index.txt  �Ӝ��3  Y ��߈�3D
+Z/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/symbol_folder_index.txt  ����3  Y ��߈�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/playback/LibrespotPlayer.kt b/app/src/main/java/dev/emanuele/spot/playback/LibrespotPlayer.kt
index 6c3454a..7b3c1a4 100644
--- a/app/src/main/java/dev/emanuele/spot/playback/LibrespotPlayer.kt
+++ b/app/src/main/java/dev/emanuele/spot/playback/LibrespotPlayer.kt
@@ -3,6 +3,7 @@ package dev.emanuele.spot.playback
import android.os.Looper
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
+import dev.emanuele.spot.ui.EXTRA_CONTEXT_LABEL
import androidx.media3.common.Player
import androidx.media3.common.SimpleBasePlayer
import androidx.media3.common.util.UnstableApi
@@ -68,11 +69,17 @@ class LibrespotPlayer(
if (uris.isEmpty()) return
val index = queue.currentIndex
fadeOutThen {
+ // Read now, not when this was scheduled. The fade takes a moment,
+ // and a tap on a track while paused arrives as "load this" followed
+ // immediately by "play": with the flag frozen at schedule time the
+ // load went out as paused, the play landed before it, and the track
+ // sat there selected and silent.
+ val wanted = startPlaying || playWhenReady
runCatching {
NativeBridge.loadQueue(
uris,
index,
- startPlaying,
+ wanted,
positionMs,
queue.contextUri.orEmpty(),
// Only when the queue is that context in its own order, and
@@ -82,7 +89,7 @@ class LibrespotPlayer(
)
}
.onFailure { android.util.Log.e("SpotPlayer", "load failed: ${it.message}") }
- if (startPlaying) fadeIn()
+ if (wanted) fadeIn()
}
}
@@ -519,6 +526,15 @@ class LibrespotPlayer(
.setTitle(track.title)
.setArtist(track.artist)
.setArtworkUri(track.artworkUri)
+ // Put back, because this item is rebuilt rather
+ // than passed through; see PlayQueue.contextLabel.
+ .setExtras(
+ queue.contextLabel.takeIf { it.isNotEmpty() }?.let {
+ android.os.Bundle().apply {
+ putString(EXTRA_CONTEXT_LABEL, it)
+ }
+ },
+ )
.build(),
)
.build(),
diff --git a/app/src/main/java/dev/emanuele/spot/playback/PlayQueue.kt b/app/src/main/java/dev/emanuele/spot/playback/PlayQueue.kt
index 11d128c..6a153c1 100644
--- a/app/src/main/java/dev/emanuele/spot/playback/PlayQueue.kt
+++ b/app/src/main/java/dev/emanuele/spot/playback/PlayQueue.kt
@@ -2,6 +2,7 @@ package dev.emanuele.spot.playback
import android.net.Uri
import androidx.media3.common.MediaItem
+import dev.emanuele.spot.ui.EXTRA_CONTEXT_LABEL
import dev.emanuele.spot.ui.EXTRA_CONTEXT_ORDERED
import dev.emanuele.spot.ui.EXTRA_CONTEXT_URI
@@ -169,6 +170,9 @@ class PlayQueue {
}
contextIsOrdered = mediaItems.firstOrNull()
?.mediaMetadata?.extras?.getBoolean(EXTRA_CONTEXT_ORDERED) == true
+ contextLabel = mediaItems.firstNotNullOfOrNull {
+ it.mediaMetadata.extras?.getString(EXTRA_CONTEXT_LABEL)
+ }.orEmpty()
replace(mediaItems.mapNotNull(::toTrack), startIndex)
}
@@ -185,6 +189,18 @@ class PlayQueue {
var contextIsOrdered: Boolean = false
private set
+ /**
+ * What the player shows as the source: "Playlist · Estate 2025".
+ *
+ * Kept here and put back on every item the player publishes. The items that
+ * arrive from a controller carry it in their extras, but the ones handed
+ * *back* are rebuilt from this queue, and a rebuilt item has whatever is put
+ * into it — which is how the label reached the service and never came out
+ * the other side.
+ */
+ var contextLabel: String = ""
+ private set
+
/** Insert controller-supplied items; see [replaceFromMediaItems] for the id rule. */
fun addFromMediaItems(index: Int, mediaItems: List<MediaItem>) {
add(index, mediaItems.mapNotNull(::toTrack))
diff --git a/native/src/catalog.rs b/native/src/catalog.rs
index 592c2e8..2ffb9e7 100644
--- a/native/src/catalog.rs
+++ b/native/src/catalog.rs
@@ -300,37 +300,41 @@ pub fn playlist_cover(uri: &str) -> EngineResult<String> {
let attributes = &list.attributes;
- // Format attributes come first, and the exact `image_url` before any
- // other key that merely ends in it.
+ // Order matters, and the obvious order is wrong.
//
- // The generated lists — "i tuoi brani più ascoltati", the daily mixes —
- // carry several: a header image, a background, and the cover the web
- // client actually shows. Taking whichever came first put the wrong art
- // on those tiles. Their `picture` is stale or empty, which is why this
- // is preferred over it rather than used as a fallback.
- let format_cover = attributes
- .format_attributes
- .iter()
- .find(|attribute| attribute.key() == "image_url")
+ // `picture` is the ordinary cover, and comes first when there is one.
+ // Failing that, the sized variants: those are the square art the web
+ // client shows, largest first.
+ //
+ // The `image_url` among the format attributes is *not* the cover. On the
+ // generated lists it is the header or the phone wallpaper —
+ // `atts-desktop`, `yts-mobile`, `..._MOBILE_WALLPAPER.jpg` — a wide
+ // image where a square one belongs, and often of a different year than
+ // the playlist carrying it. Last resort, for lists with nothing else.
+ let sized = |target: &str| {
+ attributes
+ .picture_size
+ .iter()
+ .find(|size| size.target_name() == target)
+ .and_then(|size| cdn_url(size.url()))
+ };
+
+ let cover = image_url(attributes.picture())
+ .or_else(|| sized("xlarge"))
+ .or_else(|| sized("large"))
+ .or_else(|| sized("default"))
.or_else(|| {
attributes
- .format_attributes
- .iter()
- .find(|attribute| attribute.key().ends_with("image_url"))
+ .picture_size
+ .last()
+ .and_then(|size| cdn_url(size.url()))
})
- .and_then(|attribute| cdn_url(attribute.value()));
-
- let cover = format_cover
- .or_else(|| image_url(attributes.picture()))
.or_else(|| {
- // The sized variants, when there is no single picture: the
- // largest is last in Spotify's own order, and any of them is a
- // better tile than none.
attributes
- .picture_size
+ .format_attributes
.iter()
- .last()
- .and_then(|size| cdn_url(size.url()))
+ .find(|attribute| attribute.key() == "image_url")
+ .and_then(|attribute| cdn_url(attribute.value()))
});
Ok(json!(cover).to_string())