[Feature Request] Remember playback state on close
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
GSettingsto 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
StateTrackerstruct that listens for events and saves them, butGSettingsprovides ways to do that automatically usingbind
- I thought of a
You can see a proof of concept in my fork
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.
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 :)