1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
* handlers_playback.c
* Copyright 2005-2008 George Averill, William Pitcock, and Matti Hämäläinen
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions, and the following disclaimer in the documentation
* provided with the distribution.
*
* This software is provided "as is" and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising from
* the use of this software.
*/
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <locale.h>
#include "libaudclient/audctrl.h"
#include "audtool.h"
void playback_play(gint argc, gchar **argv)
{
audacious_remote_play(dbus_proxy);
}
void playback_pause(gint argc, gchar **argv)
{
audacious_remote_pause(dbus_proxy);
}
void playback_playpause(gint argc, gchar **argv)
{
if (audacious_remote_is_playing(dbus_proxy))
{
audacious_remote_pause(dbus_proxy);
}
else
{
audacious_remote_play(dbus_proxy);
}
}
void playback_stop(gint argc, gchar **argv)
{
audacious_remote_stop(dbus_proxy);
}
void playback_playing(gint argc, gchar **argv)
{
if (!audacious_remote_is_paused(dbus_proxy))
{
exit(!audacious_remote_is_playing(dbus_proxy));
}
else
{
exit(1);
}
}
void playback_paused(gint argc, gchar **argv)
{
exit(!audacious_remote_is_paused(dbus_proxy));
}
void playback_stopped(gint argc, gchar **argv)
{
if (!audacious_remote_is_playing(dbus_proxy) && !audacious_remote_is_paused(dbus_proxy))
{
exit(0);
}
else
{
exit(1);
}
}
void playback_status(gint argc, gchar **argv)
{
if (audacious_remote_is_paused(dbus_proxy))
{
audtool_report("paused");
return;
}
else if (audacious_remote_is_playing(dbus_proxy))
{
audtool_report("playing");
return;
}
else
{
audtool_report("stopped");
return;
}
}
void playback_seek(gint argc, gchar **argv)
{
if (argc < 2)
{
audtool_whine_args(argv[0], "<position>");
exit(1);
}
audacious_remote_jump_to_time(dbus_proxy, atof(argv[1]) * 1000);
}
void playback_seek_relative(gint argc, gchar **argv)
{
gint oldtime, newtime, diff;
if (argc < 2)
{
audtool_whine_args(argv[0], "<position>");
exit(1);
}
oldtime = audacious_remote_get_output_time(dbus_proxy);
diff = atof(argv[1]) * 1000;
newtime = oldtime + diff;
audacious_remote_jump_to_time(dbus_proxy, newtime);
}
|