-
-
Notifications
You must be signed in to change notification settings - Fork 27
Fix playback always starts from the first track of a playlist when using external device #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
46105b3
a1652e0
d1c1f9c
b45bd80
a5cec90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,13 +7,15 @@ use chrono::TimeDelta; | |||||||||||||||
| use rspotify::model::{ | ||||||||||||||||
| enums::RepeatState, | ||||||||||||||||
| idtypes::{PlayContextId, PlayableId}, | ||||||||||||||||
| PlayableItem, | ||||||||||||||||
| Offset, PlayableItem, | ||||||||||||||||
| }; | ||||||||||||||||
| use rspotify::prelude::*; | ||||||||||||||||
| use std::time::{Duration, Instant}; | ||||||||||||||||
|
|
||||||||||||||||
| #[cfg(feature = "streaming")] | ||||||||||||||||
| use librespot_connect::{LoadRequest, LoadRequestOptions, PlayingTrack}; | ||||||||||||||||
| #[cfg(feature = "streaming")] | ||||||||||||||||
| use std::sync::Arc; | ||||||||||||||||
|
|
||||||||||||||||
| const MAX_API_PLAYBACK_URIS: usize = 100; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -69,26 +71,43 @@ fn trim_api_playback_uris( | |||||||||||||||
| (trimmed_uris, Some(selected_index - start)) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| fn api_playback_offset( | ||||||||||||||||
| context_uris: Option<&[PlayableId<'static>]>, | ||||||||||||||||
| offset: Option<usize>, | ||||||||||||||||
| ) -> Option<Offset> { | ||||||||||||||||
| if let Some(first_uri) = context_uris.and_then(|uris| uris.first()) { | ||||||||||||||||
| return Some(Offset::Uri(first_uri.uri())); | ||||||||||||||||
|
Comment on lines
+78
to
+79
|
||||||||||||||||
| if let Some(first_uri) = context_uris.and_then(|uris| uris.first()) { | |
| return Some(Offset::Uri(first_uri.uri())); | |
| if let Some(uris) = context_uris { | |
| let index = offset.unwrap_or(0); | |
| if let Some(selected_uri) = uris.get(index).or_else(|| uris.first()) { | |
| return Some(Offset::Uri(selected_uri.uri())); | |
| } |
LargeModGames marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test api_playback_offset_uses_track_uri_for_context_playback passes offset = Some(1) but asserts that the first URI is used. If api_playback_offset is updated to honor offsets for multi-URI context playback (recommended), this test will start failing for the right reason. Adjust/add test cases to explicitly cover offset=0 vs offset=1 selection (and any bounds/fallback behavior) instead of encoding offset-ignoring behavior.
Uh oh!
There was an error while loading. Please reload this page.