]>
Commit | Line | Data |
---|---|---|
83d20a45 CS |
1 | # |
2 | # This file is part of Audio::MPD::Common | |
3 | # Copyright (c) 2007 Jerome Quelin, all rights reserved. | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the same terms as Perl itself. | |
7 | # | |
8 | # | |
9 | ||
10 | package Audio::MPD::Common::Status; | |
11 | ||
12 | use warnings; | |
13 | use strict; | |
14 | ||
15 | use Audio::MPD::Common::Time; | |
16 | ||
17 | use base qw[ Class::Accessor::Fast ]; | |
18 | __PACKAGE__->mk_accessors | |
19 | ( qw[ audio bitrate error playlist playlistlength random | |
20 | repeat song songid state time volume updating_db xfade ] ); | |
21 | ||
22 | #our ($VERSION) = '$Rev: 5865 $' =~ /(\d+)/; | |
23 | ||
24 | ||
25 | #-- | |
26 | # Constructor | |
27 | ||
28 | # | |
29 | # my $status = Audio::MPD::Common::Status->new( \%kv ) | |
30 | # | |
31 | # The constructor for the class Audio::MPD::Common::Status. %kv is | |
32 | # a cooked output of what MPD server returns to the status command. | |
33 | # | |
34 | sub new { | |
35 | my ($class, $kv) = @_; | |
36 | my %kv = %$kv; | |
37 | $kv{time} = Audio::MPD::Common::Time->new( delete $kv{time} ); | |
38 | bless \%kv, $class; | |
39 | return \%kv; | |
40 | } | |
41 | ||
42 | 1; | |
43 | ||
44 | __END__ | |
45 | ||
46 | ||
47 | =head1 NAME | |
48 | ||
49 | Audio::MPD::Common::Status - class representing MPD status | |
50 | ||
51 | ||
52 | =head1 SYNOPSIS | |
53 | ||
54 | print $status->bitrate; | |
55 | ||
56 | ||
57 | =head1 DESCRIPTION | |
58 | ||
59 | The MPD server maintains some information on its current state. Those | |
60 | information can be queried with mpd modules. Some of those information | |
61 | are served to you as an C<Audio::MPD::Common::Status> object. | |
62 | ||
63 | Note that an C<Audio::MPD::Common::Status> object does B<not> update | |
64 | itself regularly, and thus should be used immediately. | |
65 | ||
66 | ||
67 | =head1 METHODS | |
68 | ||
69 | =head2 Constructor | |
70 | ||
71 | =over 4 | |
72 | ||
73 | =item new( \%kv ) | |
74 | ||
75 | The C<new()> method is the constructor for the C<Audio::MPD::Common::Status> | |
76 | class. | |
77 | ||
78 | Note: one should B<never> ever instantiate an C<Audio::MPD::Common::Status> | |
79 | object directly - use the mpd modules instead. | |
80 | ||
81 | =back | |
82 | ||
83 | ||
84 | =head2 Accessors | |
85 | ||
86 | Once created, one can access to the following members of the object: | |
87 | ||
88 | =over 4 | |
89 | ||
90 | =item $status->audio() | |
91 | ||
92 | A string with the sample rate of the song currently playing, number of bits | |
93 | of the output and number of channels (2 for stereo) - separated by a colon. | |
94 | ||
95 | ||
96 | =item $status->bitrate() | |
97 | ||
98 | The instantaneous bitrate in kbps. | |
99 | ||
100 | ||
101 | =item $status->error() | |
102 | ||
103 | May appear in special error cases, such as when disabling output. | |
104 | ||
105 | ||
106 | =item $status->playlist() | |
107 | ||
108 | The playlist version number, that changes every time the playlist is updated. | |
109 | ||
110 | ||
111 | =item $status->playlistlength() | |
112 | ||
113 | The number of songs in the playlist. | |
114 | ||
115 | ||
116 | =item $status->random() | |
117 | ||
118 | Whether the playlist is read randomly or not. | |
119 | ||
120 | ||
121 | =item $status->repeat() | |
122 | ||
123 | Whether the song is repeated or not. | |
124 | ||
125 | ||
126 | =item $status->song() | |
127 | ||
128 | The offset of the song currently played in the playlist. | |
129 | ||
130 | ||
131 | =item $status->songid() | |
132 | ||
133 | The song id (MPD id) of the song currently played. | |
134 | ||
135 | ||
136 | =item $status->state() | |
137 | ||
138 | The state of MPD server. Either C<play>, C<stop> or C<pause>. | |
139 | ||
140 | ||
141 | =item $status->time() | |
142 | ||
143 | An C<Audio::MPD::Common::Time> object, representing the time elapsed / | |
144 | remainging and total. See the associated pod for more details. | |
145 | ||
146 | ||
147 | =item $status->updating_db() | |
148 | ||
149 | An integer, representing the current update job. | |
150 | ||
151 | ||
152 | =item $status->volume() | |
153 | ||
154 | The current MPD volume - an integer between 0 and 100. | |
155 | ||
156 | ||
157 | =item $status->xfade() | |
158 | ||
159 | The crossfade in seconds. | |
160 | ||
161 | ||
162 | =back | |
163 | ||
164 | Please note that those accessors are read-only: changing a value will B<not> | |
165 | change the current settings of MPD server. Use the mpd modules to alter the | |
166 | settings. | |
167 | ||
168 | ||
169 | =head1 SEE ALSO | |
170 | ||
171 | =over 4 | |
172 | ||
173 | =item L<Audio::MPD> | |
174 | ||
175 | =item L<POE::Component::Client::MPD> | |
176 | ||
177 | =back | |
178 | ||
179 | ||
180 | =head1 AUTHOR | |
181 | ||
182 | Jerome Quelin, C<< <jquelin at cpan.org> >> | |
183 | ||
184 | ||
185 | =head1 COPYRIGHT & LICENSE | |
186 | ||
187 | Copyright (c) 2007 Jerome Quelin, all rights reserved. | |
188 | ||
189 | This program is free software; you can redistribute it and/or modify | |
190 | it under the same terms as Perl itself. | |
191 | ||
192 | =cut |