Mercurial > audlegacy
annotate src/audtool/audtool_handlers_playback.c @ 3497:6f34cc4217b9 trunk
Added "date" field to basic fields.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Sep 2007 10:09:11 +0300 |
parents | 7be518cc8e60 |
children | f3341c2d6b9e |
rev | line source |
---|---|
2928
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1 /* |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2 * Audtool2 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3 * Copyright (c) 2007 Audacious development team |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
4 * |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
5 * Redistribution and use in source and binary forms, with or without |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
6 * modification, are permitted provided that the following conditions are |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
7 * met: |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
8 * |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
9 * 1. Redistributions of source code must retain the above copyright notice, |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
10 * this list of conditions and the following disclaimer. |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
11 * |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
13 * notice, this list of conditions and the following disclaimer in the |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
14 * documentation and/or other materials provided with the distribution. |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
15 * |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
16 * 3. The name of the author may not be used to endorse or promote products |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
17 * derived from this software without specific prior written permission. |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
18 * |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
29 * POSSIBILITY OF SUCH DAMAGE. |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
30 */ |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
31 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
32 #include <stdlib.h> |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
33 #include <string.h> |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
34 #include <glib.h> |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
35 #include <mowgli.h> |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
36 #include <locale.h> |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
37 #include "libaudclient/audctrl.h" |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
38 #include "audtool.h" |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
39 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
40 void playback_play(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
41 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
42 audacious_remote_play(dbus_proxy); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
43 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
44 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
45 void playback_pause(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
46 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
47 audacious_remote_pause(dbus_proxy); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
48 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
49 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
50 void playback_playpause(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
51 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
52 if (audacious_remote_is_playing(dbus_proxy)) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
53 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
54 audacious_remote_pause(dbus_proxy); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
55 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
56 else |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
57 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
58 audacious_remote_play(dbus_proxy); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
59 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
60 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
61 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
62 void playback_stop(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
63 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
64 audacious_remote_stop(dbus_proxy); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
65 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
66 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
67 void playback_playing(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
68 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
69 if (!audacious_remote_is_paused(dbus_proxy)) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
70 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
71 exit(!audacious_remote_is_playing(dbus_proxy)); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
72 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
73 else |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
74 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
75 exit(1); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
76 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
77 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
78 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
79 void playback_paused(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
80 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
81 exit(!audacious_remote_is_paused(dbus_proxy)); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
82 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
83 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
84 void playback_stopped(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
85 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
86 if (!audacious_remote_is_playing(dbus_proxy) && !audacious_remote_is_paused(dbus_proxy)) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
87 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
88 exit(0); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
89 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
90 else |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
91 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
92 exit(1); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
93 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
94 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
95 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
96 void playback_status(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
97 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
98 if (audacious_remote_is_paused(dbus_proxy)) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
99 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2928
diff
changeset
|
100 audtool_report("paused"); |
2928
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
101 return; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
102 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
103 else if (audacious_remote_is_playing(dbus_proxy)) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
104 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2928
diff
changeset
|
105 audtool_report("playing"); |
2928
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
106 return; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
107 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
108 else |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
109 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2928
diff
changeset
|
110 audtool_report("stopped"); |
2928
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
111 return; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
112 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
113 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
114 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
115 void playback_seek(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
116 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
117 if (argc < 2) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
118 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2928
diff
changeset
|
119 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2928
diff
changeset
|
120 audtool_whine("syntax: %s <position>", argv[0]); |
2928
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
121 return; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
122 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
123 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
124 audacious_remote_jump_to_time(dbus_proxy, atoi(argv[1]) * 1000); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
125 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
126 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
127 void playback_seek_relative(gint argc, gchar **argv) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
128 { |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
129 gint oldtime, newtime, diff; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
130 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
131 if (argc < 2) |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
132 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2928
diff
changeset
|
133 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2928
diff
changeset
|
134 audtool_whine("syntax: %s <position>", argv[0]); |
2928
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
135 return; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
136 } |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
137 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
138 oldtime = audacious_remote_get_output_time(dbus_proxy); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
139 diff = atoi(argv[1]) * 1000; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
140 newtime = oldtime + diff; |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
141 |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
142 audacious_remote_jump_to_time(dbus_proxy, newtime); |
ede9a8b8deff
Split out playback functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
143 } |