[GH-ISSUE #1576] Sort songs in playlist by the time they were added #881

Open
opened 2026-02-26 02:34:31 +03:00 by kerem · 12 comments
Owner

Originally created by @jacobvdl on GitHub (Nov 7, 2022).
Original GitHub issue: https://github.com/koel/koel/issues/1576

Description
Sorting playlists in order of the time they were added (like spotify).

Example
Spotify has this with playlists.

Originally created by @jacobvdl on GitHub (Nov 7, 2022). Original GitHub issue: https://github.com/koel/koel/issues/1576 **Description** Sorting playlists in order of the time they were added (like spotify). **Example** Spotify has this with playlists.
Author
Owner

@phanan commented on GitHub (Nov 7, 2022):

Apart from "Spotify has it," what would be a reason for this "feature"?

<!-- gh-comment-id:1305711027 --> @phanan commented on GitHub (Nov 7, 2022): Apart from "Spotify has it," what would be a reason for this "feature"?
Author
Owner

@jacobvdl commented on GitHub (Nov 7, 2022):

It's a lot easier to organise songs this way rather than it being on
shuffle.

On Tue, 8 Nov 2022 at 01:08, Phan An @.***> wrote:

Except for "Spotify has it," what would be a reason for this "feature"?


Reply to this email directly, view it on GitHub
https://github.com/koel/koel/issues/1576#issuecomment-1305711027, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ALEBOMGNTUEUPFR4BBP3FBLWHEH6PANCNFSM6AAAAAARY5XRKQ
.
You are receiving this because you authored the thread.Message ID:
@.***>

<!-- gh-comment-id:1306297062 --> @jacobvdl commented on GitHub (Nov 7, 2022): It's a lot easier to organise songs this way rather than it being on shuffle. On Tue, 8 Nov 2022 at 01:08, Phan An ***@***.***> wrote: > Except for "Spotify has it," what would be a reason for this "feature"? > > — > Reply to this email directly, view it on GitHub > <https://github.com/koel/koel/issues/1576#issuecomment-1305711027>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ALEBOMGNTUEUPFR4BBP3FBLWHEH6PANCNFSM6AAAAAARY5XRKQ> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@phanan commented on GitHub (Nov 7, 2022):

I think the better way (which Spotify supports btw) is to be able to re-order the songs in playlists. This, however, isn't too high on my list.

<!-- gh-comment-id:1306314749 --> @phanan commented on GitHub (Nov 7, 2022): I think the better way (which Spotify supports btw) is to be able to re-order the songs in playlists. This, however, isn't too high on my list.
Author
Owner

@jacobvdl commented on GitHub (Nov 7, 2022):

Yeah that'd also be a good way to sort it.

On Tue, 8 Nov 2022 at 08:58, Phan An @.***> wrote:

I think the better way (which Spotify supports btw) is to be able to
re-order the songs in playlists. This, however, isn't too high on my list.


Reply to this email directly, view it on GitHub
https://github.com/koel/koel/issues/1576#issuecomment-1306314749, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ALEBOMAEDNJZUP4PZFOHL53WHF7CBANCNFSM6AAAAAARY5XRKQ
.
You are receiving this because you authored the thread.Message ID:
@.***>

<!-- gh-comment-id:1306389404 --> @jacobvdl commented on GitHub (Nov 7, 2022): Yeah that'd also be a good way to sort it. On Tue, 8 Nov 2022 at 08:58, Phan An ***@***.***> wrote: > I think the better way (which Spotify supports btw) is to be able to > re-order the songs in playlists. This, however, isn't too high on my list. > > — > Reply to this email directly, view it on GitHub > <https://github.com/koel/koel/issues/1576#issuecomment-1306314749>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ALEBOMAEDNJZUP4PZFOHL53WHF7CBANCNFSM6AAAAAARY5XRKQ> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@bilogic commented on GitHub (Jul 2, 2023):

Is there a way to rearrange the order of songs in a playlist?

<!-- gh-comment-id:1616675124 --> @bilogic commented on GitHub (Jul 2, 2023): Is there a way to rearrange the order of songs in a playlist?
Author
Owner

@Mark-Shternberg commented on GitHub (Aug 15, 2023):

This is really a very important thing that greatly affects on the UI convenience

<!-- gh-comment-id:1679423182 --> @Mark-Shternberg commented on GitHub (Aug 15, 2023): This is really a very important thing that greatly affects on the UI convenience
Author
Owner

@TylerCode commented on GitHub (Dec 11, 2023):

For now I've been using "Shuffle" on the Favorites, but I would like this feature since usually the songs I've just added to the favorites are the current "fire" I'm listening to so I want to listen to them either shuffled or in the order they were added.

<!-- gh-comment-id:1850700094 --> @TylerCode commented on GitHub (Dec 11, 2023): For now I've been using "Shuffle" on the Favorites, but I would like this feature since usually the songs I've just added to the favorites are the current "fire" I'm listening to so I want to listen to them either shuffled or in the order they were added.
Author
Owner

@eylvisaker commented on GitHub (Jan 17, 2024):

Apart from "Spotify has it," what would be a reason for this "feature"?

DJ'ing. From time to time, I DJ dance events. In this scenario, being able to replay a playlist in the order that I curated it is critical. I've been doing it in iTunes, and I want to get rid of it for obvious reasons. So I wrote some code to parse my iTunes library and upload it to my Koel instance, but since Koel doesn't preserve the ordering of songs, it's not fit for this purpose.

<!-- gh-comment-id:1896954678 --> @eylvisaker commented on GitHub (Jan 17, 2024): > Apart from "Spotify has it," what would be a reason for this "feature"? DJ'ing. From time to time, I DJ dance events. In this scenario, being able to replay a playlist in the order that I curated it is *critical*. I've been doing it in iTunes, and I want to get rid of it for obvious reasons. So I wrote some code to parse my iTunes library and upload it to my Koel instance, but since Koel doesn't preserve the ordering of songs, it's not fit for this purpose.
Author
Owner

@phanan commented on GitHub (Jan 17, 2024):

Good point. I will include it in a future version.

On Wed, Jan 17, 2024 at 22:51 Erik Ylvisaker @.***>
wrote:

Apart from "Spotify has it," what would be a reason for this "feature"?

DJ'ing. From time to time, I DJ dance events. In this scenario, being able
to replay a playlist in the order that I curated it is critical. I've
been doing it in iTunes, and I want to get rid of it for obvious reasons.
So I wrote some code to parse my iTunes library and upload it to my Koel
instance, but since Koel doesn't preserve the ordering of songs, it's not
fit for this purpose.


Reply to this email directly, view it on GitHub
https://github.com/koel/koel/issues/1576#issuecomment-1896954678, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AB5O3US7S4QMRTNJFOQDYTLYPBBW7AVCNFSM6AAAAAARY5XRKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJWHE2TINRXHA
.
You are receiving this because you were mentioned.Message ID:
@.***>

<!-- gh-comment-id:1896993151 --> @phanan commented on GitHub (Jan 17, 2024): Good point. I will include it in a future version. On Wed, Jan 17, 2024 at 22:51 Erik Ylvisaker ***@***.***> wrote: > Apart from "Spotify has it," what would be a reason for this "feature"? > > DJ'ing. From time to time, I DJ dance events. In this scenario, being able > to replay a playlist in the order that I curated it is *critical*. I've > been doing it in iTunes, and I want to get rid of it for obvious reasons. > So I wrote some code to parse my iTunes library and upload it to my Koel > instance, but since Koel doesn't preserve the ordering of songs, it's not > fit for this purpose. > > — > Reply to this email directly, view it on GitHub > <https://github.com/koel/koel/issues/1576#issuecomment-1896954678>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AB5O3US7S4QMRTNJFOQDYTLYPBBW7AVCNFSM6AAAAAARY5XRKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJWHE2TINRXHA> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@emmadesilva commented on GitHub (Feb 5, 2024):

Good point. I will include it in a future version.

So surprised to find that there is no way to order songs! The way Spotify has it is perfect, default to sort by date added, but allow reorder (so implementation-wise, the song order would default to an int based on the count songs in the playlist).

<!-- gh-comment-id:1927280447 --> @emmadesilva commented on GitHub (Feb 5, 2024): > Good point. I will include it in a future version. So surprised to find that there is no way to order songs! The way Spotify has it is perfect, default to sort by date added, but allow reorder (so implementation-wise, the song order would default to an int based on the count songs in the playlist).
Author
Owner

@phanan commented on GitHub (Feb 5, 2024):

This feature will land in the next version :)

