Audio::Moosic(3pm)
๐ Audio::Moosic ๐
okay bestie, welcome to the Audio::Moosic page โ it's the Moosic client library for Perl and honestly? it's giving "let me talk to your jukebox for you" ๐
โจ SYNOPSIS โจ
use Audio::Moosic;
$moo = Audio::Moosic::Unix->new();
$moosic->append('/home/me/somewhat.ogg');
$moosic->play;
print $moosic->current, "\n";
$moosic->pause;
...
๐ฆ DESCRIPTION ๐ฆ
So Audio::Moosic is literally a client for the musical jukebox program Moosic ( http://nanoo.org/~daniel/moosic/ ) by Daniel Pearson <daniel@nanoo.org> โ no cap, that's the whole vibe.
Using Audio::Moosic you can connect to a moosic server either via an UNIX socket or an INET socket. pick your fighter ๐
๐ธ METHODS ๐ธ
๐ซ new
$moo = Audio::Moosic::Unix->new();
$moo = Audio::Moosic::Unix->new('/tmp/moosic/socket');
$moo = Audio::Moosic::Inet->new('localhost', 8765);
Constructor time, bestie โจ It initializes the class and invokes the connect method. So if you're creating a Audio::Moosic::Unix object, you can pass the location of your moosic socket as a parameter. If you don't? Then ~/.moosic/socket gets used instead, nbd. And if you're making a Audio::Moosic::Inet instance, you gotta pass host and port as arguments โ that's not optional, periodt.
๐จ Real talk: you cannot create an instance ofAudio::Moosicitself. Use theUnixorInetsubclass, iykyk.
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 is returned. sad girl hours ๐ญ
๐ connect
$moo->connect('foobar.com', 9876);
Connects to the moosic server. Ngl you normally don't need to run this method in your moosic client โ it just kinda happens for you ๐
๐ disconnect
$moo->disconnect;
Disconnects from the moosic daemon. After you call this, no more calls will be sent to the server. You'll need to reconnect() first. so dramatic, but valid ๐
๐ reconnect
$moo->reconnect;
Disconnects from the server if you're connected, and tries to reconnect. it's giving "we broke up but let's try again" energy ๐
๐ง connected
$moo->reconnect unless $moo->connected;
Check whether you're connected to the moosic server or not. simple as that, bestie โจ
๐ client_config
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, you get the whole config hash. obsessed with options tbh.
Hmm โ "Would it be a good idea to make the user able to edit the client_config here? Suggestions or maybe patches are welcome." โ straight from the author's keyboard, and honestly? valid question ๐
๐ฉบ ping
die unless $moo->ping;
Checks if we're still connected. And here's the tea โ โ this method checks the connection explicitly by calling the no_op server method. Meanwhile connected() only checks the value of the 'connected' object property. two very different vibes, don't mix them up ๐
๐ญ error
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 that occurred. If you call error() in list context, the whole error array of the Audio::Moosic instance is returned. collect them all like Pokรฉmon, bestie ๐
๐ call
$moo->call('foo');
$moo->call('bar', RPC::XML::int->new(3));
This method calls an xml-rpc method on the moosic server. The first argument should be the method name, and the arguments of that method should follow behind it. okay so:
- If the request to the moosic server could not be sent, the
Audio::Moosicinstance disconnects from the server and puts the error message into the internal error array. Access it viaerror(). 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()returnsundef. If everything went fine, the value of the response is returned โจ
Normally you don't need to call this method โ it's only used by other moosic methods to send their calls more easily. But if a new moosic method is not supported by this library yet, you'll maybe need to use call() manually. And: "Please notice me if that happens so I'll add the new method." ๐ซถ adorable, we love a responsive maintainer.
๐ท๏ธ api_version
@api = $moo->api_version;
$api = $moo->api_version;
Returns the moosic servers API version. In scalar context you get a version string like '1.3'. In list context you get the mayor and minor numbers of the API version. (yes, "mayor" โ that's how the original says it, and we respect the original ๐)
โ append
$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. slay when it works, oof when it doesn't ๐ญ
๐งน clear
$moo->clear;
Clears the moosic queue. Only the current song remains playing. it's giving "clean slate, fresh start" โจ
โ๏ธ crop
$moo->crop(4);
$moo->crop(3, 4);
Remove all playlist items that don't fall within a given range. So here's how the range works, bestie:
- 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 the first integer and less than the value of the second integer.
okay so note that second one is "less than", not "less than or equal" โ the details matter ๐
๐ crop_list
$moo->crop_list(1, 4, 3);
Remove all queued items except those referenced by a list of positions. keep only the chosen ones ๐
๐ต current
print $moo->current;
Return the name of the current playing song. main character energy only ๐
โฑ๏ธ current_time
print $moo->current_time;
Return the amount of time the current song has been playing. ticking away, iconic โณ
๐ก๏ธ cut
$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 โ same rules, different verb ๐ฅ
๐ฏ cut_list
Remove all queued items referenced by list of positions. bye besties ๐
---
## ๐ `die`
$moo->die;
Tell the server to terminate itself. <red>yes, really, that's the whole method</red> โ it's giving lethal ๐ use with intention, bestie.
---
## ๐งผ `filter`
$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()`. regex said "not today" and honestly, same ๐ธ
---
## ๐ `get_history_limit`
$limit = $moo->get_history_limit;
Get the limit on the size of the history list stored in servers memory ๐ง
---
## โ๏ธ `getconfig`
@config = $moo->getconfig;
Return a list of the server's filetype-player associations. who plays what, the whole roster ๐ง
---
## ๐ `halt_queue`
$moo->halt_queue;
Stop any new songs from being played. Use `run_queue()` to reverse this state. queue said "no more, i'm tired" ๐ด
---
## ๐ `haltqueue`
See `halt_queue()`. (same thing, shorter name โ pick your fave ๐
)
---
## ๐ `history`
%hist = $moo->history;
Return a list of items that has been recently played. If a positive integer argument is given, then no more than that number of items will be returned. Otherwise the entire history is printed. receipts of everything you've played, bestie ๐งพ
`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 }, ... );
---
## ๐๏ธ `indexed_list`
%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 );
---
## ๐ฅ `insert`
$moo->insert(4, 'foo.ogg', 'bar.mp3');
Insert items at a given position in the queue. cutting the line but make it legal ๐
---
## ๐ `is_looping`
$moo->toggle_loop_mode if $moo->is_looping;
Check whether the loop mode is on or not. round and round and round we go ๐
---
## โธ๏ธ `is_paused`
$moo->toggle_pause if $moo->is_paused;
Check whether the current song is paused or not.
---
## โถ๏ธ `is_queue_running`
if($moo->is_queue_running) { ...; }
Check whether the queue consumption (advancement) is activated. is the queue actually moving or is it just sitting there ๐ฆ
---
## ๐ฐ๏ธ `last_queue_update`
$time = $moo->last_queue_update
Return the time at which the song queue was last modified. timestamped, iconic โฑ๏ธ
---
## ๐ `length`
$length = $moo->length
Return the number of items in the song queue. math but make it music ๐ถ
---
## ๐ `list`
@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 <yellow>list context</yellow>, or an array reference if it's called in <yellow>scalar context</yellow>. context is everything, bestie ๐
---
## ๐ `move`
$moo->move(10, 4); $moo->move(4, 7, 1);
Move a range of items to a new position within the queue. rearrange, restyle, re-slay โจ
---
## ๐ช `move_list`
$moo->move(3, 5, 7, 11);
Move the items referenced by a list of positions to a new position. (yes, the example says `move` โ we keep it exactly as written, no edits, fr fr ๐)
---
## โญ๏ธ `next`
$moo->next; $moo->next(5);
Stop the current song (if any), and jump 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 <yellow>even if nothing is currently playing</yellow>. so it's skip but with main character energy ๐
---
## ๐ซ `no_op`
$moo->no_op
Do nothing, successfully. the most relatable method on this entire page ๐ญ iconic.
---
## โฏ๏ธ `pause`
$moo->pause;
Pause the currently playing song. hold that thought โ
---
## ๐ฅ `prepend`
$moo->prepend('foo.ogg', 'bar.mp3');
Add items to the beginning of the queue. front of the line, no waiting ๐
---
## โฎ๏ธ `previous`
$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. time travel but for your playlist ๐ฐ๏ธโจ
---
## ๐ `putback`
$moo->putback;
Place the currently playing song at the beginning of the queue. "actually, one more time" ๐
---
## ๐ `queue_length`
$length = $moo->queue_length;
Return the number of items in the song queue. (yes, same job as `length` โ both are here, both stay ๐)
---
## โป๏ธ `reconfigure`
$moo->reconfigure;
Tell the server to reread its player configuration file. glow up for the config ๐
---
## ๐๏ธ `remove`
$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 the last argument. (yep โ `filter` removes the non-matches, `remove` removes the matches. don't get it twisted bestie ๐ญ)
---
## ๐ `replace`
$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 <yellow>atomic</yellow>. all at once, no in-between, slay ๐ฅ
---
## ๐ `reverse`
$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 the last argument. upside down, backwards, but make it chic ๐
---
## ๐ `run_queue`
$moo->run_queue;
Allows new songs to be played again after `halt_queue()` has been called. we're so back ๐
---
## ๐โโ๏ธ `runqueue`
See `run_queue()`. (same method, shorter name, both iconic ๐
)
---
## ๐ข `set_history_limit`
$moo->set_history_limit(44);
Set the limit on the size of the history list stored in memory. how much past we're keeping, bestie ๐ง
---
## ๐ `set_loop_mode`
$moo->set_loop_mode(0); $moo->set_loop_mode(1);
Turn loop mode on or off. `0` for off, `1` for on โ the eternal cycle begins or ends ๐
---
## ๐ `showconfig`
my $config = $moo->showconfig; my %config = $moo->showconfig;
the config reveal moment โ and that's where part 1 wraps... well, not wraps exactly, because there's more coming ๐
<pink>Return the server's player configuration</pink>, bestie. If `showconfig()` is called in <cyan>scalar context</cyan> a scalar containing the textual description of the configuration is returned. If you call `showconfig()` in <cyan>list context</cyan> a hash which maps the configuration regular expression to the player commands is returned.
---
### <pink>shuffle</pink> ๐ฒ
$moo->shuffle; $moo->shuffle(2); $moo->shuffle(4, 6);
<yellow>Rearrange the contents of the queue into a random order.</yellow> You can limit this operation by giving a range as described for `crop()` as last argument.
---
### <pink>skip</pink> โญ๏ธ
$moo->skip;
<yellow>Skips the rest of the current song to play the next song in the queue.</yellow> This only has an effect if there actually is a current song.
---
### <pink>sort</pink> ๐ค
$moo->sort; $moo->sort(2); $moo->sort(4, 6);
<yellow>Arrange the contents of the queue into sorted order.</yellow>
---
### <pink>stop</pink> ๐
$moo->stop;
<yellow>Stop playing the current song and stops new songs from playing.</yellow> 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.
---
### <pink>sub</pink> ๐
$moo->sub('regex', 'substitition'); $moo->sub('regex', 'substitition', 2); $moo->sub('regex', 'substitition', 1, 7);
<yellow>Perform a regular expression substitution on the items in the queue.</yellow> You can limit this operation by giving a range as described for `crop()` as last argument.
---
### <pink>sub_all</pink> ๐
$moo->sub_all('regex', 'substition'); $moo->sub_all('regex', 'substition', 2); $moo->sub_all('regex', 'substition', 1, 7);
<yellow>Performs a global regular expression substitution on the items in the queue.</yellow>
---
### <pink>swap</pink> ๐
$moo->swap( [7, 10], [ 5 ] );
<yellow>Swap the items contained in one range with the items contained in the other range.</yellow> The ranges for the `swap()` method need to be passed as array references in contrast to other methods that use ranges.
---
### <pink>listMethods</pink> ๐
@methods = $moo->listMethods;
<yellow>Return an array of all available XML-RPC methods on this server.</yellow>
---
### <pink>methodHelp</pink> โ
$help = $moo->methodHelp('sub');
<yellow>Given the name of a method, return a help string.</yellow>
---
### <pink>methodSignature</pink> โ๏ธ
$signature = $moo->methodSignature;
<yellow>Given the name of a method, return an array of legal signatures.</yellow> 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`
---
### <pink>multicall</pink> ๐
$moo->multicall(...);
<yellow>Process an array of calls, and return an array of results.</yellow> This is not implemented yet.
---
### <pink>toggle_loop_mode</pink> ๐
$moo->toggle_loop_mode;
<yellow>Turn loop mode on if it is off, and turns it off if it is on.</yellow>
---
### <pink>toggle_pause</pink> โฏ๏ธ
$moo->toggle_pause;
<yellow>Pause the current song if it is playing, and unpauses if it is paused.</yellow>
---
### <pink>unpause</pink> โถ๏ธ
$moo->unpause;
<yellow>Unpauses the current song.</yellow>
---
### <pink>version</pink> ๐ข
$version = $moo->version;
<yellow>Return the Moosic server's version string.</yellow>
---
# โจ <hotpink>HELPER METHODS</hotpink> โจ
<lavender>The following methods aren't methods defined by the moosic API but should be useful when dealing with a moosic server.</lavender>
### <pink>play</pink> ๐ต
$moo->play();
<yellow>Start playing.</yellow> If the playback is paused it will be unpaused. If the queue is stopped it will be started.
### <pink>can_play</pink> โ
$moo->append( $song ) if $moo->can_play( $song );
<yellow>Takes a list of songs as argument and returns all items that can be played by the moosic daemon.</yellow>
---
# ๐ <red>BUGS</red> ๐
- <peach>check arguments more strictly</peach>
<peach>especially for constructors.</peach>
If you find some others please report them to Florian Ragwitz <flora@cpan.org>
---
# ๐ <purple>TODO</purple> ๐
- <peach>implement system_multicall</peach>
- <peach>improve client_config</peach>
- <peach>maybe use autoloader to load subs on demand</peach>
<peach>create the method arguments from methodSignature.</peach>
---
# ๐ <rainbow>SEE ALSO</rainbow> ๐
moosic(1), moosicd(1), http://nanoo.org/~daniel/moosic/
---
# ๐ <yellow>AUTHOR</yellow> ๐
Florian Ragwitz <rafl@debian.org>
---
# ๐ <hotpink>COPYRIGHT AND LICENSE</hotpink> ๐
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.
---
and that's the whole vibe check! this page is from <cyan>`perl v5.36.0`</cyan>, dated <cyan>`2022-12-12`</cyan>, and it's <cyan>`Audio::Moosic(3pm)`</cyan>. stay slay, bestie ๐
โจ
๐ฆ where this page comes from
- debian bookworm: libaudio-moosic-perl 0.10-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libaudio-moosic-perl 0.10-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libaudio-moosic-perl 0.10-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libaudio-moosic-perl 0.10-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libaudio-moosic-perl 0.10-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms