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