app.player.addTracksAsync track ordering issue [#18167]

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: app.player.addTracksAsync track ordering issue [#18167]

Re: app.player.addTracksAsync track ordering issue [#18167]

by MyVikes » Sun Jul 25, 2021 1:50 pm

thx for the response

Re: app.player.addTracksAsync track ordering issue

by Ludek » Sun Jul 25, 2021 8:00 am

Hi, based on my tests it is the app.db.getTracklist() that does not respect the SQL order.

I used code:

Code: Select all

var tracklist = app.db.getTracklist("SELECT * FROM Songs WHERE PlayCounter > 0 ORDER BY SongTitle", -1);
        tracklist.whenLoaded().then(function () {
            console.log("tracklist count:" + tracklist.count);
            console.log("tracklist asJSON:", tracklist.asJSON);
            app.player.addTracksAsync(tracklist, {});
        });
... and even the tracklist.asJSON has already incorrect order (not by title).
app.player.addTracksAsync does not change the order further.

To be fixed as: https://www.ventismedia.com/mantis/view.php?id=18167

Thanks for reporting!

app.player.addTracksAsync track ordering issue [#18167]

by MyVikes » Sat Jul 24, 2021 8:39 am

I'm having an issue I can't resolve with the addTrackAsync method in MM5. I'm able to add tracks but the order is always an alpha order on the TrackNumber versus the order of the tracks as specified in the query. You can see in the code below were i add an ORDER BY on the DiscNumber and the TrackNumber and looking at the asJSON they are indeed ordered correctly but when passed to the addTrackAsync method they're being reorder as if the TrackNumber was alpha. So the in the playlist the sequence becomes 1, 10, 11, 2, 3, etc.

Without the ORDER BY I will see the tracks sorted as if the TrackNumber was alpha but with the ORDER BY they are definitely sorted by TrackNumber numerically.

This is being done in Javascript where previously this worked as intended using the COM objects in MM4 using newSongList = SDB.NewSongList and then SDB.Player.PlaylistAddTracks(newSongList ).

Code: Select all

let sql = "SELECT * FROM Songs WHERE IDAlbum = 12 ORDER BY CAST(DiscNumber as int), CAST(TrackNumber as int) ";

// also tried forcing the TrackNumber to have leading zeros in the ORDER BY (i.e. 1=001, 11=011, etc.)
//let sql = "SELECT printf('%03.0f', TrackNumber ) , * FROM Songs WHERE IDAlbum = 20 ORDER BY CAST(DiscNumber as int), printf('%03.0f', TrackNumber ) ";

console.log("selectAlbum sql:", sql);

var tracklist = app.db.getTracklist(sql, -1);

tracklist.whenLoaded().then(function () {
    console.log("selectAlbum tracklist count:" + tracklist.count);

    console.log("selectAlbum tracklist asJSON:", tracklist.asJSON);

    app.player.addTracksAsync(tracklist, {});
});
Any suggestion on how to control the sort order what adding to the playlist would be appreciated.

Top