1 package util
.command
.ctrlint
;
3 import interfaces
.DJInterface
;
4 import interfaces
.Track
;
9 import util
.command
.Command
;
10 import util
.node
.Node
;
11 import util
.queryparser
.ApplyFilter
;
12 import util
.queryparser
.Filter
;
13 import util
.queryparser
.QueryParser
;
15 public class Cue
implements Command
{
17 private Map
<String
,String
> args
;
19 public void init(Map
<String
, String
> args
) {
23 public Node
run(DJInterface dj
) {
25 List
<?
extends Track
> playlist
= dj
.library().getLibrary();
27 System
.out
.println("library has " + playlist
.size() + " elements");
33 if (args
.containsKey("query")) {
35 Filter f
= QueryParser
.parse(args
.get("query"));
36 System
.out
.println(f
);
37 playlist
= ApplyFilter
.filter(f
, playlist
);
39 System
.out
.println("enqueuing " + playlist
.size() + " elements");
41 dj
.playbackControl().enqueue(playlist
);
45 if (args
.containsKey("index")) {
47 dj
.playbackControl().jump(Integer
.parseInt(args
.get("index")));
51 if (args
.containsKey("command")) {
53 String cmd
= args
.get("command");
55 if (cmd
.equals("play")) {
56 dj
.playbackControl().next();
58 else if (cmd
.equals("clear")) {
59 dj
.playbackControl().clear();
62 throw new IllegalArgumentException("unexpected command: " + cmd
);