I just use this for my queue button.
this.buttons.queue = new _button(x + (bs * 5), y, bs, bs, { char : '\ue109', colour: colours.white}, null, function () {
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}
}, 'Add to playback queue');
Thank you! Works very well.
I added rightmouse functionality for the button to remove queued items from selection but that is not really straightforward. If there is one item in the selection that is not queued the command will fail therefore I first had to add it to the queue before removing it.
if (buttons.buttons.queue.containsXY(x, y)) {
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
handleList.RunContextCommand("Remove from playback queue");
}
return true;
}
In the end I want to add rightmouse functionality to the Randomize selection button, so that it starts playing the first track of the selection after randomizing that selection. I would prefer to set focus to the first element of the selection after randomizing that selection and start playing that element, but I don't know how to set the focus to the first element of the selection.
I tried plman.SetPlaylistFocusItem(plman.ActivePlaylist, 0) but that sets the focus to the first element of the whole playlist.
What variable should be used instead of the 0 to set focus to the first item of the selection?
Also I do not know how to issue a play command that starts playing the focused item. fb.Play() just starts playing the song that is already playing or where playback stopped last time.
So now I use a rather stupid workaround. First I make a handlelist for the whole playlist. Then I add all items to the queue and delete all items (to clear the queue. Is there a better way?). Then I create a handlelist for current selection and add all items to the queue. And finally I issue a fb.Next() command to start playing the first (queued) item), which is the first rack of the selection after it was randomized.
var handleList = plman.GetPlaylistItems(plman.ActivePlaylist)
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
handleList.RunContextCommand("Remove from playback queue");
}
fb.RunMainMenuCommand('Edit/Selection/Sort/Randomize');
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}
fb.Next();
It works and solves the ordering issue I encountered by creating functionality for on-the-fly "compilation" folders, but I wonder if there's not a better way to it.