Skip to content

Conversation

@teamcons
Copy link
Contributor

@teamcons teamcons commented May 27, 2025

Fixes #792

This is not ready yet.
The new key in gschema does not seem to install at all. I am trying to figure this out.

-After constructing the window and adding all the signals, when everything is ready, start loading previous queue
-Handle a close request for the window, the handler slorps everything in the queue in gsettings

alternatively i could change the plumbing to have the app save in realtime whenever the liststore gets changed. This would keep state despite a crash, but it feels gross constantly writing to gsettings

@teamcons
Copy link
Contributor Author

Oh! I know why it didnt work!

@teamcons
Copy link
Contributor Author

This one works but
-Music starts playing at the item "0" instead of the one that was playing last time (im fixing this now)
-Music starts playing the queue, when a music file is opened, instead of the file itself (seems to be Music default behaviour? Same when opening with the app already on)

Note: I went with a fixed array size from start, forloop and assigning the array to parse instead of adding to an empty array while parsing
Ive heard it is more efficient because the slots are assigned in memory already and the app does not need to constantly rebuilt it. But i may be wrong.
I can imagine cases where people have thousand files to restore.

@teamcons
Copy link
Contributor Author

teamcons commented May 27, 2025

Okay
I need to figure how to start playing a track in the liststore at a specific position (Int)
I will do that tomorrow. But saving/restoring works

@danirabbit thank you very much for your feedback. Learning how to properly integrate stuff in the sane/right places thanks to you.

var play_pause_action = (SimpleAction) GLib.Application.get_default ().lookup_action (Application.ACTION_PLAY_PAUSE);
play_pause_action.set_enabled (current_audio != null);

settings.set_string ("uri-last-played", current_audio.uri);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we just bind this instead of getting and setting in different places?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"uri-last-played" gets overwritten before being used. But apart from that, yes i suppose, but do not forget this is a draft - i want first to have something that works (im failing at it), before making it clean.

Comment on lines +123 to +126
PlaybackManager.get_default ().restore_queue ();

settings.set_string ("uri-last-played", uri_last_played);
PlaybackManager.get_default ().restore_last_played ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to have this be two separate functions? We always want to restore both the previous queue and the previously played audio right?

Copy link
Contributor Author

@teamcons teamcons May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No
If the user double-click on a music file with the app closed, they want to play it - not play last week's track

restoring previous queue without previous played makes sense in this case, before adding the new track, but the expected behaviour is not to play another totally unrelated track.
this is kind of a problem introduced by restoring sessions, because before the queue would have always been empty, unless the app was already started

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah that makes sense. Thanks for clarifying!

@teamcons
Copy link
Contributor Author

So i can save the stupid last played track. Reliably.
but i cannot figure out how to tell playback to say "please play this AudioObject ive set as current_audio"

@teamcons
Copy link
Contributor Author

Yes. I cant figure this out.
Giving up on this PR. If anyone want to pick up from here please do.

@teamcons
Copy link
Contributor Author

Should i close the PR ? Sorry im useless i thought i could tackle this, but it just doesnt care whatever i set as current audio or call, it will always reset to 0 after the activate()

@danirabbit
Copy link
Member

Please leave the PR up. I'll take a look when I get a moment. You're definitely not useless! It seems like you're really close. Be kind to yourself 🩷

@danirabbit
Copy link
Member

@teamcons okay, so we can get some stuff merged, what do you think about breaking this up into 3 branches?

  • A branch to do the refactoring parts in PlaybackManager: moving those bits from lambdas into functions
  • A branch to restore the queue
  • A branch to restore the last played track

That way we can merge in the stuff that's working now and scope things down a bit so it doens't feel as overwhelming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore last queue

2 participants