On Mon, Feb 5, 2024 at 16:38 Caen De Silva @.***> wrote:

Good point. I will include it in a future version.

So surprised to find that there is no way to order songs! The way Spotify
has it is perfect, default to sort by date added, but allow reorder (so
implementation-wise, the song order would default to an int based on the
count songs in the playlist).


Reply to this email directly, view it on GitHub
https://github.com/koel/koel/issues/1576#issuecomment-1927280447, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AB5O3UQZBOVQL5KVSCFJW6TYSD4IXAVCNFSM6AAAAAARY5XRKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRXGI4DANBUG4
.
You are receiving this because you were mentioned.Message ID:
@.***>

<!-- gh-comment-id:1927317289 --> @phanan commented on GitHub (Feb 5, 2024): This feature will land in the next version :) On Mon, Feb 5, 2024 at 16:38 Caen De Silva ***@***.***> wrote: > Good point. I will include it in a future version. > > So surprised to find that there is no way to order songs! The way Spotify > has it is perfect, default to sort by date added, but allow reorder (so > implementation-wise, the song order would default to an int based on the > count songs in the playlist). > > — > Reply to this email directly, view it on GitHub > <https://github.com/koel/koel/issues/1576#issuecomment-1927280447>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AB5O3UQZBOVQL5KVSCFJW6TYSD4IXAVCNFSM6AAAAAARY5XRKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRXGI4DANBUG4> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@emmadesilva commented on GitHub (Feb 5, 2024):

