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.
I'm having an issue I can't resolve with the [b]addTrackAsync [/b]method in MM5. I'm able to add tracks but the order is always an alpha order on the [b]TrackNumber [/b]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 [b]DiscNumber [/b]and the [b]TrackNumber[/b] and looking at the [i]asJSON[/i] they are indeed ordered correctly but when passed to the addTrackAsync method they're being reorder as if the [b]TrackNumber [/b]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 [b]TrackNumber [/b]was alpha but with the ORDER BY they are definitely sorted by [b]TrackNumber [/b]numerically.
This is being done in Javascript where previously this worked as intended using the COM objects in MM4 using [i]newSongList = SDB.NewSongList and then SDB.Player.PlaylistAddTracks(newSongList )[/i].
[code]
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, {});
});
[/code]
Any suggestion on how to control the sort order what adding to the playlist would be appreciated.