mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[PR #127] [MERGED] Improved next/prev handling for queued tracks. (v2) #796
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#796
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/librespot-org/librespot/pull/127
Author: @kingosticks
Created: 2/8/2018
Status: ✅ Merged
Merged: 2/10/2018
Merged by: @plietar
Base:
master← Head:fix/skipping-with-queued-tracks📝 Commits (1)
d05fa10Improved next/prev handling for queued tracks.📊 Changes
1 file changed (+40 additions, -14 deletions)
View changed files
📝
src/spirc.rs(+40 -14)📄 Description
My original PR at https://github.com/librespot-org/librespot/pull/119 got all screwed up when I changed my fork from plietar/librespot to librespot-org/librespot. So here it is again.
A queued track is removed once it has become the current track.
Note that the track doesn't need to actually play i.e. it could
have been immediately skipped over with
next(). This isimplemented in
consume_queued_track().Queued tracks are always positioned immediately after the current
track. 1) ensures this is true for
next()butprev()requiresall the queued tracks are actually moved for this to remain the
case.
Also fixed the case where
prev()on the first track would incorrectlywrap back around to the last track even when repeat was disabled. The
correct behaviour is to remain on the first track and just seek to the
start.
For example, with the following tracks and repeat enabled:
Here, the result of
prevchanges the current track from TrackB toTrackA and the queued tracks (TrackC, TrackD) move to the position
immediately after TrackA:
Calling
prevagain results in the current track wrapping back aroundto TrackE and the queued tracks moving after that same track:
After looking again at what @plietar suggested at https://github.com/librespot-org/librespot/pull/119#discussion_r166569148 I agree it does make things neater. So I refactored the code a bit to make full use of that. And added some more comments.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.