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.

Reverb released on pause, notification opens the player, no black Canvas

Lelonio3982de90b68c
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 342b0a0..56b1fb4 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -120,7 +120,8 @@
"Bash(git commit -q -m 'A hero that actually collapses, and a menu nothing covers *)",
"Bash(git commit -q -m 'Relink playlist tracks to this market; icon-only track menu *)",
"Bash(git commit -q -m 'A modal track sheet, and reverb that stops with playback *)",
- "Bash(git commit -q -m 'Blur the sheet harder than the page; stop reverb on pause *)"
+ "Bash(git commit -q -m 'Blur the sheet harder than the page; stop reverb on pause *)",
+ "Bash(git commit -q -m 'Reverb released on pause, notification opens the player, no black Canvas *)"
]
}
}
diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
index 0a681c7..800fc35 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/playback/AudioOutput.kt b/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
index 17867b7..6b81cce 100644
--- a/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
+++ b/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
@@ -268,7 +268,16 @@ class AudioOutput {
setAuxEffectSendLevel(0f)
attachAuxEffect(0)
}
- reverb?.runCatching { enabled = false }
+ // Released, not just disabled. Disabling stops the effect processing but
+ // leaves it on the output mix, and the tail already inside it went on
+ // ringing out over whatever the phone played next. Releasing it takes it
+ // off the mix entirely; the next play builds a fresh one, which starts
+ // silent by definition.
+ reverb?.runCatching {
+ enabled = false
+ release()
+ }
+ reverb = null
}
/**
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 ee61e87..8f27a8f 100644
--- a/app/src/main/java/dev/emanuele/spot/playback/LibrespotPlayer.kt
+++ b/app/src/main/java/dev/emanuele/spot/playback/LibrespotPlayer.kt
@@ -463,11 +463,16 @@ class LibrespotPlayer(
playbackState = Player.STATE_READY
playWhenReady = true
positionMs = eventPositionMs
+ // Here as well as in handleSetPlayWhenReady: a pause can arrive
+ // from the notification, from a headset button or from another
+ // Connect device, and only this path sees all of them.
+ onPlaybackActive(true)
}
"paused" -> {
playbackState = Player.STATE_READY
playWhenReady = false
positionMs = eventPositionMs
+ onPlaybackActive(false)
}
"position" -> {
positionMs = eventPositionMs
@@ -475,6 +480,7 @@ class LibrespotPlayer(
"stopped" -> {
playbackState = Player.STATE_IDLE
playWhenReady = false
+ onPlaybackActive(false)
}
// Both used to advance the queue from here. The engine does it now
// — it owns the queue — so acting on them as well would skip two
diff --git a/app/src/main/java/dev/emanuele/spot/playback/PlaybackService.kt b/app/src/main/java/dev/emanuele/spot/playback/PlaybackService.kt
index 0dfe58f..5a96430 100644
--- a/app/src/main/java/dev/emanuele/spot/playback/PlaybackService.kt
+++ b/app/src/main/java/dev/emanuele/spot/playback/PlaybackService.kt
@@ -30,6 +30,9 @@ import kotlinx.coroutines.withContext
* in [onDestroy] is guaranteed to run.
*/
@UnstableApi
+/** Set on the intent the notification fires: open straight into the player. */
+const val EXTRA_OPEN_PLAYER = "dev.emanuele.spot.OPEN_PLAYER"
+
class PlaybackService : MediaSessionService() {
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
@@ -62,6 +65,23 @@ class PlaybackService : MediaSessionService() {
)
session = MediaSession.Builder(this, player)
.setCallback(MediaItemsCallback)
+ // Without this the notification is inert to a tap: Media3 has no way
+ // to know which activity owns the session. `SINGLE_TOP` so an app
+ // already running comes forward rather than starting a second copy
+ // on top of itself.
+ .setSessionActivity(
+ android.app.PendingIntent.getActivity(
+ this,
+ 0,
+ android.content.Intent(this, dev.emanuele.spot.ui.MainActivity::class.java)
+ .setAction(android.content.Intent.ACTION_MAIN)
+ .addCategory(android.content.Intent.CATEGORY_LAUNCHER)
+ .putExtra(EXTRA_OPEN_PLAYER, true)
+ .addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP),
+ android.app.PendingIntent.FLAG_IMMUTABLE or
+ android.app.PendingIntent.FLAG_UPDATE_CURRENT,
+ ),
+ )
.build()
AudioEffects.load(this)
diff --git a/app/src/main/java/dev/emanuele/spot/ui/MainActivity.kt b/app/src/main/java/dev/emanuele/spot/ui/MainActivity.kt
index 8192b3f..7a708b8 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/MainActivity.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/MainActivity.kt
@@ -31,6 +31,15 @@ class MainActivity : ComponentActivity() {
private var controller by mutableStateOf<MediaController?>(null)
+ /**
+ * Bumped when something asks for the player to be open — the notification,
+ * for now.
+ *
+ * A counter rather than a flag: two taps in a row are two requests, and a
+ * boolean that is already true the second time would be ignored.
+ */
+ private var openPlayer by mutableStateOf(0)
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Transparent bars; SpotTheme sets the icon colour, because it is the
@@ -45,8 +54,25 @@ class MainActivity : ComponentActivity() {
android.graphics.Color.TRANSPARENT,
),
)
+ if (intent?.getBooleanExtra(dev.emanuele.spot.playback.EXTRA_OPEN_PLAYER, false) == true) {
+ openPlayer++
+ }
+
setContent {
- SpotApp(player = controller, onPlay = ::play, onEnqueue = ::enqueue)
+ SpotApp(
+ player = controller,
+ onPlay = ::play,
+ onEnqueue = ::enqueue,
+ openPlayer = openPlayer,
+ )
+ }
+ }
+
+ override fun onNewIntent(intent: android.content.Intent) {
+ super.onNewIntent(intent)
+ setIntent(intent)
+ if (intent.getBooleanExtra(dev.emanuele.spot.playback.EXTRA_OPEN_PLAYER, false)) {
+ openPlayer++
}
}
diff --git a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
index 1680cce..2e8242c 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/SpotApp.kt
@@ -154,6 +154,12 @@ fun SpotApp(
onPlay: (List<CatalogTrack>, Int) -> Unit,
/** Appends one track to the end of the queue; see the swipe gesture on rows. */
onEnqueue: (CatalogTrack) -> Unit,
+ /**
+ * Incremented when something outside the app asks for the player — the
+ * notification, for now. A counter, so a second request while the player is
+ * already open is still a request.
+ */
+ openPlayer: Int = 0,
viewModel: MainViewModel = viewModel(),
) {
val state by viewModel.state.collectAsStateWithLifecycle()
@@ -202,6 +208,13 @@ fun SpotApp(
val expand = remember { Animatable(0f) }
val scope = rememberCoroutineScope()
+ // Opened from outside — a tap on the media notification. Skipped on the
+ // first composition of a launch that did not ask for it, since the counter
+ // starts at zero.
+ LaunchedEffect(openPlayer) {
+ if (openPlayer > 0 && playback.hasItem) expand.animateTo(1f, expandSpec)
+ }
+
// Measured rather than assumed. The constant this replaced was 62dp while
// the bar is a 64dp capsule with padding around it and the navigation inset
// under that, so the sheet sat about twenty over it.
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 2e2c8b9..7d895b0 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
@@ -217,12 +217,28 @@ fun PlayerScreen(
when {
clip == null -> Unit
- clip.isVideo -> CanvasSurface(
+ // The video only while the player is at rest.
+ //
+ // A TextureView inside a layer that is being scaled and
+ // faded — which is exactly what the closing animation does —
+ // goes black for the length of the travel: its surface is
+ // detached and re-attached around the layer change, and
+ // there is nothing to draw in between. Standing in the
+ // artwork for those few hundred milliseconds is invisible;
+ // a black rectangle sliding down the screen is not.
+ clip.isVideo && LocalGlassEnabled.current -> CanvasSurface(
url = clip.url,
isPlaying = state.isPlaying,
modifier = Modifier.fillMaxSize(),
)
+ clip.isVideo -> AsyncImage(
+ model = state.artworkUrl,
+ contentDescription = null,
+ contentScale = ContentScale.Crop,
+ modifier = Modifier.fillMaxSize(),
+ )
+
// A handful of canvases are stills rather than clips.
else -> AsyncImage(
model = clip.url,