Skip to content
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

Non-Standard Behavior in Rewind Button (intentional?) #539

Closed
Colonial-Dev opened this issue Jul 20, 2022 · 3 comments
Closed

Non-Standard Behavior in Rewind Button (intentional?) #539

Colonial-Dev opened this issue Jul 20, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Colonial-Dev
Copy link
Contributor

Describe the bug
When invoking the "rewind"/previous track command (either through the Spot UI or dedicated keyboard buttons), Spot will skip directly to the previous song in the playlist. AFAIK this is non-standard behavior for a music player; typically the rewind command skips to the start of the current song unless it's only a few seconds in, in which case then it goes to the previous song.

General information:

  • Distribution: Fedora 36
  • Installation method [e. g. built from source, installed from Flathub...]: Flathub
  • Version [e.g. 0.1.0]: 0.3.3
  • Device used [e. g. desktop, phone...]: Desktop

I'd also like to note that I'm willing to try my hand at changing this myself, as a way to get more familiar with Rust. I just wanted to open an issue first to ensure this wasn't an intentional design choice.

@Colonial-Dev Colonial-Dev added the bug Something isn't working label Jul 20, 2022
@xou816
Copy link
Owner

xou816 commented Feb 18, 2023

sorry for the late answer but yeah, you're right, this behaviour should be fixed!

@xou816 xou816 added the good first issue Good for newcomers label Feb 18, 2023
@Colonial-Dev
Copy link
Contributor Author

Awesome, I'll fork it and give it a whirl. Any pointers as to where I should look first?

@xou816
Copy link
Owner

xou816 commented Feb 18, 2023

Sure! I see two possibilities right now

Solution 1: in playback_state.rs you'll see the logic of how playback related actions are handled. If using the UI or controlling Spot via MPRIS (eg with your keyboard) a PlaybackAction::Previous will be issued.

Right now this updates the state to point to the previous song if there is one. Instead it could be changed to check whether something has been playing for "long enough", in which case the action should do the same thing as PlaybackAction::Seek(0).

This requires modifying the PlaybackState so that it knows the current track position (it does not at the moment), which could be implemented with a similar strategy as PositionMicros in the dbus part of the app (it's a struct that keeps track of the moment we hit play or pause to estimate how far along the track is).

Solution 2 : let various parts of the app handle this. The PlaybackWidget knows the current position, and would be able to issue a PlaybackAction::Seek(0) instead of PlaybackAction::Previous when appropriate. Same with the previous method in mpris.rs, it could choose to send the right action based on the position (estimated with PositionMicros).

It's probably better to go with the first solution, it should be easy to start by having something similar to PositionMicros in the PlaybackState and updating it for the relevant actions (see how MprisState updates the position estimation for instance).

Hope this helps!

@xou816 xou816 added enhancement New feature or request and removed bug Something isn't working labels Feb 18, 2023
@xou816 xou816 closed this as completed in 99b448e Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants