spot icon indicating copy to clipboard operation
spot copied to clipboard

[Feature Request] Remember playback state on close

Open Diegovsky opened this issue 3 years ago • 3 comments

I had implemented this before in a private branch of mine but it wasn't very clean.

I'm mostly refering to shuffle and repeat mode, but we can remember last playlist played or something else too.

I have a few questions on how to implement this:

  • Since this is related to state, should we even use GSettings to store that?
  • Since MPRIS and our playback state need to be in sync, should we broadcast PlaybackActions at the start?
  • Assuming we use GSettings, how do we update it when the user changes shuffle or repeat mode?
    • I thought of a StateTracker struct that listens for events and saves them, but GSettings provides ways to do that automatically using bind

Diegovsky avatar May 05 '22 12:05 Diegovsky

You can see a proof of concept in my fork

Diegovsky avatar May 05 '22 17:05 Diegovsky

I agree this would be very useful!

We probably don't have to dump the whole state to a file or GSettings, and some parts of it aren't serializable. PlaybackState.source is probably enough to at least reconstruct what was playing -- except if it was a random play queue. From a source, we can get a first batch of songs with BatchLoader and then we can dispatch LoadPagedSongs + Load

As for a random play queue... maybe this could be saved somewhere automatically, and we could have a new source type for this.

xou816 avatar Feb 18 '23 18:02 xou816

I'll have to severely rework my POC then. I'll look more closely into BatchLoader code & co you suggested. Will take a while though :)

Diegovsky avatar Feb 20 '23 13:02 Diegovsky