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.

A dark player, a lit tab that follows the page, and one rule for back

Lelonio85592cb786a6
diff --git a/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt b/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt
index 8534696..3cf85b0 100644
--- a/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt
@@ -649,6 +649,24 @@ class LibrespotPlayer(
private val skipGaveUp = Runnable {
skipPending = false
skipInFlight = false
+ // And stop contradicting it.
+ //
+ // Clearing the flags was not enough: the queue kept the track that was
+ // asked for, so a skip the engine turned into something else left the
+ // screen on one song and the speaker on another, and every step after
+ // that was measured from the wrong place. A next pressed then asked for
+ // the track already playing, so nothing was sent and the old song went
+ // on. What the engine last said it was on is where the queue goes back
+ // to. A load on its way still counts, since it names the track asked
+ // for.
+ if (engineIndex >= 0 && engineIndex != queue.currentIndex && engineIndex <= queue.items.lastIndex) {
+ android.util.Log.w(
+ "SquarePlayer",
+ "skip to ${queue.currentIndex} never confirmed, back to the engine's $engineIndex",
+ )
+ queue.currentIndex = engineIndex
+ invalidateState()
+ }
}
private val settleSkip = Runnable {
diff --git a/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt b/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt
index ac42e33..67cbab5 100644
--- a/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt
@@ -68,9 +68,20 @@ class NetworkWatch(context: Context, private val scope: CoroutineScope) {
evaluate()
}
+ /** What was last written to the log; see [evaluate]. */
+ private var lastReport: String? = null
+
private fun evaluate() {
val connected = connected()
- android.util.Log.i(TAG, "network is ${if (connected) "up" else "gone"}: ${describe()}")
+ // Only when it changes. The system reports every step in signal
+ // strength as a new set of capabilities, so this was a line every second
+ // or two, and it pushed out of the phone's log the very playback lines
+ // a bug report needs.
+ val report = "network is ${if (connected) "up" else "gone"}: ${describe()}"
+ if (report != lastReport) {
+ lastReport = report
+ android.util.Log.i(TAG, report)
+ }
pending?.cancel()
if (connected) {
OfflineMode.setNoSession(false)
diff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
index 89d892f..45bdca8 100644
--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
@@ -248,6 +248,35 @@ private fun inkTintedBy(color: Color): Color {
return androidx.compose.ui.graphics.lerp(Ink, Color(android.graphics.Color.HSVToColor(hsv)), 0.3f)
}
+/**
+ * The lit tab on a page with a colour of its own: that colour, made to read on
+ * the bar.
+ *
+ * Its hue at full strength, where [inkTintedBy] only leans the ink towards it:
+ * the other tabs whisper the page's colour and the one you are on says it.
+ * Bright over the dark film and deep over the light one, like the ink it takes
+ * the place of. A page with no colour to speak of gets that ink.
+ */
+@Composable
+private fun litTabInk(color: Color): Color {
+ val hsv = FloatArray(3)
+ android.graphics.Color.colorToHSV(color.toArgb(), hsv)
+ if (hsv[1] < 0.06f) return neutralTabInk()
+ hsv[1] = hsv[1].coerceIn(0.55f, 1f)
+ hsv[2] = if (dev.lelonio.square.ui.theme.lightPage()) 0.42f else 1f
+ return Color(android.graphics.Color.HSVToColor(hsv))
+}
+
+/**
+ * The lit tab where the page has no colour: whichever ink reads on the bar's
+ * film, dark on the light one and light on the dark one. The films are the ones
+ * the glass recipe gives the bar on each side; see GlassEffect.
+ */
+@Composable
+private fun neutralTabInk(): Color = dev.lelonio.square.ui.theme.inkOn(
+ if (dev.lelonio.square.ui.theme.lightPage()) Color(0xFFFAFAFA) else Color(0xFF23232A),
+)
+
/** Roughly what the search circle takes: the row's height, which is its own. */
private val SearchCircle = 58.dp
@@ -714,13 +743,6 @@ fun SquareApp(
var clipColumns by remember { mutableStateOf<List<Color>>(emptyList()) }
// What the player's field is made of, worked out once.
- //
- // Both the background and the player itself need it: one paints it, and the
- // other has to know whether what it is writing on is light or dark. It was
- // computed inside the background's own lambda, where the player could not
- // see it — and the player was choosing its ink from the phone's setting
- // instead, which is how a dark Canvas ended up with a near-black progress
- // bar drawn on it in the light setting.
val ambientArt = nowPlayingArt?.heroUrl
?: nowPlayingArt?.coverUrl
?: playback.artworkUrl
@@ -735,19 +757,14 @@ fun SquareApp(
else -> pageColorFor(ambientAccent)
}
- // And the ink that field asks for.
+ // The player's ink, which is always the light one.
//
- // Damped a little first: the lower half of the player carries a black wash
- // for legibility, so the colour the transport actually sits on is darker
- // than the field's own — deciding on the undamped colour left dark ink on
- // a field that had since been taken down towards black.
- val playerInk = dev.lelonio.square.ui.theme.inkOn(
- androidx.compose.ui.graphics.lerp(
- if (clipColumns.isNotEmpty()) clipColumns.mean() else playerTone,
- Color.Black,
- 0.22f,
- ),
- )
+ // It used to be read off the field, and the glass took the opposite film
+ // from it: a pale sleeve turned the whole player into white panes with dark
+ // writing, and the next song could turn it back. The player is dark now
+ // whatever the record and whatever the phone's setting, so the ink is light
+ // and the glass, which still reads it, always takes its dark film.
+ val playerInk = Color(0xFFF7F8FA)
// Emptied by the track change itself, not by the answer about the new
// track's Canvas.
@@ -1096,7 +1113,14 @@ fun SquareApp(
if (spotifyVideoOn) {
dev.lelonio.square.backend.spotify.SpotifyVideoMode.skip(forward = false)
} else {
- player.seekToPreviousMediaItem()
+ // The track before in the first three seconds, the
+ // start of this one after, decided here by the position
+ // on screen. It was always the track before, and the
+ // engine then made its own three-second decision by its
+ // own clock: past three seconds it restarted the song
+ // while the queue moved back, and the app stayed a
+ // track behind the speaker.
+ player.seekToPrevious()
}
},
onSeek = { player.seekTo(it) },
@@ -2005,7 +2029,7 @@ fun SquareApp(
},
onPrevious = {
if (remote != null) onRemote(RemoteConnect::previous)
- else player?.seekToPreviousMediaItem()
+ else player?.seekToPrevious()
},
onSeek = { positionMillis -> player?.seekTo(positionMillis) },
)
@@ -2041,26 +2065,11 @@ fun SquareApp(
// from the screen rather than fixed: four labels and a circle
// on a narrow phone is exactly where a constant starts
// pushing the last tab off the end.
- // The colour the current tab is drawn in: the artwork's
- // own, straight from the palette rather than through the
- // theme.
- //
- // The theme's primary is that colour after the material
- // scheme has had it — pulled toward its own tonal palette,
- // which is what made the lit tab a near-relative of the
- // cover rather than the cover's colour. This is the same
- // value the pages are tinted from, at full strength, which
- // is how the reference draws the place you are.
- // The app's accent, which is the cover's own: the theme is
- // seeded from it through ArtworkColor and every switch,
- // slider and progress bar in the app is drawn in it.
- //
- // This used to read the palette a second time here, and off
- // the *other* catalogue's picture — so the bar could be
- // violet while the rest of the app was orange, on the same
- // song. One accent, taken from where the app already keeps
- // it.
- val tabAccent = MaterialTheme.colorScheme.primary
+ // The app's accent, which is the playing cover's own. Only
+ // the faint tint of the other tabs comes from it now; see
+ // barInk below.
+ val songAccent = MaterialTheme.colorScheme.primary
+
// And the white the rest of the bar is drawn in: never a
// pure one. The reference tints its icons with the colour of
@@ -2079,17 +2088,32 @@ fun SquareApp(
val onDetail = route == Routes.PLAYLIST
val detailArt = playlist.heroUrl ?: playlist.coverUrl ?: playlist.artworkUrl
val detailAccent by rememberArtworkColor(detailArt.takeIf { onDetail })
- val surfaceTint = when {
- // Off a detail page the bar is tinted by what is
- // playing, which is what those pages are tinted by too.
- !onDetail -> tabAccent
+ // The colour of the page under the bar, where it has one: a
+ // record's own, the catalogue's where there is one and the
+ // picture's where there is not.
+ val pageTint: Color? = when {
+ !onDetail -> null
playlist.tintHex != null -> runCatching {
Color(android.graphics.Color.parseColor("#${playlist.tintHex}"))
- }.getOrDefault(tabAccent)
- else -> detailAccent ?: tabAccent
+ }.getOrNull()
+ else -> detailAccent
}
+ // Off a detail page the bar is tinted by what is playing,
+ // which is what those pages are tinted by too.
+ val surfaceTint = pageTint ?: songAccent
val barInk = inkTintedBy(surfaceTint)
+ // The colour the current tab is drawn in: the page's, never
+ // the song's.
+ //
+ // It was the accent, so the one mark that says where you
+ // are changed colour with every song, and on a green list
+ // with a grey record playing it came out grey. On a page
+ // with a colour of its own it is that colour, at the
+ // strength the other tabs only lean towards; on the neutral
+ // pages it is plain ink, chosen by the film it sits on.
+ val tabAccent = pageTint?.let { litTabInk(it) } ?: neutralTabInk()
+
// What the lit slot is filled with. The listener's own glass
// settings still own it — the puck was a surface of this
// app's making before the library grew one — so an opacity of
@@ -2629,10 +2653,9 @@ fun SquareApp(
dev.lelonio.square.ui.player.LocalGlassEnabled provides
(glassConfig.playerEnabled &&
dev.lelonio.square.ui.player.LocalGlassEnabled.current),
- // Everything on this screen writes on the field,
- // and the field is the record — not the phone's
- // setting. The glass reads this too and takes the
- // opposite film; see GlassEffect.
+ // Light ink on every surface of the player, and
+ // through it the dark film on its glass; see
+ // playerInk above and GlassEffect.
dev.lelonio.square.ui.theme.LocalInkOverride provides playerInk,
androidx.compose.material3.LocalContentColor provides playerInk,
) {
@@ -2711,7 +2734,7 @@ fun SquareApp(
dev.lelonio.square.backend.spotify
.SpotifyVideoMode.skip(forward = false)
} else {
- player?.seekToPreviousMediaItem()
+ player?.seekToPrevious()
}
},
onSeek = { target ->
@@ -3895,13 +3918,3 @@ private suspend fun awaitAudible(
/** How long the extras wait for the song; see [awaitAudible]. */
private const val AUDIBLE_TIMEOUT_MS = 5_000L
-
-/** The one colour a row of sampled columns amounts to. */
-private fun List<Color>.mean(): Color {
- if (isEmpty()) return Color.Black
- return Color(
- red = sumOf { it.red.toDouble() }.toFloat() / size,
- green = sumOf { it.green.toDouble() }.toFloat() / size,
- blue = sumOf { it.blue.toDouble() }.toFloat() / size,
- )
-}
diff --git a/app/src/main/java/dev/lelonio/square/ui/components/AmbientArtworkBackground.kt b/app/src/main/java/dev/lelonio/square/ui/components/AmbientArtworkBackground.kt
index 3808966..ffaed46 100644
--- a/app/src/main/java/dev/lelonio/square/ui/components/AmbientArtworkBackground.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/components/AmbientArtworkBackground.kt
@@ -452,7 +452,10 @@ fun AmbientArtworkBackground(
),
),
)
- val scrim = dev.lelonio.square.ui.theme.scrimColor()
+ // Black on both sides of the phone's setting: the player is always
+ // dark, and a white wash under its light writing would be working
+ // against it.
+ val scrim = Color.Black
if (scrimFloor > 0f) {
Box(
Modifier
diff --git a/app/src/main/java/dev/lelonio/square/ui/glass/LiquidBottomTabs.kt b/app/src/main/java/dev/lelonio/square/ui/glass/LiquidBottomTabs.kt
index 7422c3b..62de602 100644
--- a/app/src/main/java/dev/lelonio/square/ui/glass/LiquidBottomTabs.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/glass/LiquidBottomTabs.kt
@@ -40,6 +40,8 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.graphicsLayer
+import dev.lelonio.square.ui.glass.backdrop.BackdropEffectScope
+import androidx.compose.ui.graphics.GraphicsLayerScope
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.semantics.clearAndSetSemantics
@@ -51,7 +53,6 @@ import androidx.compose.ui.util.fastRoundToInt
import androidx.compose.ui.util.lerp
import dev.lelonio.square.ui.glass.backdrop.Backdrop
import dev.lelonio.square.ui.glass.backdrop.backdrops.layerBackdrop
-import dev.lelonio.square.ui.glass.backdrop.backdrops.rememberCombinedBackdrop
import dev.lelonio.square.ui.glass.backdrop.backdrops.rememberLayerBackdrop
import dev.lelonio.square.ui.glass.backdrop.drawBackdrop
import dev.lelonio.square.ui.glass.backdrop.effects.blur
@@ -242,6 +243,15 @@ fun LiquidBottomTabs(
lerp(1f, 1.2f, dampedDragAnimation.pressProgress)
}
) {
+ // LOCAL CHANGE: only the tabs, tinted, on nothing.
+ //
+ // This copy used to carry the page and the bar's film under the
+ // tabs, and the lit slot drew all of it through itself and then laid
+ // its own wash on top. The wash is what makes the slot, and on top
+ // it darkened the one tab that has to stand out: at the dark side's
+ // strength a white tab came out a flat mid grey. The page now comes
+ // through the slot on its own, and this is drawn over the wash; see
+ // the two layers below.
Row(
Modifier
.clearAndSetSemantics {}
@@ -250,24 +260,6 @@ fun LiquidBottomTabs(
.graphicsLayer {
translationX = panelOffset
}
- .drawBackdrop(
- backdrop = backdrop,
- shape = { ContinuousCapsule() },
- effects = {
- val progress = dampedDragAnimation.pressProgress
- vibrancy()
- blur(8f.dp.toPx())
- lens(
- lensDepth.toPx() * progress,
- lensDepth.toPx() * progress
- )
- },
- highlight = {
- val progress = dampedDragAnimation.pressProgress
- Highlight.Default.copy(alpha = progress)
- },
- onDrawSurface = { drawRect(containerColor) }
- )
.then(interactiveHighlight.modifier)
.height(height - 8f.dp)
.fillMaxWidth()
@@ -284,27 +276,45 @@ fun LiquidBottomTabs(
label = "indicatorAlpha",
)
+ // Where the slot is and how it is bent, shared by its two layers so
+ // they move and stretch as one.
+ val slotPlacement = Modifier
+ .padding(horizontal = 4f.dp)
+ .graphicsLayer {
+ alpha = indicatorAlpha
+ translationX =
+ if (isLtr) dampedDragAnimation.value * tabWidth + panelOffset
+ else size.width - (dampedDragAnimation.value + 1f) * tabWidth + panelOffset
+ }
+ val slotLayer: GraphicsLayerScope.() -> Unit = {
+ scaleX = dampedDragAnimation.scaleX
+ scaleY = dampedDragAnimation.scaleY
+ val velocity = dampedDragAnimation.velocity / 10f
+ scaleX /= 1f - (velocity * 0.75f).fastCoerceIn(-0.2f, 0.2f)
+ scaleY *= 1f - (velocity * 0.25f).fastCoerceIn(-0.2f, 0.2f)
+ }
+ val slotLens: BackdropEffectScope.() -> Unit = {
+ val progress = dampedDragAnimation.pressProgress
+ lens(
+ 10f.dp.toPx() * progress,
+ 14f.dp.toPx() * progress,
+ chromaticAberration = true
+ )
+ }
+
+ // The slot: the page through it, frosted and filmed the way the tabs'
+ // copy used to bring it, then the wash, the rim and the shadow.
Box(
- Modifier
- .padding(horizontal = 4f.dp)
- .graphicsLayer {
- alpha = indicatorAlpha
- translationX =
- if (isLtr) dampedDragAnimation.value * tabWidth + panelOffset
- else size.width - (dampedDragAnimation.value + 1f) * tabWidth + panelOffset
- }
+ slotPlacement
.then(interactiveHighlight.gestureModifier)
.then(dampedDragAnimation.modifier)
.drawBackdrop(
- backdrop = rememberCombinedBackdrop(backdrop, tabsBackdrop),
+ backdrop = backdrop,
shape = { ContinuousCapsule() },
effects = {
- val progress = dampedDragAnimation.pressProgress
- lens(
- 10f.dp.toPx() * progress,
- 14f.dp.toPx() * progress,
- chromaticAberration = true
- )
+ vibrancy()
+ blur(8f.dp.toPx())
+ slotLens()
},
highlight = {
val progress = dampedDragAnimation.pressProgress
@@ -321,15 +331,10 @@ fun LiquidBottomTabs(
alpha = progress
)
},
- layerBlock = {
- scaleX = dampedDragAnimation.scaleX
- scaleY = dampedDragAnimation.scaleY
- val velocity = dampedDragAnimation.velocity / 10f
- scaleX /= 1f - (velocity * 0.75f).fastCoerceIn(-0.2f, 0.2f)
- scaleY *= 1f - (velocity * 0.25f).fastCoerceIn(-0.2f, 0.2f)
- },
+ layerBlock = slotLayer,
onDrawSurface = {
val progress = dampedDragAnimation.pressProgress
+ drawRect(containerColor)
drawRect(
indicatorColor ?: if (isLightTheme) Color.Black.copy(0.1f)
else Color.White.copy(0.1f),
@@ -341,5 +346,25 @@ fun LiquidBottomTabs(
.height(height - 8f.dp)
.fillMaxWidth(1f / tabsCount)
)
+
+ // LOCAL CHANGE: the lit tab, over its slot rather than under the wash.
+ //
+ // Bent by the same lens and stretched by the same drag, so while a
+ // finger is on the bar it still reads as one piece of glass; no rim or
+ // shadow of its own, those belong to the slot. Nothing takes touches
+ // here, so the slot underneath still gets them.
+ Box(
+ slotPlacement
+ .drawBackdrop(
+ backdrop = tabsBackdrop,
+ shape = { ContinuousCapsule() },
+ effects = slotLens,
+ highlight = null,
+ shadow = null,
+ layerBlock = slotLayer,
+ )
+ .height(height - 8f.dp)
+ .fillMaxWidth(1f / tabsCount)
+ )
}
}
diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt
index 7e08f39..2bc9c61 100644
--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt
@@ -148,7 +148,7 @@ fun PlayerPanelSection(
backdrop = backdrop,
tabsCount = views.size,
accentColor = GlassInk,
- containerColor = GlassFilm,
+ containerColor = PlayerFilm,
// Slimmer than the tab bar, and icon-only. This one sits under the
// transport rather than at the edge of the window, so it has to
// read as a smaller thing than the app's own navigation.
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.kt
index a4437d5..82d6db1 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
@@ -1071,7 +1071,7 @@ fun PlayerScreen(
) {
GlassSurface(
backdrop = glassBackdrop,
- surfaceColor = GlassFilm,
+ surfaceColor = PlayerFilm,
shape = RoundedCornerShape(50),
// The gap to the title lives here rather than
// in a spacer beside it: what a visibility
@@ -1112,7 +1112,7 @@ fun PlayerScreen(
// per-track actions on the right.
GlassSurface(
backdrop = glassBackdrop,
- surfaceColor = GlassFilm,
+ surfaceColor = PlayerFilm,
shape = RoundedCornerShape(50),
modifier = Modifier
.fillMaxWidth()
@@ -2107,6 +2107,16 @@ internal val GlassFilm: Color
Color.White.copy(alpha = 0.12f)
}
+/**
+ * The film on the player's own glass, which is always the dark one.
+ *
+ * The same tint the glass recipe puts under light ink, at the same strength,
+ * so the panes that draw their film themselves match the ones that get it from
+ * [GlassEffect]. Everywhere else the film follows the phone's setting; the
+ * player does not, see playerInk in SquareApp.
+ */
+internal val PlayerFilm = Color(0xFF23232A).copy(alpha = 0.5f)
+
/**
* The lyrics, centre stage.
*
diff --git a/native/src/engine.rs b/native/src/engine.rs
index 46c1be8..96e6eee 100644
--- a/native/src/engine.rs
+++ b/native/src/engine.rs
@@ -1958,7 +1958,11 @@ pub fn next() -> EngineResult<()> {
pub fn previous() -> EngineResult<()> {
leaving();
- transport("previous", |e| e.spirc()?.prev(), |e| e.player.stop())
+ // The track before, never a restart of this one: the app sends this only
+ // once it has decided to move back, by the position on its own screen,
+ // and a restart here left it one track behind the speaker. A restart is
+ // sent as a seek to zero instead.
+ transport("previous", |e| e.spirc()?.prev_track(), |e| e.player.stop())
}
diff --git a/native/vendor/librespot-connect/src/spirc.rs b/native/vendor/librespot-connect/src/spirc.rs
index a1ea9d3..1bf77a1 100644
--- a/native/vendor/librespot-connect/src/spirc.rs
+++ b/native/vendor/librespot-connect/src/spirc.rs
@@ -129,6 +129,9 @@ enum SpircCommand {
PlayPause,
Pause,
Prev,
+ /// LOCAL PATCH: the previous track, whatever the position; see
+ /// [`Spirc::prev_track`].
+ PrevTrack,
Next,
VolumeUp,
VolumeDown,
@@ -403,6 +406,18 @@ impl Spirc {
Ok(self.commands.send(SpircCommand::Prev)?)
}
+ /// LOCAL PATCH: goes to the previous track even past the first three
+ /// seconds.
+ ///
+ /// [`Spirc::prev`] decides between the previous track and the start of this
+ /// one by its own clock. The app has already made that decision by the
+ /// position on its screen, and when the two clocks disagree near the three
+ /// second line the app moved to the previous song while this restarted the
+ /// current one, which left the app a track behind the speaker from then on.
+ pub fn prev_track(&self) -> Result<(), Error> {
+ Ok(self.commands.send(SpircCommand::PrevTrack)?)
+ }
+
/// Skips to the next track.
///
/// Does nothing if we are not the active device.
@@ -851,6 +866,7 @@ impl SpircTask {
SpircCommand::PlayPause => self.handle_play_pause(),
SpircCommand::Pause => self.handle_pause(),
SpircCommand::Prev => self.handle_prev()?,
+ SpircCommand::PrevTrack => self.handle_prev_track()?,
SpircCommand::Next => {
// LOCAL PATCH: not if the queue has just moved on its own.
//
@@ -1931,15 +1947,7 @@ impl SpircTask {
// Under 3s it goes to the previous song (starts playing)
// Over 3s it seeks to zero (retains previous play status)
if self.position() < 3000 {
- let repeat_context = self.connect_state.repeat_context();
- match self.connect_state.prev_track()? {
- None if repeat_context => self.connect_state.reset_playback_to_position(None)?,
- None => {
- self.connect_state.reset_playback_to_position(None)?;
- self.handle_stop()
- }
- Some(_) => self.load_track(self.connect_state.is_playing(), 0)?,
- }
+ self.handle_prev_track()?;
} else {
self.handle_seek(0);
}
@@ -1947,6 +1955,22 @@ impl SpircTask {
Ok(())
}
+ /// LOCAL PATCH: the under-three-seconds half of [`Self::handle_prev`], on
+ /// its own; see [`Spirc::prev_track`].
+ fn handle_prev_track(&mut self) -> Result<(), Error> {
+ let repeat_context = self.connect_state.repeat_context();
+ match self.connect_state.prev_track()? {
+ None if repeat_context => self.connect_state.reset_playback_to_position(None)?,
+ None => {
+ self.connect_state.reset_playback_to_position(None)?;
+ self.handle_stop()
+ }
+ Some(_) => self.load_track(self.connect_state.is_playing(), 0)?,
+ }
+
+ Ok(())
+ }
+
fn handle_volume_up(&mut self) {
let volume = (self.connect_state.device_info().volume as u16)
.saturating_add(self.connect_state.volume_step_size);