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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
#
# This file is part of Audio::MPD::Common
# Copyright (c) 2007 Jerome Quelin, all rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
#
package Audio::MPD::Common::Status;
use warnings;
use strict;
use Audio::MPD::Common::Time;
use base qw[ Class::Accessor::Fast ];
__PACKAGE__->mk_accessors
( qw[ audio bitrate error playlist playlistlength random
repeat song songid state time volume updating_db xfade ] );
#our ($VERSION) = '$Rev: 5865 $' =~ /(\d+)/;
#--
# Constructor
#
# my $status = Audio::MPD::Common::Status->new( \%kv )
#
# The constructor for the class Audio::MPD::Common::Status. %kv is
# a cooked output of what MPD server returns to the status command.
#
sub new {
my ($class, $kv) = @_;
my %kv = %$kv;
$kv{time} = Audio::MPD::Common::Time->new( delete $kv{time} );
bless \%kv, $class;
return \%kv;
}
1;
__END__
=head1 NAME
Audio::MPD::Common::Status - class representing MPD status
=head1 SYNOPSIS
print $status->bitrate;
=head1 DESCRIPTION
The MPD server maintains some information on its current state. Those
information can be queried with mpd modules. Some of those information
are served to you as an C<Audio::MPD::Common::Status> object.
Note that an C<Audio::MPD::Common::Status> object does B<not> update
itself regularly, and thus should be used immediately.
=head1 METHODS
=head2 Constructor
=over 4
=item new( \%kv )
The C<new()> method is the constructor for the C<Audio::MPD::Common::Status>
class.
Note: one should B<never> ever instantiate an C<Audio::MPD::Common::Status>
object directly - use the mpd modules instead.
=back
=head2 Accessors
Once created, one can access to the following members of the object:
=over 4
=item $status->audio()
A string with the sample rate of the song currently playing, number of bits
of the output and number of channels (2 for stereo) - separated by a colon.
=item $status->bitrate()
The instantaneous bitrate in kbps.
=item $status->error()
May appear in special error cases, such as when disabling output.
=item $status->playlist()
The playlist version number, that changes every time the playlist is updated.
=item $status->playlistlength()
The number of songs in the playlist.
=item $status->random()
Whether the playlist is read randomly or not.
=item $status->repeat()
Whether the song is repeated or not.
=item $status->song()
The offset of the song currently played in the playlist.
=item $status->songid()
The song id (MPD id) of the song currently played.
=item $status->state()
The state of MPD server. Either C<play>, C<stop> or C<pause>.
=item $status->time()
An C<Audio::MPD::Common::Time> object, representing the time elapsed /
remainging and total. See the associated pod for more details.
=item $status->updating_db()
An integer, representing the current update job.
=item $status->volume()
The current MPD volume - an integer between 0 and 100.
=item $status->xfade()
The crossfade in seconds.
=back
Please note that those accessors are read-only: changing a value will B<not>
change the current settings of MPD server. Use the mpd modules to alter the
settings.
=head1 SEE ALSO
=over 4
=item L<Audio::MPD>
=item L<POE::Component::Client::MPD>
=back
=head1 AUTHOR
Jerome Quelin, C<< <jquelin at cpan.org> >>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2007 Jerome Quelin, all rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
|