Mercurial > audlegacy
annotate audtool/audtool.c @ 1233:47a8833c2b01 trunk
[svn] - get_song_tuple() implementation
author | nenolod |
---|---|
date | Wed, 14 Jun 2006 21:47:23 -0700 |
parents | b8f5cb287ed2 |
children | 276cc2ce63b7 |
rev | line source |
---|---|
1200 | 1 /* Audtool -- Audacious scripting tool |
2 * Copyright (c) 2005-2006 George Averill, William Pitcock | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 */ | |
18 | |
19 #include <stdlib.h> | |
20 #include <glib.h> | |
1225 | 21 #include "libaudacious/beepctrl.h" |
1200 | 22 #include "audtool.h" |
23 | |
24 struct commandhandler handlers[] = { | |
25 {"current-song", get_current_song, "returns current song title"}, | |
26 {"current-song-filename", get_current_song_filename, "returns current song filename"}, | |
27 {"current-song-length", get_current_song_length, "returns current song length"}, | |
28 {"current-song-length-seconds", get_current_song_length_seconds, "returns current song length in seconds"}, | |
29 {"current-song-length-frames", get_current_song_length_frames, "returns current song length in frames"}, | |
30 {"current-song-output-length", get_current_song_output_length, "returns current song output length"}, | |
31 {"current-song-output-length-seconds", get_current_song_output_length_seconds, "returns current song output length in seconds"}, | |
32 {"current-song-output-length-frames", get_current_song_output_length_frames, "returns current song output length in frames"}, | |
33 {"current-song-bitrate", get_current_song_bitrate, "returns current song bitrate in bits per second"}, | |
34 {"current-song-bitrate-kbps", get_current_song_bitrate_kbps, "returns current song bitrate in kilobits per second"}, | |
35 {"current-song-frequency", get_current_song_frequency, "returns current song frequency in hertz"}, | |
36 {"current-song-frequency-khz", get_current_song_frequency_khz, "returns current song frequency in kilohertz"}, | |
37 {"current-song-channels", get_current_song_channels, "returns current song channels"}, | |
38 {"<sep>", NULL, NULL}, | |
39 {"playlist-advance", playlist_advance, "go to the next song in the playlist"}, | |
40 {"playlist-reverse", playlist_reverse, "go to the previous song in the playlist"}, | |
41 {"playlist-addurl", playlist_add_url_string, "adds a url to the playlist"}, | |
42 {"playlist-length", playlist_length, "returns the total length of the playlist"}, | |
43 {"playlist-song", playlist_song, "returns the title of a song in the playlist"}, | |
44 {"playlist-song-filename", playlist_song_filename, "returns the filename of a song in the playlist"}, | |
45 {"playlist-song-length", playlist_song_length, "returns the length of a song in the playlist"}, | |
46 {"playlist-song-length-seconds", playlist_song_length_seconds, "returns the length of a song in the playlist in seconds"}, | |
47 {"playlist-song-length-frames", playlist_song_length_frames, "returns the length of a song in the playlist in frames"}, | |
48 {"playlist-display", playlist_display, "returns the entire playlist"}, | |
49 {"playlist-position", playlist_position, "returns the position in the playlist"}, | |
50 {"playlist-jump", playlist_jump, "jumps to a position in the playlist"}, | |
51 {"playlist-clear", playlist_clear, "clears the playlist"}, | |
52 {"playlist-repeat-status", playlist_repeat_status, "returns the status of playlist repeat"}, | |
53 {"playlist-repeat-toggle", playlist_repeat_toggle, "toggles playlist repeat"}, | |
54 {"playlist-shuffle-status", playlist_shuffle_status, "returns the status of playlist shuffle"}, | |
55 {"playlist-shuffle-toggle", playlist_shuffle_toggle, "toggles playlist shuffle"}, | |
56 {"<sep>", NULL, NULL}, | |
57 {"playqueue-add", playqueue_add, "adds a song to the playqueue"}, | |
58 {"playqueue-remove", playqueue_remove, "removes a song from the playqueue"}, | |
59 {"playqueue-is-queued", playqueue_is_queued, "returns OK if a song is queued"}, | |
60 {"playqueue-get-position", playqueue_get_position, "returns the queue position of a song in the playlist"}, | |
61 {"playqueue-get-qposition", playqueue_get_qposition, "returns the playlist position of a song in the queue"}, | |
62 {"playqueue-length", playqueue_length, "returns the length of the playqueue"}, | |
63 {"playqueue-display", playqueue_display, "returns a list of currently-queued songs"}, | |
64 {"playqueue-clear", playqueue_clear, "clears the playqueue"}, | |
65 {"<sep>", NULL, NULL}, | |
66 {"playback-play", playback_play, "starts/unpauses song playback"}, | |
67 {"playback-pause", playback_pause, "(un)pauses song playback"}, | |
68 {"playback-playpause", playback_playpause, "plays/(un)pauses song playback"}, | |
69 {"playback-stop", playback_stop, "stops song playback"}, | |
70 {"playback-playing", playback_playing, "returns OK if audacious is playing"}, | |
71 {"playback-paused", playback_paused, "returns OK if audacious is paused"}, | |
72 {"playback-stopped", playback_stopped, "returns OK if audacious is stopped"}, | |
73 {"playback-status", playback_status, "returns the playback status"}, | |
74 {"<sep>", NULL, NULL}, | |
75 {"get-volume", get_volume, "returns the current volume level in percent"}, | |
76 {"set-volume", set_volume, "sets the current volume level in percent"}, | |
77 {"<sep>", NULL, NULL}, | |
78 {"preferences", show_preferences_window, "shows/hides the preferences window"}, | |
79 {"jumptofile", show_jtf_window, "shows the jump to file window"}, | |
80 {"shutdown", shutdown_audacious_server, "shuts down audacious"}, | |
81 {"<sep>", NULL, NULL}, | |
82 {"list-handlers", get_handlers_list, "shows handlers list"}, | |
83 {"help", get_handlers_list, "shows handlers list"}, | |
84 {NULL, NULL, NULL} | |
85 }; | |
86 | |
87 gint main(gint argc, gchar **argv) | |
88 { | |
89 gint i; | |
90 | |
91 if (argc < 2) | |
92 { | |
93 g_print("%s: usage: %s <command>\n", argv[0], argv[0]); | |
94 g_print("%s: use `%s help' to get a listing of available commands.\n", | |
95 argv[0], argv[0]); | |
96 exit(0); | |
97 } | |
98 | |
1203
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
99 if (!xmms_remote_is_running(0) && g_strcasecmp("help", argv[1]) |
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
100 && g_strcasecmp("list-handlers", argv[1])) |
1200 | 101 { |
102 g_print("%s: audacious server is not running!\n", argv[0]); | |
103 exit(0); | |
104 } | |
105 | |
106 for (i = 0; handlers[i].name != NULL; i++) | |
107 { | |
1203
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
108 if ((!g_strcasecmp(handlers[i].name, argv[1]) || |
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
109 !g_strcasecmp(g_strconcat("--", handlers[i].name, NULL), argv[1])) |
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
110 && g_strcasecmp("<sep>", handlers[i].name)) |
1200 | 111 { |
112 handlers[i].handler(0, argc, argv); | |
113 exit(0); | |
114 } | |
115 } | |
116 | |
117 g_print("%s: invalid command '%s'\n", argv[0], argv[1]); | |
118 g_print("%s: use `%s help' to get a listing of available commands.\n", argv[0], argv[0]); | |
119 | |
120 return 0; | |
121 } | |
122 | |
123 /*** MOVE TO HANDLERS.C ***/ | |
124 | |
125 void get_current_song(gint session, gint argc, gchar **argv) | |
126 { | |
127 gint playpos = xmms_remote_get_playlist_pos(session); | |
128 gchar *song = xmms_remote_get_playlist_title(session, playpos); | |
129 | |
130 if (!song) | |
131 { | |
132 g_print("No song playing.\n"); | |
133 return; | |
134 } | |
135 | |
136 g_print("%s\n", song); | |
137 } | |
138 | |
139 void get_current_song_filename(gint session, gint argc, gchar **argv) | |
140 { | |
141 gint playpos = xmms_remote_get_playlist_pos(session); | |
142 | |
143 g_print("%s\n", xmms_remote_get_playlist_file(session, playpos)); | |
144 } | |
145 | |
146 void get_current_song_output_length(gint session, gint argc, gchar **argv) | |
147 { | |
148 gint frames = xmms_remote_get_output_time(session); | |
149 gint length = frames / 1000; | |
150 | |
151 g_print("%d:%.2d\n", length / 60, length % 60); | |
152 } | |
153 | |
154 void get_current_song_output_length_seconds(gint session, gint argc, gchar **argv) | |
155 { | |
156 gint frames = xmms_remote_get_output_time(session); | |
157 gint length = frames / 1000; | |
158 | |
159 g_print("%d\n", length); | |
160 } | |
161 | |
162 void get_current_song_output_length_frames(gint session, gint argc, gchar **argv) | |
163 { | |
164 gint frames = xmms_remote_get_output_time(session); | |
165 | |
166 g_print("%d\n", frames); | |
167 } | |
168 | |
169 void get_current_song_length(gint session, gint argc, gchar **argv) | |
170 { | |
171 gint playpos = xmms_remote_get_playlist_pos(session); | |
172 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
173 gint length = frames / 1000; | |
174 | |
175 g_print("%d:%.2d\n", length / 60, length % 60); | |
176 } | |
177 | |
178 void get_current_song_length_seconds(gint session, gint argc, gchar **argv) | |
179 { | |
180 gint playpos = xmms_remote_get_playlist_pos(session); | |
181 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
182 gint length = frames / 1000; | |
183 | |
184 g_print("%d\n", length); | |
185 } | |
186 | |
187 void get_current_song_length_frames(gint session, gint argc, gchar **argv) | |
188 { | |
189 gint playpos = xmms_remote_get_playlist_pos(session); | |
190 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
191 | |
192 g_print("%d\n", frames); | |
193 } | |
194 | |
195 void get_current_song_bitrate(gint session, gint argc, gchar **argv) | |
196 { | |
197 gint rate, freq, nch; | |
198 | |
199 xmms_remote_get_info(session, &rate, &freq, &nch); | |
200 | |
201 g_print("%d\n", rate); | |
202 } | |
203 | |
204 void get_current_song_bitrate_kbps(gint session, gint argc, gchar **argv) | |
205 { | |
206 gint rate, freq, nch; | |
207 | |
208 xmms_remote_get_info(session, &rate, &freq, &nch); | |
209 | |
210 g_print("%d\n", rate / 1000); | |
211 } | |
212 | |
213 void get_current_song_frequency(gint session, gint argc, gchar **argv) | |
214 { | |
215 gint rate, freq, nch; | |
216 | |
217 xmms_remote_get_info(session, &rate, &freq, &nch); | |
218 | |
219 g_print("%d\n", freq); | |
220 } | |
221 | |
222 void get_current_song_frequency_khz(gint session, gint argc, gchar **argv) | |
223 { | |
224 gint rate, freq, nch; | |
225 | |
226 xmms_remote_get_info(session, &rate, &freq, &nch); | |
227 | |
228 g_print("%0.1f\n", (gfloat) freq / 1000); | |
229 } | |
230 | |
231 void get_current_song_channels(gint session, gint argc, gchar **argv) | |
232 { | |
233 gint rate, freq, nch; | |
234 | |
235 xmms_remote_get_info(session, &rate, &freq, &nch); | |
236 | |
237 g_print("%d\n", nch); | |
238 } | |
239 | |
240 void playlist_reverse(gint session, gint argc, gchar **argv) | |
241 { | |
242 xmms_remote_playlist_prev(session); | |
243 } | |
244 | |
245 void playlist_advance(gint session, gint argc, gchar **argv) | |
246 { | |
247 xmms_remote_playlist_next(session); | |
248 } | |
249 | |
250 void playback_play(gint session, gint argc, gchar **argv) | |
251 { | |
252 xmms_remote_play(session); | |
253 } | |
254 | |
255 void playback_pause(gint session, gint argc, gchar **argv) | |
256 { | |
257 xmms_remote_pause(session); | |
258 } | |
259 | |
260 void playback_playpause(gint session, gint argc, gchar **argv) | |
261 { | |
262 if (xmms_remote_is_playing(session)) | |
263 { | |
264 xmms_remote_pause(session); | |
265 } | |
266 else | |
267 { | |
268 xmms_remote_play(session); | |
269 } | |
270 } | |
271 | |
272 void playback_stop(gint session, gint argc, gchar **argv) | |
273 { | |
274 xmms_remote_stop(session); | |
275 } | |
276 | |
277 void playback_playing(gint session, gint argc, gchar **argv) | |
278 { | |
279 if (!xmms_remote_is_paused(session)) | |
280 { | |
281 exit(!xmms_remote_is_playing(session)); | |
282 } | |
283 else | |
284 { | |
285 exit(1); | |
286 } | |
287 } | |
288 | |
289 void playback_paused(gint session, gint argc, gchar **argv) | |
290 { | |
291 exit(!xmms_remote_is_paused(session)); | |
292 } | |
293 | |
294 void playback_stopped(gint session, gint argc, gchar **argv) | |
295 { | |
296 if (!xmms_remote_is_playing(session) && !xmms_remote_is_paused(session)) | |
297 { | |
298 exit(0); | |
299 } | |
300 else | |
301 { | |
302 exit(1); | |
303 } | |
304 } | |
305 | |
306 void playback_status(gint session, gint argc, gchar **argv) | |
307 { | |
308 if (xmms_remote_is_paused(session)) | |
309 { | |
310 g_print("paused\n"); | |
311 return; | |
312 } | |
313 else if (xmms_remote_is_playing(session)) | |
314 { | |
315 g_print("playing\n"); | |
316 return; | |
317 } | |
318 else | |
319 { | |
320 g_print("stopped\n"); | |
321 return; | |
322 } | |
323 } | |
324 | |
325 void playlist_add_url_string(gint session, gint argc, gchar **argv) | |
326 { | |
327 if (argc < 3) | |
328 { | |
329 g_print("%s: invalid parameters for playlist-addurl.\n", argv[0]); | |
330 g_print("%s: syntax: %s playlist-addurl <url>\n", argv[0], argv[0]); | |
331 return; | |
332 } | |
333 | |
334 xmms_remote_playlist_add_url_string(session, argv[2]); | |
335 } | |
336 | |
337 void playlist_length(gint session, gint argc, gchar **argv) | |
338 { | |
339 gint i; | |
340 | |
341 i = xmms_remote_get_playlist_length(session); | |
342 | |
343 g_print("%d\n", i); | |
344 } | |
345 | |
346 void playlist_song(gint session, gint argc, gchar **argv) | |
347 { | |
348 if (argc < 3) | |
349 { | |
350 g_print("%s: invalid parameters for playlist-song-title.\n", argv[0]); | |
351 g_print("%s: syntax: %s playlist-song-title <position>\n", argv[0], argv[0]); | |
352 return; | |
353 } | |
354 | |
355 gint playpos = atoi(argv[2]); | |
356 | |
357 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
358 { | |
359 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
360 return; | |
361 } | |
362 | |
363 gchar *song = xmms_remote_get_playlist_title(session, playpos - 1); | |
364 | |
365 g_print("%s\n", song); | |
366 } | |
367 | |
368 | |
369 void playlist_song_length(gint session, gint argc, gchar **argv) | |
370 { | |
371 if (argc < 3) | |
372 { | |
373 g_print("%s: invalid parameters for playlist-song-length.\n", argv[0]); | |
374 g_print("%s: syntax: %s playlist-song-length <position>\n", argv[0], argv[0]); | |
375 return; | |
376 } | |
377 | |
378 gint playpos = atoi(argv[2]); | |
379 | |
380 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
381 { | |
382 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
383 return; | |
384 } | |
385 | |
386 gint frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
387 gint length = frames / 1000; | |
388 | |
389 g_print("%d:%.2d\n", length / 60, length % 60); | |
390 } | |
391 | |
392 void playlist_song_length_seconds(gint session, gint argc, gchar **argv) | |
393 { | |
394 if (argc < 3) | |
395 { | |
396 g_print("%s: invalid parameters for playlist-song-length-seconds.\n", argv[0]); | |
397 g_print("%s: syntax: %s playlist-song-length-seconds <position>\n", argv[0], argv[0]); | |
398 return; | |
399 } | |
400 | |
401 gint playpos = atoi(argv[2]); | |
402 | |
403 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
404 { | |
405 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
406 return; | |
407 } | |
408 | |
409 gint frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
410 gint length = frames / 1000; | |
411 | |
412 g_print("%d\n", length); | |
413 } | |
414 | |
415 void playlist_song_length_frames(gint session, gint argc, gchar **argv) | |
416 { | |
417 if (argc < 3) | |
418 { | |
419 g_print("%s: invalid parameters for playlist-song-length-frames.\n", argv[0]); | |
420 g_print("%s: syntax: %s playlist-song-length-frames <position>\n", argv[0], argv[0]); | |
421 return; | |
422 } | |
423 | |
424 gint playpos = atoi(argv[2]); | |
425 | |
426 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
427 { | |
428 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
429 return; | |
430 } | |
431 | |
432 gint frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
433 | |
434 g_print("%d\n", frames); | |
435 } | |
436 | |
437 void playlist_display(gint session, gint argc, gchar **argv) | |
438 { | |
439 gint i, ii, frames, length, total; | |
440 gchar *songname; | |
441 | |
442 i = xmms_remote_get_playlist_length(session); | |
443 | |
444 g_print("%d tracks.\n", i); | |
445 | |
446 total = 0; | |
447 | |
448 for (ii = 0; ii < i; ii++) | |
449 { | |
450 songname = xmms_remote_get_playlist_title(session, ii); | |
451 frames = xmms_remote_get_playlist_time(session, ii); | |
452 length = frames / 1000; | |
453 total += length; | |
454 | |
455 g_print("%4d | %-60s | %d:%.2d\n", | |
456 ii + 1, songname, length / 60, length % 60); | |
457 } | |
458 | |
459 g_print("Total length: %d:%.2d\n", total / 60, total % 60); | |
460 } | |
461 | |
462 void playlist_position(gint session, gint argc, gchar **argv) | |
463 { | |
464 gint i; | |
465 | |
466 i = xmms_remote_get_playlist_pos(session); | |
467 | |
468 g_print("%d\n", i + 1); | |
469 } | |
470 | |
471 void playlist_song_filename(gint session, gint argc, gchar **argv) | |
472 { | |
473 gint i; | |
474 | |
475 if (argc < 3) | |
476 { | |
477 g_print("%s: invalid parameters for playlist-filename.\n", argv[0]); | |
478 g_print("%s: syntax: %s playlist-filename <position>\n", argv[0], argv[0]); | |
479 return; | |
480 } | |
481 | |
482 i = atoi(argv[2]); | |
483 | |
484 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
485 { | |
486 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
487 return; | |
488 } | |
489 | |
490 g_print("%s\n", xmms_remote_get_playlist_file(session, i - 1)); | |
491 } | |
492 | |
493 void playlist_jump(gint session, gint argc, gchar **argv) | |
494 { | |
495 gint i; | |
496 | |
497 if (argc < 3) | |
498 { | |
499 g_print("%s: invalid parameters for playlist-jump.\n", argv[0]); | |
500 g_print("%s: syntax: %s playlist-jump <position>\n", argv[0], argv[0]); | |
501 return; | |
502 } | |
503 | |
504 i = atoi(argv[2]); | |
505 | |
506 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
507 { | |
508 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
509 return; | |
510 } | |
511 | |
512 xmms_remote_set_playlist_pos(session, i - 1); | |
513 } | |
514 | |
515 void playlist_clear(gint session, gint argc, gchar **argv) | |
516 { | |
517 xmms_remote_playlist_clear(session); | |
518 } | |
519 | |
520 void playlist_repeat_status(gint session, gint argc, gchar **argv) | |
521 { | |
522 if (xmms_remote_is_repeat(session)) | |
523 { | |
524 g_print("on\n"); | |
525 return; | |
526 } | |
527 else | |
528 { | |
529 g_print("off\n"); | |
530 return; | |
531 } | |
532 } | |
533 | |
534 void playlist_repeat_toggle(gint session, gint argc, gchar **argv) | |
535 { | |
536 xmms_remote_toggle_repeat(session); | |
537 } | |
538 | |
539 void playlist_shuffle_status(gint session, gint argc, gchar **argv) | |
540 { | |
541 if (xmms_remote_is_shuffle(session)) | |
542 { | |
543 g_print("on\n"); | |
544 return; | |
545 } | |
546 else | |
547 { | |
548 g_print("off\n"); | |
549 return; | |
550 } | |
551 } | |
552 | |
553 void playlist_shuffle_toggle(gint session, gint argc, gchar **argv) | |
554 { | |
555 xmms_remote_toggle_shuffle(session); | |
556 } | |
557 | |
558 void playqueue_add(gint session, gint argc, gchar **argv) | |
559 { | |
1204
76e6b66fb859
[svn] - compiles warningless inside the audacious buildsystem now
nenolod
parents:
1203
diff
changeset
|
560 gint i; |
1200 | 561 |
562 if (argc < 3) | |
563 { | |
564 g_print("%s: invalid parameters for playqueue-add.\n", argv[0]); | |
565 g_print("%s: syntax: %s playqueue-add <position>\n", argv[0], argv[0]); | |
566 return; | |
567 } | |
568 | |
569 i = atoi(argv[2]); | |
570 | |
571 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
572 { | |
573 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
574 return; | |
575 } | |
576 | |
577 if (!(xmms_remote_playqueue_is_queued(session, i - 1))) | |
578 xmms_remote_playqueue_add(session, i - 1); | |
579 } | |
580 | |
581 void playqueue_remove(gint session, gint argc, gchar **argv) | |
582 { | |
1204
76e6b66fb859
[svn] - compiles warningless inside the audacious buildsystem now
nenolod
parents:
1203
diff
changeset
|
583 gint i; |
1200 | 584 |
585 if (argc < 3) | |
586 { | |
587 g_print("%s: invalid parameters for playqueue-remove.\n", argv[0]); | |
588 g_print("%s: syntax: %s playqueue-remove <position>\n", argv[0], argv[0]); | |
589 return; | |
590 } | |
591 | |
592 i = atoi(argv[2]); | |
593 | |
594 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
595 { | |
596 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
597 return; | |
598 } | |
599 | |
600 if (xmms_remote_playqueue_is_queued(session, i - 1)) | |
601 xmms_remote_playqueue_remove(session, i - 1); | |
602 } | |
603 | |
604 void playqueue_is_queued(gint session, gint argc, gchar **argv) | |
605 { | |
606 gint i; | |
607 | |
608 if (argc < 3) | |
609 { | |
610 g_print("%s: invalid parameters for playqueue-is-queued.\n", argv[0]); | |
611 g_print("%s: syntax: %s playqueue-is-queued <position>\n", argv[0], argv[0]); | |
612 return; | |
613 } | |
614 | |
615 i = atoi(argv[2]); | |
616 | |
617 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
618 { | |
619 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
620 return; | |
621 } | |
622 | |
623 exit(!(xmms_remote_playqueue_is_queued(session, i - 1))); | |
624 } | |
625 | |
626 void playqueue_get_position(gint session, gint argc, gchar **argv) | |
627 { | |
628 gint i, pos; | |
629 | |
630 if (argc < 3) | |
631 { | |
632 g_print("%s: invalid parameters for playqueue-get-position.\n", argv[0]); | |
633 g_print("%s: syntax: %s playqueue-get-position <position>\n", argv[0], argv[0]); | |
634 return; | |
635 } | |
636 | |
637 i = atoi(argv[2]); | |
638 | |
639 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
640 { | |
641 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
642 return; | |
643 } | |
644 | |
645 pos = xmms_remote_get_playqueue_position(session, i - 1) + 1; | |
646 | |
647 if (pos < 1) | |
648 return; | |
649 | |
650 g_print("%d\n", pos); | |
651 } | |
652 | |
653 void playqueue_get_qposition(gint session, gint argc, gchar **argv) | |
654 { | |
655 gint i, pos; | |
656 | |
657 if (argc < 3) | |
658 { | |
659 g_print("%s: invalid parameters for playqueue-get-qposition.\n", argv[0]); | |
660 g_print("%s: syntax: %s playqueue-get-qposition <position>\n", argv[0], argv[0]); | |
661 return; | |
662 } | |
663 | |
664 i = atoi(argv[2]); | |
665 | |
666 if (i < 1 || i > xmms_remote_get_playqueue_length(session)) | |
667 { | |
668 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
669 return; | |
670 } | |
671 | |
672 pos = xmms_remote_get_playqueue_queue_position(session, i - 1) + 1; | |
673 | |
674 if (pos < 1) | |
675 return; | |
676 | |
677 g_print("%d\n", pos); | |
678 } | |
679 | |
680 void playqueue_display(gint session, gint argc, gchar **argv) | |
681 { | |
682 gint i, ii, position, frames, length, total; | |
683 gchar *songname; | |
684 | |
685 i = xmms_remote_get_playqueue_length(session); | |
686 | |
687 g_print("%d queued tracks.\n", i); | |
688 | |
689 total = 0; | |
690 | |
691 for (ii = 0; ii < i; ii++) | |
692 { | |
693 position = xmms_remote_get_playqueue_queue_position(session, ii); | |
694 songname = xmms_remote_get_playlist_title(session, position); | |
695 frames = xmms_remote_get_playlist_time(session, position); | |
696 length = frames / 1000; | |
697 total += length; | |
698 | |
699 g_print("%4d | %4d | %-60s | %d:%.2d\n", | |
700 ii + 1, position + 1, songname, length / 60, length % 60); | |
701 } | |
702 | |
703 g_print("Total length: %d:%.2d\n", total / 60, total % 60); | |
704 } | |
705 | |
706 void playqueue_length(gint session, gint argc, gchar **argv) | |
707 { | |
708 gint i; | |
709 | |
710 i = xmms_remote_get_playqueue_length(session); | |
711 | |
712 g_print("%d\n", i); | |
713 } | |
714 | |
715 void playqueue_clear(gint session, gint argc, gchar **argv) | |
716 { | |
717 xmms_remote_playqueue_clear(session); | |
718 } | |
719 | |
720 void get_volume(gint session, gint argc, gchar **argv) | |
721 { | |
722 gint i; | |
723 | |
724 i = xmms_remote_get_main_volume(session); | |
725 | |
726 g_print("%d\n", i); | |
727 } | |
728 | |
729 void set_volume(gint session, gint argc, gchar **argv) | |
730 { | |
731 gint i, current_volume; | |
732 | |
733 if (argc < 3) | |
734 { | |
735 g_print("%s: invalid parameters for set-volume.\n", argv[0]); | |
736 g_print("%s: syntax: %s set-volume <level>\n", argv[0], argv[0]); | |
737 return; | |
738 } | |
739 | |
740 current_volume = xmms_remote_get_main_volume(session); | |
741 switch (argv[2][0]) | |
742 { | |
743 case '+': | |
744 case '-': | |
745 i = current_volume + atoi(argv[2]); | |
746 break; | |
747 default: | |
748 i = atoi(argv[2]); | |
749 break; | |
750 } | |
751 | |
752 xmms_remote_set_main_volume(session, i); | |
753 } | |
754 | |
755 void show_preferences_window(gint session, gint argc, gchar **argv) | |
756 { | |
757 xmms_remote_show_prefs_box(session); | |
758 } | |
759 | |
760 void show_jtf_window(gint session, gint argc, gchar **argv) | |
761 { | |
762 xmms_remote_show_jtf_box(session); | |
763 } | |
764 | |
765 void shutdown_audacious_server(gint session, gint argc, gchar **argv) | |
766 { | |
767 xmms_remote_quit(session); | |
768 } | |
769 | |
770 void get_handlers_list(gint session, gint argc, gchar **argv) | |
771 { | |
772 gint i; | |
773 | |
774 g_print("Available handlers:\n\n"); | |
775 | |
776 for (i = 0; handlers[i].name != NULL; i++) | |
777 { | |
1203
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
778 if (!g_strcasecmp("<sep>", handlers[i].name)) |
1200 | 779 g_print("\n"); |
780 else | |
781 g_print(" %-34s - %s\n", handlers[i].name, handlers[i].desc); | |
782 } | |
783 | |
784 g_print("\nHandlers may be prefixed with `--' (GNU-style long-options) or not, your choice.\n"); | |
785 g_print("Report bugs to http://bugs.audacious-media-player.org.\n"); | |
786 } |