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

Add a 'shuffle all' button for songs in webUI #256

Closed
stncrn opened this issue Apr 30, 2020 · 7 comments
Closed

Add a 'shuffle all' button for songs in webUI #256

stncrn opened this issue Apr 30, 2020 · 7 comments

Comments

@stncrn
Copy link
Contributor

stncrn commented Apr 30, 2020

I often like to listen to my whole music library, in random order.

Doing so with the current song page is almost impossible. The bulk action is only applied to the selected elements of the current page of the song list. So you have to select all on the first page, add to queue, go to the second page, repeat...

I already tried to implement the feature. The steps were:

  • Adding the button, as action in the list. This button uses the exporter feature of the list, to be able to access all records, and not only the displayed (ids) or selected (selectedIds) ones.
  • Using the dataProvider to call the API to get the songs from the song ids. I had to do this by chunks to avoid a 'too many SQL variables error on the API'. I also inserted the shuffeling here.
  • Adding 2 actions to the player:
    • addTracks, that mimics addTrack: I had to do this to limit the number of calls to the dispatch function
    • clearQueue: very basic, to clear the queue only once, before adding all the songs in it

The current commit is here: stncrn@0ea60b7

However, it is not ready for a pull request:

  • This was my very first experience with react, redux, react-admin. So I guess some things could have been done in a better way.
  • The processing time is slow: the first 2000 songs are added almost instantly to the queue, but the following ones are added slower and slower. It's still acceptable with the 6k library I used, but it would be a big issue with bigger ones. I made a quick demo video of the current implementation in action:
    https://vimeo.com/413592965

It would be very great to have this feature added in Navidrome, and I hope that this preliminary work will help.

@deluan
Copy link
Member

deluan commented Apr 30, 2020

Thanks for taking a stab at this. My concern with this approach is the issue you already observed: It does not scale. My library for example has ~40K songs, and we have some users with more than 170K songs!!!!

I would implement this in a way similar to what Jamstash and DSub do: Have an option to generate a random playlist, where you can limit the size (no more than 1000), and even add some filters. This could be a dialog box in the Songs view, or part of the upcoming Playlist management feature.

Regarding your implementation, it is really good, specially for a first timer. The only thing I would change (not considering the whole "not-scaleable" approach) is to move the shuffling to an action, so instead of dispatching addTracks we would dispatch shuffleTracks. This would be more consistent to how we shuffle albums, for example. But again, I don't think we can make it scalable so I would think about a different approach.

@deluan
Copy link
Member

deluan commented May 5, 2020

Hey @stncrn, what do you think about adding an option to the song endpoint that retrieves up to 1000 random songs, possibly with genre, year and artist filters? Then instead of loading all songs and randomize it in the UI, you'd get the list already randomized from the server, with one call. IMHO, 1000 random songs is enough for a listening session (+2 days of music!)

Let me know your thoughts about this, it would be pretty straightforward to implement this endpoint

@deluan
Copy link
Member

deluan commented May 5, 2020

I already implemented the option in the song endpoint here: c585ca7. Just specify random as the sort field. Ex:

    dataProvider
      .getList('song', {
        pagination: { page: 1, perPage: 1000 },
        sort: { field: 'random', order: 'ASC' },
        filter: { },
      })

Keep in mind that there is no default limit for the perPage parameter, so you could potentially set it to -1 to retrieve all songs!. I may impose a limit to this (and to all other) endpoint, probably around 1000 items, as I said before.

Feel free to experiment with this.

@stncrn
Copy link
Contributor Author

stncrn commented May 8, 2020

Sorry, hadn't have a lot a free time recently.

You're definitely right, 1000 songs are more than enough. I didn't know that dSub was only creating a partial playlist when using the random button.

Great to see that you advanced on adding a random selection method on the song provider! I definitely did not thought it would be as simple.

I'll try to use it this weekend, and make the "shuffle (almost-)all" button finally usable.

@deluan deluan closed this as completed in 0730c66 Aug 7, 2020
@deluan
Copy link
Member

deluan commented Aug 7, 2020

Commit 0730c66 implements a basic "Shuffle All" button, similar to what @stncrn proposed above. It plays up to 200 songs in random order.

This functionality may evolve in the future, with options like max num songs, filter by genres, artists...

@mmatasic
Copy link

mmatasic commented Sep 5, 2022

Can something similar be added for the album view?

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants