nuclear icon indicating copy to clipboard operation
nuclear copied to clipboard

Resume last played music on queue when reopening the app

Open sith-on-mars opened this issue 1 year ago • 14 comments

Currently, if you play music on a queue, reopening the app will lead to the loss of the queue history. It would be great if the app could resume last played music on the queue and keep queue history, unless the user change to another queue or playlist. So basically the app can emulate default Sportify player does.

sith-on-mars avatar Mar 24 '23 13:03 sith-on-mars

Thanks for the suggestion, this is a good idea.

nukeop avatar Mar 29 '23 08:03 nukeop

Hi I would like to work on this issue.

DxVxDOD avatar Mar 29 '23 21:03 DxVxDOD

Hi @sith-on-mars, I would like to contribute on this issue if it is still opened.

fastio19 avatar Apr 16 '23 07:04 fastio19

Hi is this issue still open I can start working for it

mjsf1234 avatar May 18 '23 14:05 mjsf1234

No, someone is working on it.

nukeop avatar May 18 '23 14:05 nukeop

@nukeop i checked all accounts, no one seems to be actively working on this issue for over a month, i don't want to be rude to anyone but if no one's working on it, i would love to take it.

thank you.

vinay94185 avatar May 24 '23 18:05 vinay94185

There's an open pull request on this.

nukeop avatar May 24 '23 19:05 nukeop

thanks for update. i see it.

vinay94185 avatar May 25 '23 05:05 vinay94185

Can I be assigned this.

sameer-haider avatar Jun 20 '23 14:06 sameer-haider

Hi @nukeop, since I do not think someone is working on this issue currently. I would like to work on it. I wanted to know where should the queue's state be stored, so that it can be retrieved once the app closes and reopens?

SamarthBagga avatar Jul 21 '23 15:07 SamarthBagga

This would be the 5th time I'm assigning someone to this issue.

nukeop avatar Jul 21 '23 16:07 nukeop

hi @nukeop , there is no need to assign the issue to me. I am not sure yet if ill be able to provide a fix, I am just trying to grasp the issue and trying to find a fix. If I am able to come up with a fix, I'll make a PR.

All I wanted to know is that where should I store the queue's state so that it can be retreieved once the app closes and then reopens?

SamarthBagga avatar Jul 21 '23 17:07 SamarthBagga

I'm going to paste what I said on Discord:

  • it should probably be contained in the app package
  • last time someone tried this I suggested implementing a redux subscriber that listens to anything related to adding/removing/swapping tracks in the queue, and saves it in a json file. If you search by subscribe you should find existing subscribers to get an idea how to use them.
  • this can either be a separate file (using electron-store) or in the regular config file, just make sure that the write is non-blocking
  • if possible, use atomic writes* to ensure the queue is never corrupted
  • the program should read the queue when starting, and if it fails it should simply start with a blank one
  • ideally, there should be a setting that controls whether this feature is enabled
  • This is obviously a lot of work, so it's fine (and encouraged) to do this stage by stage, and not a problem if you don't do all of this.

* explanation:

Atomic saving is a method used in programming to safely update files. Instead of directly modifying the original file, atomic saving writes changes to a new temporary file. Once the changes are successfully written, the original file is replaced with the new file in a single operation. This ensures that if anything goes wrong during the process, the original file remains unchanged, preventing data corruption.

This is going to be a moderately-sized piece of code that's going to take probably at least 2-3 hours to implement.

nukeop avatar Jul 21 '23 18:07 nukeop

okay, I'll get started on it. thank you!

SamarthBagga avatar Jul 22 '23 04:07 SamarthBagga