migrated to moose
[audio-mpd-common.git] / lib / Audio / MPD / Common / Status.pm
blob8baaa000eda4291cf0a8f35b6a89ddd9850e2412
1 use strict;
2 use warnings;
4 package Audio::MPD::Common::Status;
5 # ABSTRACT: class representing MPD status
7 use Moose;
8 use Moose::Util::TypeConstraints;
9 use Audio::MPD::Common::Time;
12 # -- private types
14 subtype 'Int_0_100'
15 => as 'Int'
16 => where { $_ >= 0 && $_ <= 100 }
17 => message { "$_ is not between 0 and 100" };
18 enum 'State' => qw{ play stop pause };
19 coerce 'Audio::MPD::Common::Time'
20 => from 'Str'
21 => via { Audio::MPD::Common::Time->new(time=>$_) };
24 # -- public attributes
26 =attr $status->audio;
28 A string with the sample rate of the song currently playing, number of
29 bits of the output and number of channels (2 for stereo) - separated
30 by a colon.
32 =attr $status->bitrate;
34 The instantaneous bitrate in kbps.
36 =attr $status->error;
38 May appear in special error cases, such as when disabling output.
40 =attr $status->playlist;
42 The playlist version number, that changes every time the playlist
43 is updated.
45 =attr $status->playlistlength;
47 The number of songs in the playlist.
49 =attr $status->random;
51 Whether the playlist is read randomly or not.
53 =attr $status->repeat;
55 Whether the song is repeated or not.
57 =attr $status->song;
59 The offset of the song currently played in the playlist.
61 =attr $status->songid;
63 The song id (MPD id) of the song currently played.
65 =attr $status->state;
67 The state of MPD server. Either C<play>, C<stop> or C<pause>.
69 =attr $status->time;
71 An L<Audio::MPD::Common::Time> object, representing the time elapsed /
72 remainging and total. See the associated pod for more details.
74 =attr $status->updating_db;
76 An integer, representing the current update job.
78 =attr $status->volume;
80 The current MPD volume - an integer between 0 and 100.
82 =attr $status->xfade;
84 The crossfade in seconds.
86 =cut
88 has audio => ( is=>'ro', required=>1, isa=>'Str' );
89 has bitrate => ( is=>'ro', required=>1, isa=>'Int' );
90 has error => ( is=>'ro', required=>0, isa=>'Str' );
91 has playlist => ( is=>'ro', required=>1, isa=>'Int' );
92 has playlistlength => ( is=>'ro', required=>1, isa=>'Int' );
93 has random => ( is=>'ro', required=>1, isa=>'Bool' );
94 has repeat => ( is=>'ro', required=>1, isa=>'Bool' );
95 has songid => ( is=>'ro', required=>1, isa=>'Int' );
96 has song => ( is=>'ro', required=>1, isa=>'Int' );
97 has state => ( is=>'ro', required=>1, isa=>'State' );
98 has time => ( is=>'ro', required=>1, isa=>'Audio::MPD::Common::Time', coerce=>1 );
99 has updating_db => ( is=>'ro', required=>1, isa=>'Int' );
100 has volume => ( is=>'ro', required=>1, isa=>'Int_0_100' );
101 has xfade => ( is=>'ro', required=>1, isa=>'Int' );
105 __END__
107 =head1 DESCRIPTION
109 The MPD server maintains some information on its current state. Those
110 information can be queried with mpd modules. Some of those information
111 are served to you as an L<Audio::MPD::Common::Status> object.
113 An L<Audio::MPD::Common::Status> object does B<not> update itself
114 regularly, and thus should be used immediately.
116 Note: one should B<never> ever instantiate an L<Audio::MPD::Common::Status>
117 object directly - use the mpd modules instead.