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
Expand the mini player into the player; smooth the lyric sweep
Lelonio83808eb1caec
diff --git a/.claude/settings.local.json b/.claude/settings.local.jsonindex 64c9652..9c7c4ea 100644--- a/.claude/settings.local.json+++ b/.claude/settings.local.json@@ -63,7 +63,9 @@"Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Home: profile header, recency-ordered playlists, plainer cards *)","Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Collapsing home header, sharper cards, library rewrite *)","Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Lyrics centre stage over a blurred Canvas; fix the card blur artefact *)",- "Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Word-level lyric highlight, list fade, chips follow the scroll *)"+ "Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Word-level lyric highlight, list fade, chips follow the scroll *)",+ "Bash(cd \"/Users/emanuele/Progetto Spotify\" && grep -rn \"sharedElement\\\\|SharedTransitionLayout\" ~/.gradle/caches/modules-2/files-2.1/androidx.compose.animation/ 2>/dev/null | head -2; ls ~/.gradle/caches/modules-2/files-2.1/androidx.compose.animation/ 2>/dev/null)",+ "Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Expand the mini player into the player; smooth the lyric sweep *)"]}}diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.binindex 74e2683..c078429 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 Logljh/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtCA-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint �Ӆ��3 ����3i+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint �Ǩ��3 ����3ig-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� ����3nl-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 �Ǩ��3db-`/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 @ ����3ec-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�� ����3ig-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 �" ����3om-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 ( ����3ge-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 ����3DB-@/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 filediff --git a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.ktindex baefc36..07e7be7 100644--- a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt+++ b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt@@ -1,7 +1,11 @@package dev.emanuele.spot.ui-import androidx.compose.animation.slideInVertically-import androidx.compose.animation.slideOutVertically+import androidx.compose.animation.AnimatedVisibility+import androidx.compose.animation.ExperimentalSharedTransitionApi+import androidx.compose.animation.SharedTransitionLayout+import androidx.compose.animation.core.tween+import androidx.compose.animation.fadeIn+import androidx.compose.animation.fadeOutimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.clickableimport androidx.compose.foundation.layout.Box@@ -101,6 +105,10 @@ object Routes {private val BottomBarHeight = 62.dp+/** How long the mini player takes to become the player, and back. */+private const val EXPAND_MS = 420++@OptIn(ExperimentalSharedTransitionApi::class)@UnstableApi@Composablefun SpotApp(@@ -191,6 +199,10 @@ fun SpotApp(// here, or every Text that does not set one explicitly stays black on// the darkened artwork.CompositionLocalProvider(LocalContentColor provides Ink) {+ // Wraps everything that takes part in the expand animation: the+ // mini player lives outside the NavHost, and a shared element only+ // works between two composables under the same layout.+ SharedTransitionLayout {Box(Modifier.fillMaxSize()) {val navController = rememberNavController()val currentEntry by navController.currentBackStackEntryAsState()@@ -320,11 +332,15 @@ fun SpotApp(composable(Routes.PLAYER,- // Rises from the bottom, like the bar it grew out of.- enterTransition = { slideInVertically { it } },- exitTransition = { slideOutVertically { it } },- popEnterTransition = { slideInVertically { it } },- popExitTransition = { slideOutVertically { it } },+ // A plain fade, deliberately. The motion belongs to+ // the artwork: it is a shared element, so it travels+ // from the mini player's 42dp thumbnail to the full+ // cover and back. Sliding the screen as well would+ // be two animations describing the same thing.+ enterTransition = { fadeIn(tween(EXPAND_MS)) },+ exitTransition = { fadeOut(tween(EXPAND_MS)) },+ popEnterTransition = { fadeIn(tween(EXPAND_MS)) },+ popExitTransition = { fadeOut(tween(EXPAND_MS)) },) {PlayerScreen(state = playback,@@ -372,6 +388,8 @@ fun SpotApp(onDeletePreset = viewModel::deleteEffectPreset,backdrop = artBackdrop,canvas = canvas,+ sharedScope = this@SharedTransitionLayout,+ animatedScope = this@composable,)}}@@ -384,23 +402,32 @@ fun SpotApp(//// Both survive navigation, and both step aside on the full// player, which already carries the same controls.- if (!onPlayer) {- Column(- Modifier- .align(Alignment.BottomCenter)- .fillMaxWidth(),+ Column(+ Modifier+ .align(Alignment.BottomCenter)+ .fillMaxWidth(),+ ) {+ // An AnimatedVisibility rather than an `if`, because the+ // shared element needs a scope to animate within: this is+ // the half of the transition that shrinks back into the bar.+ AnimatedVisibility(+ visible = !onPlayer && playback.hasItem,+ enter = fadeIn(tween(EXPAND_MS)),+ exit = fadeOut(tween(EXPAND_MS)),) {- if (playback.hasItem) {- MiniPlayer(- state = playback,- progress = { progressOf(positionMs.value, playback.durationMs) },- backdrop = pageBackdrop,- modifier = Modifier.padding(horizontal = 16.dp),- onExpand = { navController.navigate(Routes.PLAYER) },- onTogglePlay = { player?.togglePlay() },- onNext = { player?.seekToNextMediaItem() },- )- }+ MiniPlayer(+ state = playback,+ progress = { progressOf(positionMs.value, playback.durationMs) },+ backdrop = pageBackdrop,+ modifier = Modifier.padding(horizontal = 16.dp),+ sharedScope = this@SharedTransitionLayout,+ animatedScope = this@AnimatedVisibility,+ onExpand = { navController.navigate(Routes.PLAYER) },+ onTogglePlay = { player?.togglePlay() },+ onNext = { player?.seekToNextMediaItem() },+ )+ }+ if (!onPlayer) {BottomBar(route = route,bottomInset = navBar,@@ -410,6 +437,7 @@ fun SpotApp(}}}+ }}}}diff --git a/app/src/main/java/dev/emanuele/spot/ui/player/LyricsView.kt b/app/src/main/java/dev/emanuele/spot/ui/player/LyricsView.ktindex 09a39ff..45f91b6 100644--- a/app/src/main/java/dev/emanuele/spot/ui/player/LyricsView.kt+++ b/app/src/main/java/dev/emanuele/spot/ui/player/LyricsView.kt@@ -17,6 +17,7 @@ import androidx.compose.runtime.Composableimport androidx.compose.runtime.Stateimport androidx.compose.runtime.getValueimport androidx.compose.runtime.remember+import androidx.compose.runtime.withFrameMillisimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.blur@@ -50,11 +51,14 @@ import kotlin.math.absfun LyricsView(lyrics: Lyrics,positionMs: State<Long>,+ isPlaying: Boolean,modifier: Modifier = Modifier,onSeek: (Long) -> Unit,) {- val listState = rememberLazyListState()- val position = positionMs.value+ // Keyed on the lyrics, so a new track starts at its first line. Kept across+ // the change, the list stayed wherever the previous song was left.+ val listState = remember(lyrics) { androidx.compose.foundation.lazy.LazyListState() }+ val position by rememberSmoothPosition(positionMs, isPlaying)val activeLine = remember(lyrics, position) {if (!lyrics.synced) -1@@ -111,6 +115,35 @@ fun LyricsView(}}+/**+ * The playback position, advanced every frame between reports.+ *+ * The player is polled four times a second, which is plenty for a seek bar and+ * far too coarse for a highlight that sweeps across words: at 250ms steps the+ * words light up in visible jumps, which is exactly what this was. Between+ * reports the clock simply runs — playback does too — and every report snaps it+ * back to the truth, so it can never drift further than one poll.+ */+@Composable+private fun rememberSmoothPosition(source: State<Long>, isPlaying: Boolean): State<Long> {+ val smoothed = remember { androidx.compose.runtime.mutableLongStateOf(source.value) }+ val reported = source.value++ androidx.compose.runtime.LaunchedEffect(reported, isPlaying) {+ smoothed.longValue = reported+ if (!isPlaying) return@LaunchedEffect++ val startedAt = withFrameMillis { it }+ while (true) {+ withFrameMillis { frame ->+ smoothed.longValue = reported + (frame - startedAt)+ }+ }+ }++ return smoothed+}+/*** How far through the current line playback is, 0 to 1.*@@ -212,14 +245,27 @@ private fun LyricRow(} else {buildAnnotatedString {append(text)+ var previousStop = 0fwordStops(text).forEach { (range, stop) ->- if (stop > sungFraction) {- addStyle(- SpanStyle(color = Color.White.copy(alpha = 0.45f)),- range.first,- range.last + 1,- )- }+ // Each word lights over its own span rather than+ // switching at the moment it starts. A hard switch is+ // what made this read as stepping from word to word;+ // Apple's version has each one come up as it is reached.+ val span = (stop - previousStop).coerceAtLeast(0.0001f)+ val lit = ((sungFraction - previousStop) / span).coerceIn(0f, 1f)+ previousStop = stop+ // Eased at both ends, so a word neither snaps on nor+ // finishes brightening a beat before the next begins.+ val eased = lit * lit * (3f - 2f * lit)+ addStyle(+ SpanStyle(+ color = Color.White.copy(+ alpha = DIM_WORD_ALPHA + (1f - DIM_WORD_ALPHA) * eased,+ ),+ ),+ range.first,+ range.last + 1,+ )}}}@@ -251,5 +297,8 @@ private fun LyricRow(/** Rough line height in px, used to bias the auto-scroll target. */private const val LineHeightPx = 60+/** How dim a word is before it has been reached. */+private const val DIM_WORD_ALPHA = 0.42f+/** How long the last line is assumed to last, having no next line to end it. */private const val TAIL_LINE_MS = 4_000Ldiff --git a/app/src/main/java/dev/emanuele/spot/ui/player/MiniPlayer.kt b/app/src/main/java/dev/emanuele/spot/ui/player/MiniPlayer.ktindex d32a00d..6bf23a0 100644--- a/app/src/main/java/dev/emanuele/spot/ui/player/MiniPlayer.kt+++ b/app/src/main/java/dev/emanuele/spot/ui/player/MiniPlayer.kt@@ -42,6 +42,29 @@ import dev.emanuele.spot.ui.glass.LiquidButtonimport dev.emanuele.spot.ui.theme.softShadow/** Persistent bar above the bottom edge; tapping it opens the full player. */+/**+ * Marks the artwork as the element shared with the full player.+ *+ * An extension rather than an inline block because it is needed identically at+ * both ends, and the two have to agree on the key or nothing is shared.+ */+@Composable+fun Modifier.sharedArtwork(+ sharedScope: androidx.compose.animation.SharedTransitionScope?,+ animatedScope: androidx.compose.animation.AnimatedVisibilityScope?,+): Modifier {+ if (sharedScope == null || animatedScope == null) return this+ return with(sharedScope) {+ rememberSharedContentState(key = SHARED_ARTWORK),+ animatedScope,+ )+ }+}++/** The key both ends of the expand animation agree on. */+const val SHARED_ARTWORK = "nowPlayingArtwork"+@Composablefun MiniPlayer(state: PlaybackState,@@ -53,6 +76,16 @@ fun MiniPlayer(/** The layer this bar refracts. */backdrop: Backdrop,modifier: Modifier = Modifier,+ /**+ * The two halves of the expand animation.+ *+ * The cover here and the cover on the player screen are declared as the same+ * shared element, so opening the player grows this bar into that screen+ * instead of sliding a new one over it. Null when there is no transition to+ * take part in, which keeps this composable usable on its own.+ */+ sharedScope: androidx.compose.animation.SharedTransitionScope? = null,+ animatedScope: androidx.compose.animation.AnimatedVisibilityScope? = null,onExpand: () -> Unit,onTogglePlay: () -> Unit,onNext: () -> Unit,@@ -79,7 +112,14 @@ fun MiniPlayer(.padding(10.dp),verticalAlignment = Alignment.CenterVertically,) {- Artwork(state.artworkUrl, state.title, Modifier.size(42.dp), corner = 12.dp)+ Artwork(+ state.artworkUrl,+ state.title,+ Modifier+ .size(42.dp)+ .sharedArtwork(sharedScope, animatedScope),+ corner = 12.dp,+ )// Slides up on a track change, so an auto-advance is visible// without having to be reading the bar at that moment.diff --git a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.kt b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.ktindex beec506..1fc88f3 100644--- a/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.kt+++ b/app/src/main/java/dev/emanuele/spot/ui/player/PlayerPanel.kt@@ -107,7 +107,9 @@ fun PlayerPanelSection() {when (panel) {PlayerPanel.QUEUE -> QueueList(queue, onPlayQueueItem)- PlayerPanel.LYRICS -> LyricsPanel(lyrics, lyricsLoading, positionMs, onSeek)+ // Drawn in the middle of the player instead; see+ // LyricsStage in PlayerScreen.+ PlayerPanel.LYRICS -> UnitPlayerPanel.EFFECTS -> EffectsPanel(speed = speed,pitch = pitch,@@ -182,20 +184,6 @@ private fun QueueList(queue: List<QueueEntry>, onPlay: (Int) -> Unit) {}}-@Composable-private fun LyricsPanel(- lyrics: Lyrics?,- loading: Boolean,- positionMs: androidx.compose.runtime.State<Long>,- onSeek: (Long) -> Unit,-) {- when {- loading -> EmptyPanel("Carico il testo…")- lyrics == null -> EmptyPanel("Nessun testo disponibile")- else -> LyricsView(lyrics = lyrics, positionMs = positionMs, onSeek = onSeek)- }-}-/*** Tempo, pitch and reverb.*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.ktindex 0371282..4f56476 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@@ -123,6 +123,9 @@ fun PlayerScreen(backdrop: Backdrop,/** The track's Canvas clip, or null when it has none. */canvas: dev.emanuele.spot.data.CanvasClip?,+ /** See MiniPlayer: the cover is shared with the bar this screen grew out of. */+ sharedScope: androidx.compose.animation.SharedTransitionScope? = null,+ animatedScope: androidx.compose.animation.AnimatedVisibilityScope? = null,) {var panel by remember { mutableStateOf(PlayerPanel.NONE) }@@ -248,7 +251,7 @@ fun PlayerScreen(modifier = Modifier.weight(1f),) {Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {- Cover(state, panel, onNext, onPrevious)+ Cover(state, panel, onNext, onPrevious, sharedScope, animatedScope)}}@@ -264,6 +267,7 @@ fun PlayerScreen(lyrics = lyrics,loading = lyricsLoading,positionMs = positionMs,+ isPlaying = state.isPlaying,onSeek = onSeek,)}@@ -413,6 +417,8 @@ private fun Cover(panel: PlayerPanel,onNext: () -> Unit,onPrevious: () -> Unit,+ sharedScope: androidx.compose.animation.SharedTransitionScope? = null,+ animatedScope: androidx.compose.animation.AnimatedVisibilityScope? = null,) {val coverFraction by animateFloatAsState(targetValue = if (panel == PlayerPanel.NONE) 0.82f else 0.44f,@@ -455,6 +461,7 @@ private fun Cover(title = title,modifier = Modifier.fillMaxSize()+ .sharedArtwork(sharedScope, animatedScope).softShadow(RoundedCornerShape(26.dp),elevation = (10 + 30 * playingLift).dp,@@ -690,6 +697,7 @@ private fun LyricsStage(lyrics: dev.emanuele.spot.data.Lyrics?,loading: Boolean,positionMs: State<Long>,+ isPlaying: Boolean,onSeek: (Long) -> Unit,) {Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {@@ -708,6 +716,7 @@ private fun LyricsStage(else -> LyricsView(lyrics = lyrics,positionMs = positionMs,+ isPlaying = isPlaying,onSeek = onSeek,modifier = Modifier.fillMaxSize(),)