no need to document constructor
[audio-mpd-common.git] / lib / Audio / MPD / Common / Status.pm
blob38b43507a3f01fb1293bda38bbb4ebec35cd5ae6
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;
11 subtype 'Int_0_100'
12 => as 'Int'
13 => where { $_ >= 0 && $_ <= 100 }
14 => message { "$_ is not between 0 and 100" };
15 enum 'State' => qw{ play stop pause };
16 coerce 'Audio::MPD::Common::Time'
17 => from 'Str'
18 => via { Audio::MPD::Common::Time->new($_) };
21 # -- attributes
23 =attr $status->audio()
25 A string with the sample rate of the song currently playing, number of
26 bits of the output and number of channels (2 for stereo) - separated
27 by a colon.
29 =attr $status->bitrate()
31 The instantaneous bitrate in kbps.
33 =attr $status->error()
35 May appear in special error cases, such as when disabling output.
37 =attr $status->playlist()
39 The playlist version number, that changes every time the playlist
40 is updated.
42 =attr $status->playlistlength()
44 The number of songs in the playlist.
46 =attr $status->random()
48 Whether the playlist is read randomly or not.
50 =attr $status->repeat()
52 Whether the song is repeated or not.
54 =attr $status->song()
56 The offset of the song currently played in the playlist.
58 =attr $status->songid()
60 The song id (MPD id) of the song currently played.
62 =attr $status->state()
64 The state of MPD server. Either C<play>, C<stop> or C<pause>.
66 =attr $status->time()
68 An L<Audio::MPD::Common::Time> object, representing the time elapsed /
69 remainging and total. See the associated pod for more details.
71 =attr $status->updating_db()
73 An integer, representing the current update job.
75 =attr $status->volume()
77 The current MPD volume - an integer between 0 and 100.
79 =attr $status->xfade()
81 The crossfade in seconds.
83 =cut
85 has audio => ( is=>'ro', required=>1, isa=>'Str' );
86 has bitrate => ( is=>'ro', required=>1, isa=>'Int' );
87 has error => ( is=>'ro', required=>0, isa=>'Str' );
88 has playlist => ( is=>'ro', required=>1, isa=>'Int' );
89 has playlistlength => ( is=>'ro', required=>1, isa=>'Int' );
90 has random => ( is=>'ro', required=>1, isa=>'Bool' );
91 has repeat => ( is=>'ro', required=>1, isa=>'Bool' );
92 has songid => ( is=>'ro', required=>1, isa=>'Int' );
93 has song => ( is=>'ro', required=>1, isa=>'Int' );
94 has state => ( is=>'ro', required=>1, isa=>'State' );
95 has time => ( is=>'ro', required=>1, isa=>'Audio::MPD::Common::Time', coerce=>1 );
96 has updating_db => ( is=>'ro', required=>1, isa=>'Int' );
97 has volume => ( is=>'ro', required=>1, isa=>'Int_0_100' );
98 has xfade => ( is=>'ro', required=>1, isa=>'Int' );
102 __END__
104 =head1 DESCRIPTION
106 The MPD server maintains some information on its current state. Those
107 information can be queried with mpd modules. Some of those information
108 are served to you as an L<Audio::MPD::Common::Status> object.
110 An L<Audio::MPD::Common::Status> object does B<not> update itself
111 regularly, and thus should be used immediately.
113 Note: one should B<never> ever instantiate an L<Audio::MPD::Common::Status>
114 object directly - use the mpd modules instead.