1 package util
.command
.ctrlint
;
3 import interfaces
.DJInterface
;
4 import interfaces
.Track
;
9 import util
.command
.Command
;
10 import util
.queryparser
.ApplyFilter
;
11 import util
.queryparser
.Filter
;
12 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 Response
run(DJInterface dj
) {
25 if (args
== null) return new Response(null, Response
.NO_CONTENT
);
27 if (args
.containsKey("query")) {
29 Iterable
<?
extends Track
> playlist
= dj
.library().tracks();
30 System
.out
.println("library has " + dj
.library().size() + " elements");
32 Filter f
= QueryParser
.parse(args
.get("query"));
33 System
.out
.println(f
);
34 List
<?
extends Track
> pl
= ApplyFilter
.filter(f
, playlist
);
36 System
.out
.println("enqueuing " + pl
.size() + " elements");
38 dj
.playbackControl().enqueue(pl
);
42 if (args
.containsKey("index")) {
44 dj
.playbackControl().jump(Integer
.parseInt(args
.get("index")));
48 if (args
.containsKey("command")) {
50 String cmd
= args
.get("command");
52 if (cmd
.equals("play")) {
53 dj
.playbackControl().next();
54 dj
.playbackControl().play();
56 else if (cmd
.equals("clear")) {
57 dj
.playbackControl().clear();
60 throw new IllegalArgumentException("unexpected command: " + cmd
);
64 return new Response(null, Response
.NO_CONTENT
);