Author Topic: MusicBee API  (Read 195477 times)

dandepeched

  • Jr. Member
  • **
  • Posts: 29
NowPlayingList_MoveFiles uses the same internal functions as manually drag/dropping files, however i do see one inconsistency.
Does this version work better?
https://getmusicbee.com/patches/MusicBee34_Patched.zip

Unfortunately no, same result  :(
By the way _api.NowPlayingList_RemoveAt(index) works fine, which makes me think that retrieved indexes are correct.
Also NowPlayingList_MoveFiles works fine when Shuffle is off (so the indexes go in natural order)

If not, are you saying that you are comparing NowPlayingList_QueryFiles(null) before and after the operation that its shuffled? If so, I dont see how that would have been case so could you explain how you determined the list is re-shuffled?

I'm not comparing it in code, I see it re-shuffled in player. I think it makes sense to share the code:
1) To get Now Playing list and appropriate track indexes:
Code
public void RequestNowPlayingListOrdered(string clientId, int offset = 0, int limit = 100)
        {
            _api.NowPlayingList_QueryFiles(null);

            var tracks = new List<NowPlaying>();
            var position = 1;
            var itemIndex = _api.NowPlayingList_GetCurrentIndex();
            while (position <= limit)
            {
                var trackPath = _api.NowPlayingList_GetListFileUrl(itemIndex);

                var track = getFileMetadata(trackPath, itemIndex);

                tracks.Add(track);
                itemIndex = _api.NowPlayingList_GetNextIndex(position);
                position++;
            }

            sendDataToClient(clientId, tracks);
        }
2) To change order of Now Playing list:
Code
public void RequestNowPlayingMove(string clientId, int from, int to)
        {
            bool result;
            int[] aFrom = {from};
            int dIn;
            if (from > to)
            {
                dIn = to - 1;
            }
            else
            {
                dIn = to;
            }
            result = _api.NowPlayingList_MoveFiles(aFrom, dIn);

            sendDataToClient(clientId, result);
        }
Last Edit: February 20, 2021, 05:17:07 PM by dandepeched

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 31865
Actually there is a flaw in the internal functions for manual file drag/drop that is causing the issue you having. I will look to fix it over the next few days