|
@@ -24,7 +24,6 @@ package com.dmdirc.addons.nowplaying;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.MessageTarget;
|
26
|
26
|
import com.dmdirc.Server;
|
27
|
|
-import com.dmdirc.addons.nowplaying.MediaSource;
|
28
|
27
|
import com.dmdirc.commandparser.commands.ChatCommand;
|
29
|
28
|
import com.dmdirc.commandparser.CommandManager;
|
30
|
29
|
import com.dmdirc.commandparser.commands.IntelligentCommand;
|
|
@@ -57,6 +56,7 @@ public final class NowPlayingCommand extends ChatCommand implements IntelligentC
|
57
|
56
|
}
|
58
|
57
|
|
59
|
58
|
/** {@inheritDoc} */
|
|
59
|
+ @Override
|
60
|
60
|
public void execute(final InputWindow origin, final Server server,
|
61
|
61
|
final MessageTarget target, final boolean isSilent, final String ... args) {
|
62
|
62
|
if (args.length > 0 && args[0].equalsIgnoreCase("--sources")) {
|
|
@@ -76,7 +76,8 @@ public final class NowPlayingCommand extends ChatCommand implements IntelligentC
|
76
|
76
|
}
|
77
|
77
|
}
|
78
|
78
|
} else {
|
79
|
|
- sendLine(origin, isSilent, FORMAT_ERROR, "You must specify a source when using --source.");
|
|
79
|
+ sendLine(origin, isSilent, FORMAT_ERROR,
|
|
80
|
+ "You must specify a source when using --source.");
|
80
|
81
|
}
|
81
|
82
|
} else {
|
82
|
83
|
if (parent.hasRunningSource()) {
|
|
@@ -99,23 +100,33 @@ public final class NowPlayingCommand extends ChatCommand implements IntelligentC
|
99
|
100
|
if (sources.isEmpty()) {
|
100
|
101
|
sendLine(origin, isSilent, FORMAT_ERROR, "No media sources available.");
|
101
|
102
|
} else {
|
102
|
|
- String status;
|
|
103
|
+ final String[] headers = {"Source", "Status", "Information"};
|
|
104
|
+ final String[][] data = new String[sources.size()][3];
|
|
105
|
+ int i = 0;
|
103
|
106
|
|
104
|
107
|
for (MediaSource source : sources) {
|
|
108
|
+ data[i][0] = source.getAppName();
|
|
109
|
+
|
105
|
110
|
if (source.isRunning()) {
|
106
|
111
|
if (source.isPlaying()) {
|
107
|
|
- status = "playing: " + getInformation(source);
|
|
112
|
+ data[i][1] = "playing";
|
108
|
113
|
} else {
|
109
|
|
- status = "paused: " + getInformation(source);
|
|
114
|
+ data[i][1] = "paused";
|
110
|
115
|
}
|
|
116
|
+
|
|
117
|
+ data[i][2] = getInformation(source);
|
111
|
118
|
} else {
|
112
|
|
- status = "not running";
|
|
119
|
+ data[i][1] = "not running";
|
|
120
|
+ data[i][2] = "-";
|
113
|
121
|
}
|
114
|
|
- sendLine(origin, isSilent, FORMAT_OUTPUT, source.getAppName() + ": " + status);
|
|
122
|
+
|
|
123
|
+ i++;
|
115
|
124
|
}
|
|
125
|
+
|
|
126
|
+ sendLine(origin, isSilent, FORMAT_OUTPUT, doTable(headers, data));
|
116
|
127
|
}
|
117
|
128
|
}
|
118
|
|
-
|
|
129
|
+
|
119
|
130
|
/**
|
120
|
131
|
* Returns a formatted information string from the requested soruce.
|
121
|
132
|
*
|
|
@@ -139,21 +150,26 @@ public final class NowPlayingCommand extends ChatCommand implements IntelligentC
|
139
|
150
|
}
|
140
|
151
|
|
141
|
152
|
/** {@inheritDoc}. */
|
|
153
|
+ @Override
|
142
|
154
|
public String getName() {
|
143
|
155
|
return "nowplaying";
|
144
|
156
|
}
|
145
|
157
|
|
146
|
158
|
/** {@inheritDoc}. */
|
|
159
|
+ @Override
|
147
|
160
|
public boolean showInHelp() {
|
148
|
161
|
return true;
|
149
|
162
|
}
|
150
|
163
|
|
151
|
164
|
/** {@inheritDoc}. */
|
|
165
|
+ @Override
|
152
|
166
|
public String getHelp() {
|
153
|
|
- return "nowplaying [--sources|--source <source>] - tells the channel the song you're currently playing";
|
|
167
|
+ return "nowplaying [--sources|--source <source>] - " +
|
|
168
|
+ "tells the channel the song you're currently playing";
|
154
|
169
|
}
|
155
|
170
|
|
156
|
171
|
/** {@inheritDoc} */
|
|
172
|
+ @Override
|
157
|
173
|
public AdditionalTabTargets getSuggestions(final int arg,
|
158
|
174
|
final List<String> previousArgs) {
|
159
|
175
|
final AdditionalTabTargets res = new AdditionalTabTargets();
|