Skip to content

Commit fa5f474

Browse files
committed
connect: restart the first track on previous instead of stopping (0.8.2)
1 parent 426fd82 commit fa5f474

13 files changed

Lines changed: 77 additions & 39 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- [audio] Fall back to the next CDN URL when a fetch returns a non-206 status (e.g. HTTP 530) instead of failing the track. Backport of upstream PR [#1722](https://github.com/librespot-org/librespot/pull/1722) for the spotatui fork.
1717
- [core] Fix dealer websocket reconnect leaving spirc hung on stale subscription channels. Port of upstream PR [#1692](https://github.com/librespot-org/librespot/pull/1692) for the spotatui fork.
1818
- [connect] Handle dealer reconnects in place without restarting spirc, and save/restore playback state across session loss (`Spirc::with_saved_state`). Part of the [#1692](https://github.com/librespot-org/librespot/pull/1692) port.
19+
- [connect] Skipping to the previous track from the first track of a context (under the 3-second mark) restarts that track instead of stopping playback, which left the player in a `Stopped` state that `play` could not leave. Fork-only; fixes spotatui [#366](https://github.com/LargeModGames/spotatui/issues/366).
20+
- [connect] Keep spirc's play status in sync with `PlayerEvent::Seeked`, so a seek issued directly on the `Player` no longer leaves `Spirc` reporting the pre-seek position (and misapplying the previous-track 3-second rule) until the next Playing/Paused event. Fork-only.
1921

2022
## [0.8.0] - 2025-11-10
2123

‎Cargo.lock‎

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ path = "src/main.rs"
143143
doc = false
144144

145145
[workspace.dependencies]
146-
librespot-audio = { version = "0.8.1", path = "audio", package = "spotatui-librespot-audio", default-features = false }
147-
librespot-connect = { version = "0.8.1", path = "connect", package = "spotatui-librespot-connect", default-features = false }
148-
librespot-core = { version = "0.8.1", path = "core", package = "spotatui-librespot-core", default-features = false }
146+
librespot-audio = { version = "0.8.2", path = "audio", package = "spotatui-librespot-audio", default-features = false }
147+
librespot-connect = { version = "0.8.2", path = "connect", package = "spotatui-librespot-connect", default-features = false }
148+
librespot-core = { version = "0.8.2", path = "core", package = "spotatui-librespot-core", default-features = false }
149149
librespot-discovery = { version = "0.8.0", path = "discovery", default-features = false }
150-
librespot-metadata = { version = "0.8.1", path = "metadata", package = "spotatui-librespot-metadata", default-features = false }
151-
librespot-oauth = { version = "0.8.1", path = "oauth", package = "spotatui-librespot-oauth", default-features = false }
152-
librespot-playback = { version = "0.8.1", path = "playback", package = "spotatui-librespot-playback", default-features = false }
153-
librespot-protocol = { version = "0.8.1", path = "protocol", package = "spotatui-librespot-protocol", default-features = false }
150+
librespot-metadata = { version = "0.8.2", path = "metadata", package = "spotatui-librespot-metadata", default-features = false }
151+
librespot-oauth = { version = "0.8.2", path = "oauth", package = "spotatui-librespot-oauth", default-features = false }
152+
librespot-playback = { version = "0.8.2", path = "playback", package = "spotatui-librespot-playback", default-features = false }
153+
librespot-protocol = { version = "0.8.2", path = "protocol", package = "spotatui-librespot-protocol", default-features = false }
154154

155155
[dependencies]
156156
librespot-audio.workspace = true

‎SPOTATUI_FORK.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ The publishing branch: upstream **v0.8.0** plus the patches spotatui needs.
4242
(external device handoff vs. unexpected loss vs. local stop) so spotatui can classify
4343
teardowns instead of inferring them. spotatui depends on this API; the fork cannot be
4444
swapped for upstream 0.8.
45+
- **Previous on the first track restarts it** (fork-only, 0.8.2): upstream's
46+
`handle_prev` stops playback when there is no previous track, stranding the player in
47+
`Stopped` (which `handle_play` cannot leave). Spotify's own clients restart the first
48+
track; the fork does the same. spotatui #366.
49+
- **Play status follows `PlayerEvent::Seeked`** (fork-only, 0.8.2): seeks issued directly
50+
on the `Player` (spotatui does this) now update spirc's play status, so its position and
51+
the previous-track 3-second rule stay accurate.
4552

4653
## Upstream status
4754

‎audio/Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spotatui-librespot-audio"
3-
version = "0.8.1"
3+
version = "0.8.2"
44
rust-version.workspace = true
55
authors = ["Paul Lietar <[email protected]>"]
66
license.workspace = true
@@ -18,7 +18,7 @@ rustls-tls-native-roots = ["librespot-core/rustls-tls-native-roots"]
1818
rustls-tls-webpki-roots = ["librespot-core/rustls-tls-webpki-roots"]
1919

2020
[dependencies]
21-
librespot-core = { version = "0.8.1", path = "../core", package = "spotatui-librespot-core", default-features = false }
21+
librespot-core = { version = "0.8.2", path = "../core", package = "spotatui-librespot-core", default-features = false }
2222

2323
aes = "0.8"
2424
bytes = "1"

‎connect/Cargo.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spotatui-librespot-connect"
3-
version = "0.8.1"
3+
version = "0.8.2"
44
rust-version.workspace = true
55
authors = ["Paul Lietar <[email protected]>"]
66
license.workspace = true
@@ -18,9 +18,9 @@ rustls-tls-native-roots = ["librespot-core/rustls-tls-native-roots"]
1818
rustls-tls-webpki-roots = ["librespot-core/rustls-tls-webpki-roots"]
1919

2020
[dependencies]
21-
librespot-core = { version = "0.8.1", path = "../core", package = "spotatui-librespot-core", default-features = false }
22-
librespot-playback = { version = "0.8.1", path = "../playback", package = "spotatui-librespot-playback", default-features = false }
23-
librespot-protocol = { version = "0.8.1", path = "../protocol", package = "spotatui-librespot-protocol", default-features = false }
21+
librespot-core = { version = "0.8.2", path = "../core", package = "spotatui-librespot-core", default-features = false }
22+
librespot-playback = { version = "0.8.2", path = "../playback", package = "spotatui-librespot-playback", default-features = false }
23+
librespot-protocol = { version = "0.8.2", path = "../protocol", package = "spotatui-librespot-protocol", default-features = false }
2424

2525
futures-util = { version = "0.3", default-features = false, features = ["std"] }
2626
log = "0.4"

‎connect/src/spirc.rs‎

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,31 @@ impl SpircTask {
806806
},
807807
PlayerEvent::Seeked { position_ms, .. } => {
808808
trace!("==> Seeked");
809-
self.connect_state
810-
.update_position(position_ms, self.now_ms())
809+
let now = self.now_ms();
810+
self.connect_state.update_position(position_ms, now);
811+
// spotatui fork: a seek issued directly on the player (not via
812+
// `handle_seek`) never touched `play_status`, so `position()`
813+
// kept reporting the pre-seek position until the next
814+
// Playing/Paused event. That skews everything derived from it,
815+
// notably the 3-second rule in `handle_prev`. Mirror what
816+
// `handle_seek` does with the position the player confirmed.
817+
match self.play_status {
818+
SpircPlayStatus::Stopped => (),
819+
SpircPlayStatus::LoadingPause {
820+
position_ms: ref mut position,
821+
}
822+
| SpircPlayStatus::LoadingPlay {
823+
position_ms: ref mut position,
824+
}
825+
| SpircPlayStatus::Paused {
826+
position_ms: ref mut position,
827+
..
828+
} => *position = position_ms,
829+
SpircPlayStatus::Playing {
830+
ref mut nominal_start_time,
831+
..
832+
} => *nominal_start_time = now - position_ms as i64,
833+
}
811834
}
812835
PlayerEvent::Playing { position_ms, .. }
813836
| PlayerEvent::PositionCorrection { position_ms, .. } => {
@@ -1740,14 +1763,20 @@ impl SpircTask {
17401763
// Under 3s it goes to the previous song (starts playing)
17411764
// Over 3s it seeks to zero (retains previous play status)
17421765
if self.position() < 3000 {
1743-
let repeat_context = self.connect_state.repeat_context();
17441766
match self.connect_state.prev_track()? {
1745-
None if repeat_context => self.connect_state.reset_playback_to_position(None)?,
1767+
Some(_) => self.load_track(self.connect_state.is_playing(), 0)?,
1768+
// spotatui fork: nothing before the first track. Upstream stops
1769+
// playback here (and merely resets the state under repeat
1770+
// context), which strands the player in `Stopped`, a state
1771+
// `handle_play` cannot leave without a fresh load. Spotify's
1772+
// own clients restart the first track instead, so do the same:
1773+
// reset the state to the context start and load it. Loading
1774+
// the track that is already playing is a seek inside the
1775+
// player, so the audio pipeline stays up.
17461776
None => {
17471777
self.connect_state.reset_playback_to_position(None)?;
1748-
self.handle_stop()
1778+
self.load_track(self.connect_state.is_playing(), 0)?
17491779
}
1750-
Some(_) => self.load_track(self.connect_state.is_playing(), 0)?,
17511780
}
17521781
} else {
17531782
self.handle_seek(0);

‎core/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spotatui-librespot-core"
3-
version = "0.8.1"
3+
version = "0.8.2"
44
rust-version.workspace = true
55
authors = ["Paul Lietar <[email protected]>"]
66
license.workspace = true
@@ -40,8 +40,8 @@ rustls-tls-webpki-roots = [
4040
__rustls = []
4141

4242
[dependencies]
43-
librespot-oauth = { version = "0.8.1", path = "../oauth", package = "spotatui-librespot-oauth", default-features = false }
44-
librespot-protocol = { version = "0.8.1", path = "../protocol", package = "spotatui-librespot-protocol", default-features = false }
43+
librespot-oauth = { version = "0.8.2", path = "../oauth", package = "spotatui-librespot-oauth", default-features = false }
44+
librespot-protocol = { version = "0.8.2", path = "../protocol", package = "spotatui-librespot-protocol", default-features = false }
4545

4646
aes = "0.8"
4747
base64 = "0.22"

‎discovery/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rustls-tls-native-roots = ["librespot-core/rustls-tls-native-roots"]
2424
rustls-tls-webpki-roots = ["librespot-core/rustls-tls-webpki-roots"]
2525

2626
[dependencies]
27-
librespot-core = { version = "0.8.1", path = "../core", package = "spotatui-librespot-core", default-features = false }
27+
librespot-core = { version = "0.8.2", path = "../core", package = "spotatui-librespot-core", default-features = false }
2828

2929
aes = "0.8"
3030
base64 = "0.22"

‎metadata/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spotatui-librespot-metadata"
3-
version = "0.8.1"
3+
version = "0.8.2"
44
rust-version.workspace = true
55
authors = ["Paul Lietar <[email protected]>"]
66
license.workspace = true
@@ -18,8 +18,8 @@ rustls-tls-native-roots = ["librespot-core/rustls-tls-native-roots"]
1818
rustls-tls-webpki-roots = ["librespot-core/rustls-tls-webpki-roots"]
1919

2020
[dependencies]
21-
librespot-core = { version = "0.8.1", path = "../core", package = "spotatui-librespot-core", default-features = false }
22-
librespot-protocol = { version = "0.8.1", path = "../protocol", package = "spotatui-librespot-protocol", default-features = false }
21+
librespot-core = { version = "0.8.2", path = "../core", package = "spotatui-librespot-core", default-features = false }
22+
librespot-protocol = { version = "0.8.2", path = "../protocol", package = "spotatui-librespot-protocol", default-features = false }
2323

2424
async-trait = "0.1"
2525
bytes = "1"

0 commit comments

Comments
 (0)