First off. Is there an API command that replicates the Right Click->Play More->Play Album Now option? If there is you can probably ignore the rest of the post.
Edit: Before you waste time reading this stupidly long post. I fixed the problem. Solution posted below.
I couldn't find one so I used the following code to try and replicate it.
Plugin.MbApiInterface.Library_QueryFilesEx("AlbumUniqueId=" + uniqueAlbumId, out songsList);
if (songsList.Length > 0)
{
Plugin.MbApiInterface.NowPlayingList_PlayNow(songsList[0]);
if (songsList.Length > 1)
{
songsList = songsList.Skip(1).ToArray();//remove first song from array
Plugin.MbApiInterface.NowPlayingList_QueueFilesNext(songsList);
}
}
Ok strap in, this is going to be a bastard to explain.
When the now playing list is empty. This works as intended. But if the list is populated and already playing something, instead of playing the first song from the album I am trying to play now, it just starts playing whatever the next song in the now playing list was and queues up all the songs from the album I select next. But it puts the first song at the end of the current album in the list.
This might be a better way to explain it. Each letter is songs from an album in the now playing list. E is one album, D is another etc...
Lets say the list looks like the following and the * is the current song playing.
D*
D
D
D
F
F
F
Now if I want to play album now for Album G.
Instead of looking like this -
D
G*
G
G
G
D
D
D
F
F
F
It looks like this -
D
D*
G
G
G
D
D
G <-- this song should be playing now. But instead it's inserted after Album D.
F
F
F
This only occurs if I try play now(using my code above) on 2 albums in a row without letting the song change. If I play now on an album, let the song fully play through so it goes to a second song, then play now on a second album, it will work correctly. Or I can manually double click a different song then play now on a second album and it works. It's only if I play now on an album and then try a second album while that first song is still playing. And it doesn't appear to matter how far through that song has played.
Also
Plugin.MbApiInterface.Library_QueryFilesEx("AlbumUniqueId=" + uniqueAlbumId, out songsList);
The output string array is not in track number order. Is there a way to do that or do I have to query all the songs in the array to sort it myself?
Using the Right Click->Play More->Play Album Now option works as you would expect and queues the songs in track number order.
It's a strange one.
edit: Ok I might be wrong about the track number order. It does appear to be in order for most but I do have one album that seems to be out of order. But it only has 3 tracks labelled as 2 of 11, 5 of 11 and 11 of 11. The last 2 are out of order, I'll do some more testing on that one.
edit2: So most albums are coming through in track order but lucky me the first one I just happened to test initially did not. I've tried a bunch of things but they don't come through in track order.
The album Arrival by ABBA. I only have 3 songs in this library from that album
Dancing Queen track 2 of 11
Knowing Me Knowing You track 5 of 11
Fernando track 11 of 11
All other info for each track is the same. Sorting tab is the same. But for whatever reason, Fernando always comes through second in the array instead of third.
Tried changing the track numbers to 1, 2, 3. deleting the 11 field. I even renamed the file names to put the track numbers at the start of the song name like the rest of the library has and Fernando still comes through second.
I can go through and sort them myself but figured you might be interested if it's not working as intended.