Audio::Moosic(3pm) | User Contributed Perl Documentation | Audio::Moosic(3pm) |
Audio::Moosic - Moosic client library for Perl
use Audio::Moosic; $moo = Audio::Moosic::Unix->new(); $moosic->append('/home/me/somewhat.ogg'); $moosic->play; print $moosic->current, "\n"; $moosic->pause; ...
Audio::Moosic acts as a client for the musical jukebox program Moosic (http://nanoo.org/~daniel/moosic/) by Daniel Pearson <daniel@nanoo.org>.
Using Audio::Moosic you can connect to a moosic server either via an UNIX socket or an INET socket.
$moo = Audio::Moosic::Unix->new(); $moo = Audio::Moosic::Unix->new('/tmp/moosic/socket'); $moo = Audio::Moosic::Inet->new('localhost', 8765);
Constructor. Initializes the class and invokes the connect method. If you're creating a Audio::Moosic::Unix object you can give the location of your moosic socket as parameter. If not ~/.moosic/socket is used. If you're creating a Audio::Moosic::Inet instance you need to pass host and port as arguments.
You can't create an instance of Audio::Moosic itself. Use Unix or Inet subclass.
If the object was able to connect to the moosic server a reference to the object instance is returned. If the connection failed $@ is set and undef returned.
$moo->connect('foobar.com', 9876);
Connect to the moosic server. You normally don't need to run this method in your moosic client.
$moo->disconnect;
Disconnect from the moosic daemon. No more calls will be sent to the server after calling this method. You'll need to reconnect() first.
$moo->reconnect;
Disconnects from the server if you're connected and tries to reconnect.
$moo->reconnect unless $moo->connected;
Check whether you're connected to the moosic server or not.
print $moo->client_config('location'); $conf = $moo->client_config();
Reads the moosic clients config. If a $key argument is given it returns only the value associated with that key, if not the whole config hash.
Would it be a good idea to make the user able to edit the client_config here? Suggestions or maybe patches are welcome.
die unless $moo->ping;
Checks if we're still connected. This method checks the connection explicitly by calling the no_op server method. connected() only checks the value of the 'connected' object property.
my $error = $moo->error; $moo->error('Whaaa!');
If an argument is given it adds the error string to the internal error array. If called in scalar context it returns the last error occurred. If you call error() in list context the whole error array of the Audio::Moosic instance is returned.
$moo->call('foo'); $moo->call('bar', RPC::XML::int->new(3));
This method calls a xml-rpc method on the moosic server. The first argument should be the method name. The arguments of that method should follow behind.
If the request to the moosic server could not be sent the Audio::Moosic instance disconnects from the server and puts the error message into the internal error array. Access it via error(). The object won't send any calls anymore if such an error occurred. You should try to reconnect.
If the request could be sent, but returned an error the error message is added to the error array accessible via error().
If any error occurred call() returns undef. If everything went fine the value of the response is returned.
Normally you don't need to call this method. It is only used by other moosic methods to send their calls more easily. If a new moosic method is not supported by this library yet you'll maybe need to use call() manually. Please notice me if that happens so I'll add the new method.
@api = $moo->api_version; $api = $moo->api_version;
Return the moosic servers API version. If called in scalar context a version string like '1.3' is returned. In list context the mayor and minor numbers of the API version are returned.
$moo->append('/home/florian/whatever.ogg'); $moo->append('/home/florian/foo.ogg', '/home/florian/bar.mp3');
Add songs to the moosic queue. The files to add should be the arguments for the append method. append() returns 1 if there were no errors or something false if there were some.
$moo->clear;
Clears the moosic queue. Only the current song remains playing.
$moo->crop(4); $moo->crop(3, 4);
Remove all playlist items that don't fall within a given range. If the range is represented by one integer all items whose index is greater than or equal to the value will be removed. Two integers represent all items whose index is greater than or equal to the value of first integer and less than the value of the second integer.
$moo->crop_list(1, 4, 3);
Remove all queued items except those referenced by a list of positions.
print $moo->current;
Return the name of the current playing song.
print $moo->current_time;
Return the amount of time the current song has been playing.
$moo->cut(3); $moo->cut(4, 10);
Remove all queued items that fall within a given range. See crop() for details on how that range should look like.
$moo->cut_list(3, 7, 9);
Remove all queued items referenced by list of positions.
$moo->die;
Tell the server to terminate itself.
$moo->filter('foo'); $moo->filter('bar', 4); $moo->filter('moo', 7, 11);
Remove all items that don't match the given regular expression. You may limit this operation to a specific range which is described in crop().
$limit = $moo->get_history_limit;
Get the limit on the size of the history list stored in servers memory.
@config = $moo->getconfig;
Return a list of the server's filetype-player associations.
$moo->halt_queue;
Stop any new songs from being played. Use run_queue() to reverse this state.
See halt_queue().
%hist = $moo->history;
Return a list of items that has been recently played. If a positive integer argument is given than no more than number of items will be returned. Otherwise the entire history is printed.
history() returns an array of hashrefs like that:
@history = (
{ title => 'foo', start => 123.45, stop => 543.21 },
{ title => 'bar', start => 234.56, stop => 654.32 },
...
);
%list = $moo->indexed_list; %list = $moo->indexed_list(1); %list = $moo->indexed_list(2, 5);
List the song queue's contents. If a range is specified, only the items that fall within that range are listed.
indexed_list() returns a hash like that:
%list = (
list => [ 'foo', 'bar', 'moo', ... ],
start => 4
);
$moo->insert(4, 'foo.ogg', 'bar.mp3');
Insert items at a given position in the queue.
$moo->toggle_loop_mode if $moo->is_looping;
Check whether the loop mode is on or not.
$moo->toggle_pause if $moo->is_paused;
Check whether the current song is paused or not.
if($moo->is_queue_running) { ...; }
Check whether the queue consumption (advancement) is activated.
$time = $moo->last_queue_update
Return the time at which the song queue was last modified.
$length = $moo->length
Return the number of items in the song queue.
@list = $moo->list(); @list = $moo->list(2); @list = $moo->list(4, 8); $list_ref = $moo->list()
List the song queue's contents. If a range is specified, only the items that fall within that range are listed. Returns an array if called in list context or an array reference if it's called in scalar context.
$moo->move(10, 4); $moo->move(4, 7, 1);
Move a range of items to a new position within the queue.
$moo->move(3, 5, 7, 11);
Move the items referenced by a list of positions to a new position.
$moo->next; $moo->next(5);
Stop the current song (if any), and jumps ahead to a song that is currently in the queue. The skipped songs are recorded in the history as if they had been played. When called without arguments, this behaves very much like the skip() method, except that it will have an effect even if nothing is currently playing.
$moo->no_op
Do nothing, successfully.
$moo->pause;
Pause the currently playing song.
$moo->prepend('foo.ogg', 'bar.mp3');
Add items to the beginning of the queue.
$moo->previous; $moo->previous(3);
Stops the current song (if any), removes the most recently played song from the history, and puts these songs at the head of the queue. When loop mode is on, the songs at the tail of the song queue are used instead of the most recently played songs in the history.
$moo->putback;
Place the currently playing song at the beginning of the queue.
$length = $moo->queue_length;
Return the number of items in the song queue.
$moo->reconfigure;
Tell the server to reread its player configuration file.
$moo->remove('regex'); $moo->remove('regex', 4); $moo->remove('regex', 1, 3);
Remove all items that match the given regular expression. You can limit this operation by giving a range as described in crop() as last argument.
$moo->replace('foo.ogg', 'bar.mp3');
Replace the contents of the queue with the given items. This is equivalent to calling clear() and prepend() in succession, except that this operation is atomic.
$moo->reverse; $moo->reverse(2); $moo->reverse(5, 7);
Reverse the order of the items in the queue. You can limit this operation by giving a range as described in crop() as last argument.
$moo->run_queue;
Allows new songs to be played again after halt_queue() has been called.
See run_queue().
$moo->set_history_limit(44);
Set the limit on the size of the history list stored in memory.
$moo->set_loop_mode(0); $moo->set_loop_mode(1);
Turn loop mode on or off.
my $config = $moo->showconfig; my %config = $moo->showconfig;
Return the server's player configuration. If showconfig() is called in scalar context a scalar containing the textual description of the configuration is returned. If you call showconfig() in list context a hash which maps the configuration regular expression to the player commands is returned.
$moo->shuffle; $moo->shuffle(2); $moo->shuffle(4, 6);
Rearrange the contents of the queue into a random order. You can limit this operation by giving a range as described for crop() as last argument.
$moo->skip;
Skips the rest of the current song to play the next song in the queue. This only has an effect if there actually is a current song.
$moo->sort; $moo->sort(2); $moo->sort(4, 6);
Arrange the contents of the queue into sorted order.
$moo->stop;
Stop playing the current song and stops new songs from playing. The current song is returned to the head of the song queue and is not recorded in the history list. If loop mode is on, the current song won't be placed at the end of the song queue when it is stopped.
$moo->sub('regex', 'substitition'); $moo->sub('regex', 'substitition', 2); $moo->sub('regex', 'substitition', 1, 7);
Perform a regular expression substitution on the items in the queue. You can limit this operation by giving a range as described for crop() as last argument.
$moo->sub_all('regex', 'substition'); $moo->sub_all('regex', 'substition', 2); $moo->sub_all('regex', 'substition', 1, 7);
Performs a global regular expression substitution on the items in the queue.
$moo->swap( [7, 10], [ 5 ] );
Swap the items contained in one range with the items contained in the other range. The ranges for the swap() method needs to be passed as array references in contrast to other methods that use ranges.
@methods = $moo->listMethods;
Return an array of all available XML-RPC methods on this server.
$help = $moo->methodHelp('sub');
Given the name of a method, return a help string.
$signature = $moo->methodSignature;
Given the name of a method, return an array of legal signatures. Each signature is an array of scalars. The first item of each signature is the return type, and any others items are parameter types. =cut
$moo->multicall(...);
Process an array of calls, and return an array of results. This is not implemented yet.
$moo->toggle_loop_mode;
Turn loop mode on if it is off, and turns it off if it is on.
$moo->toggle_pause;
Pause the current song if it is playing, and unpauses if it is paused.
$moo->unpause;
Unpauses the current song.
$version = $moo->version;
Return the Moosic server's version string.
The following methods aren't methods defined by the moosic API but should be useful when dealing with a moosic server.
$moo->play();
Start playing. If the playback is paused it will be unpaused. If the queue is stopped it will be started.
$moo->append( $song ) if $moo->can_play( $song );
Takes a list of songs as argument and returns all items that can be played by the moosic daemon.
especially for constructors.
If you find some others please report them to Florian Ragwitz <flora@cpan.org>
create the method arguments from methodSignature.
moosic(1), moosicd(1), http://nanoo.org/~daniel/moosic/
Florian Ragwitz <rafl@debian.org>
Copyright (C) 2004-2008 by Florian Ragwitz
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
2018-08-31 | perl v5.26.2 |