Net-Shoutcast-Admin
view release on metacpan or search on metacpan
lib/Net/Shoutcast/Admin.pm view on Meta::CPAN
=item song_history
Returns a list of Net::Shoutcast::Admin::Song objects representing
the the last few songs played
=cut
sub song_history {
my $self = shift;
my @song_objects;
$self->_fetch_status_xml;
for my $song (@{ $self->{data}->{SONGHISTORY}->{SONG} }) {
push @song_objects, Net::Shoutcast::Admin::Song->new(
title => $song->{TITLE},
played_at => $song->{PLAYEDAT},
);
}
return (@song_objects);
}
=item listeners
In scalar context, returns the number of listeners currently connected.
In list context, returns a list of Net::Shoutcast::Admin::Listener
objects representing each listener.
=cut
sub listeners {
my $self = shift;
$self->_fetch_status_xml;
if (!wantarray) {
# okay, it's nice and simple:
return $self->{data}->{CURRENTLISTENERS};
} else {
# okay, we need to return a list of N:S:A::Listener objects:
return if !$self->{data}->{CURRENTLISTENERS};
my @listener_objects;
for my $listener (@{ $self->{data}->{LISTENERS}->{LISTENER} }) {
push @listener_objects, Net::Shoutcast::Admin::Listener->new(
host => $listener->{HOSTNAME},
connect_time => $listener->{CONNECTTIME},
underruns => $listener->{UNDERRUNS} || 5,
agent => $listener->{USERAGENT},
);
}
return (@listener_objects);
}
}
=item source_connected
Returns true if the stream is currently up (a source is connected and streaming
audio to the server)
=cut
sub source_connected {
my $self = shift;
$self->_fetch_status_xml;
return ($self->{data}->{STREAMSTATUS});
}
1; # Magic true value required at end of module
__END__
=back
=head1 BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to
C<bug-net-shoutcast-admin@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
=head1 AUTHOR
David Precious C<< <davidp@preshweb.co.uk> >>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2008, David Precious C<< <davidp@preshweb.co.uk> >>.
All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
=head1 DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
( run in 0.602 second using v1.01-cache-2.11-cpan-5837b0d9d2c )