Audio-XMMSClient-XMLRPC

 view release on metacpan or  search on metacpan

lib/Audio/XMMSClient/XMLRPC.pm  view on Meta::CPAN

Version 0.03

=cut

our $VERSION = '0.03';

=head1 SYNOPSIS

    use Audio::XMMSClient::XMLRPC;

    my $rpc = Audio::XMMSClient::XMLRPC->new();
    $rpc->loop;

=head1 FUNCTIONS

=head2 new

    my $rpc = Audio::XMMSClient::XMLRPC->new( \%options );

Creates a new Audio::XMMSClient::XMLRPC instance with the given C<%options>.
Valid options are:

=over

=item B<no_httpd>

If passed with a "true" value, prevents the creation and storage of the
HTTP::Daemon object. This allows for deployment of a server object in other
environments. Note that if this is set, the loop method described below will
silently attempt to use the L<Net::Server> module.

=item B<no_default>

If passed with a "true" value, prevents the loading of the default methods
provided with the L<RPC::XML> distribution. The methods themselves are described
below (see "The Default Methods Provided").

=item B<path>

=item B<port>

=item B<queue>

=item B<timeout>

These four are specific to the HTTP-based nature of the server.  The B<path>
argument sets the additional URI path information that clients would use to
contact the server.  Internally, it is not used except in outgoing status and
introspection reports. The B<host>, B<port> and B<queue> arguments are passed
to the L<HTTP::Daemon> constructor if they are passed. They set the hostname,
TCP/IP port, and socket listening queue, respectively. They may also be used if
the server object tries to use L<Net::Server> as an alternative server core.

=back

=cut

sub new {
    my $base = shift;

    my $self = $base->SUPER::new(@_);

    (my $default_name = __PACKAGE__) =~ s/::/-/g;
    $self->name( $default_name ) unless defined $self->name;
    $self->port( 9000 ) unless defined $self->port;

    my $xmms = Audio::XMMSClient->new( $self->name );
    $xmms->connect or die $xmms->get_last_error;

    $self->_xmms( $xmms );

    my $server = RPC::XML::Server->new(
            (no_http     => $self->no_http)    x! ! $self->no_http,
            (no_default  => $self->no_default) x! ! $self->no_default,
            (path        => $self->path)       x! ! $self->path,
            (port        => $self->port)       x! ! $self->port,
            (queue       => $self->queue)      x! ! $self->queue,
            (timeout     => $self->timeout)    x! ! $self->timeout,
    );

    $self->_server( $server );
    $self->_add_methods;

    return $self;
}

{
    my $method_help = {
        quit                                        => 'Tell the server to quit.',
        plugin_list                                 => 'Get a list of loaded plugins from the server.',
        main_stats                                  => 'Get a list of statistics from the server.',
        playlist_shuffle                            => 'Shuffles the current playlist.',
        playlist_add                                => 'Add the url to the playlist.',
        playlist_add_args                           => 'Add the url to the playlist with arguments.',
        playlist_add_id                             => 'Add a medialib id to the playlist.',
        playlist_add_encoded                        => 'Add the url to the playlist.',
        playlist_remove                             => 'Remove an entry from the playlist.',
        playlist_clear                              => 'Clears the current playlist.',
        playlist_list                               => 'List current playlist.',
        playlist_sort                               => 'Sorts the playlist according to the property.',
        playlist_set_next                           => 'Set next entry in the playlist.',
        playlist_set_next_rel                       => 'Same as xmms.playlist.set_next but relative to the current postion.',
        playlist_move                               => 'Move a playlist entry to a new position (absolute move).',
        playlist_current_pos                        => 'Retrive the current position in the playlist.',
        playlist_insert                             => 'Insert entry at given position in playlist.',
        playlist_insert_args                        => 'Insert entry at given position in playlist wit args.',
        playlist_insert_encoded                     => 'Insert entry at given position in playlist.',
        playlist_insert_id                          => 'Insert a medialib id at given position in playlist.',
        playlist_radd                               => 'Adds a directory recursivly to the playlist.',
        playlist_radd_encoded                       => 'Adds a directory recursivly to the playlist.',
        playback_stop                               => 'Stops the current playback.',
        playback_tickle                             => 'Stop decoding of current song.',
        playback_start                              => 'Starts playback if server is idle.',
        playback_pause                              => 'Pause the current playback, will tell the output to not read nor write.',
        playback_current_id                         => 'Make server emit the current id.',
        playback_seek_ms                            => 'Seek to a absolute time in the current playback.',
        playback_seek_ms_rel                        => 'Seek to a time relative to the current position in the current playback.',
        playback_seek_samples                       => 'Seek to a absoulte number of samples in the current playback.',
        playback_seek_samples_rel                   => 'Seek to a number of samples relative to the current position in the current playback.',
        playback_playtime                           => 'Request the playback_playtime signal.',
        playback_status                             => 'Make server emit the playback status.',



( run in 1.582 second using v1.01-cache-2.11-cpan-f56aa216473 )