This feature will land in the next version :)

Awesome! I made an embarrassingly crude patch for myself until then, if anyone dares to use it

public function index(Playlist $playlist)
   {
       $this->authorize('own', $playlist);

       // Get the raw songs data from the playlist as an array
       $rawSongsData = DB::table('songs')
           ->select('songs.*', 'playlist_song.order')
           ->join('playlist_song', 'songs.id', '=', 'playlist_song.song_id')
           ->join('playlists', 'playlists.id', '=', 'playlist_song.playlist_id')
           ->where('playlists.id', $playlist->id)
           ->orderBy('playlist_song.order')
           ->orderBy('songs.title')
           ->get()
           ->toArray();

       // Transform raw data into Song model instances
       $rawSongs = collect($rawSongsData)->map(function ($rawSong) {
           return new Song((array) $rawSong);
       });
   
       // Reorder the raw songs collection based on the 'order' value
       $orderedSongs = $rawSongs->sortBy('order');

       // Override the track value with the 'order' value
       $orderedSongs->each(function ($song, $index) {
           $song->track = $index + 1; // Assuming 1-based track numbering
       });

       // Transform the ordered collection into SongResource
       $return = SongResource::collection($orderedSongs);

       return $return;
   }
Schema::table('playlist_song', function (Blueprint $table) {
      $table->integer('order')->default(0);
  });

Still needs to have the priority set when adding to playlist, and also support reorder

<!-- gh-comment-id:1927360090 --> @emmadesilva commented on GitHub (Feb 5, 2024): > This feature will land in the next version :) Awesome! I made an embarrassingly crude patch for myself until then, if anyone dares to use it ```php public function index(Playlist $playlist) { $this->authorize('own', $playlist); // Get the raw songs data from the playlist as an array $rawSongsData = DB::table('songs') ->select('songs.*', 'playlist_song.order') ->join('playlist_song', 'songs.id', '=', 'playlist_song.song_id') ->join('playlists', 'playlists.id', '=', 'playlist_song.playlist_id') ->where('playlists.id', $playlist->id) ->orderBy('playlist_song.order') ->orderBy('songs.title') ->get() ->toArray(); // Transform raw data into Song model instances $rawSongs = collect($rawSongsData)->map(function ($rawSong) { return new Song((array) $rawSong); }); // Reorder the raw songs collection based on the 'order' value $orderedSongs = $rawSongs->sortBy('order'); // Override the track value with the 'order' value $orderedSongs->each(function ($song, $index) { $song->track = $index + 1; // Assuming 1-based track numbering }); // Transform the ordered collection into SongResource $return = SongResource::collection($orderedSongs); return $return; } ``` ```php Schema::table('playlist_song', function (Blueprint $table) { $table->integer('order')->default(0); }); ``` Still needs to have the priority set when adding to playlist, and also support reorder
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#881
No description provided.