Audio::MPD(3pm)
๐ Audio::MPD ๐
okay so this is the Audio::MPD page, and it lives in the User Contributed Perl Documentation corner of your manual, bestie ๐
โจ VERSION โจ
version 2.004 ๐
๐ธ SYNOPSIS ๐ธ
use Audio::MPD;
my $mpd = Audio::MPD->new;
$mpd->play;
sleep 10;
$mpd->next;
๐ฆ DESCRIPTION ๐ฆ
Audio::MPD hands you a clean, object-oriented interface for talking to and controlling MPD (Music Player Daemon) servers. The second you create a new Audio::MPD object, boom โ the connection to the MPD server is already established. main character energy fr ๐
So here's the thing: mpd is still in its 0.x era, so Audio::MPD sticks to the latest mpd protocol & behaviour (0.15 as of writing) and does not try to keep backward compatibility. periodt.
Also know this: by default the module connects to mpd before sending any command, and disconnects after the command has been issued. Is that scheme optimal? No bestie, it is far from optimal ๐ญ โ but it means we never have to care about timeout disconnections. And because of that, the "idle" command (new in mpd 0.14) is not โ and will not be โ supported in Audio::MPD. That one's getting implemented in POE::Component::Client::MPD instead, iykyk.
/!\ Heads up:Audio::MPDis using high-level, blocking sockets. That means if the mpd server is slow, or hangs for whatever reason, or even crashes abruptly, your program will be hung forever in this sub. ThePOE::Component::Client::MPDmodule is way safer โ you're advised to use it instead ofAudio::MPD. Or you can try setting"conntype"to$REUSE(peep the Audio::MPD constructor for more deets), but then you'd be on your own to deal with disconnections ๐
๐ Searching the collection
To search the collection, use the "collection()" accessor โ it returns the associated Audio::MPD::Collection object. Then you can call stuff like:
$mpd->collection->all_songs;
See the Audio::MPD::Collection documentation for more details on available methods ๐
๐ถ Handling the playlist
To update the playlist, use the "playlist()" accessor โ it returns the associated Audio::MPD::Playlist object. Then you can call stuff like:
$mpd->playlist->clear;
See the Audio::MPD::Playlist documentation for more details on available methods โจ
๐ ATTRIBUTES ๐
host
The hostname where MPD is running. Defaults to the environment var "MPD_HOST", then to 'localhost'. Note that "MPD_HOST" can be of the form "password@host:port" (and each of "password@" or ":port" can be omitted) ๐ซถ
port
The port that the MPD server listens to. Defaults to environment var "MPD_PORT", then to the parsed "MPD_HOST" (cf above), then to 6600.
password
The password to access special MPD functions. Defaults to environment var "MPD_PASSWORD", then to the parsed "MPD_HOST" (cf above), then to the empty string.
conntype
Change how the connection to the mpd server is handled. It should be of a "CONNTYPE" type (cf Audio::MPD::Types). Use either the "reuse" string to reuse the same connection, or "once" to open a new connection per command (default).
๐ METHODS ๐
new
my $mpd = Audio::MPD->new( \%opts );
This is the constructor for Audio::MPD. You can specify any of the attributes (cf above) ๐
๐ CONTROLLING THE SERVER ๐
ping
$mpd->ping;
Sends a ping command to the mpd server ๐
version
my $version = $mpd->version;
Returns mpd's version number as advertised during the connection. Note that mpd returns the protocol version when connected โ and that protocol version can differ from the real mpd version. eg, mpd version 0.13.2 is "speaking" and thus advertising version 0.13.0. sneaky bestie ๐ญ
kill
$mpd->kill;
Sends a message to the MPD server telling it to shut down ๐
set_password
$mpd->set_password( [$password] );
Change the password used to communicate with the MPD server to $password. An empty string is assumed if $password is not supplied ๐
updatedb
$mpd->updatedb( [$path] );
Force mpd to rescan its collection. If $path (relative to MPD's music directory) is supplied, MPD will only scan that โ otherwise, MPD will rescan its whole collection ๐
urlhandlers
my @handlers = $mpd->urlhandlers;
Return an array of supported URL schemes ๐
๐ HANDLING VOLUME & OUTPUT ๐
volume
$mpd->volume( [+][-]$volume );
Sets the audio output volume percentage to the absolute $volume. If $volume is prefixed by '+' or '-' then the volume is changed relatively by that value ๐๐
outputs
my @outputs = $mpd->outputs( );
Return a list of "Audio::MPD::Common::Outputs" with all outputs available within MPD ๐๏ธ
output_enable
$mpd->output_enable( $output );
Enable the specified audio output. $output is the ID of the audio output โ
output_disable
$mpd->output_disable( $output );
Disable the specified audio output. $output is the ID of the audio output ๐ซ
๐ง RETRIEVING INFO FROM CURRENT STATE ๐ง
stats
my $stats = $mpd->stats;
Return an Audio::MPD::Common::Stats object with the current statistics of MPD. See the associated pod for more information ๐
status
my $status = $mpd->status;
Return an Audio::MPD::Common::Status object with various information on current MPD server settings. See the associated pod for more information ๐
current
my $song = $mpd->current;
Return an Audio::MPD::Common::Item::Song representing the song currently playing ๐ต
song
my $song = $mpd->song( [$song] );
Return an Audio::MPD::Common::Item::Song representing the song number $song. If $song is not supplied, returns the current song ๐ง
songid
my $song = $mpd->songid( [$songid] );
Return an Audio::MPD::Common::Item::Song representing the song with id $songid. If $songid is not supplied, returns the current song ๐ง
โ๏ธ ALTERING MPD SETTINGS โ๏ธ
repeat
$mpd->repeat( [$repeat] );
Set the repeat mode to $repeat (1 or 0). If $repeat is not specified then the repeat mode is toggled ๐
random
$mpd->random( [$random] );
Set the random mode to $random (1 or 0). If $random is not specified then the random mode is toggled ๐
fade
$mpd->fade( [$seconds] );
Enable crossfading and set the duration of crossfade between songs. If $seconds is not specified, or $seconds is 0, then crossfading is disabled ๐
โถ๏ธ CONTROLLING PLAYBACK โธ๏ธ
play
$mpd->play( [$song] );
Begin playing the playlist at song number $song. If no argument is supplied, resume playing ๐ถ
playid
$mpd->playid( [$songid] );
Begin playing the playlist at song ID $songid. If no argument is supplied, resume playing ๐ถ
pause
$mpd->pause( [$state] );
Pause playback. If $state is 0 then the current track is unpaused, if $state is 1 then the current track is paused.
Note that if $state is not given, the pause state will be toggled โฏ๏ธ
stop
$mpd->stop;
Stop playback ๐
next
$mpd->next;
Play the next song in the playlist โญ๏ธ
prev
$mpd->prev;
Play the previous song in the playlist โฎ๏ธ
seek
$mpd->seek( $time, [$song]);
Seek to $time seconds in song number $song. If $song number is not specified then the perl module will try and seek to $time in the current song โฑ๏ธ
seekid
$mpd->seekid( $time, $songid );
Seek to $time seconds in song ID $songid. If $song number is not specified then the perl module will try and seek to $time in the current song โฑ๏ธ
๐ SEE ALSO ๐
You can find more information on the mpd project on its homepage at <http://www.musicpd.org>.wikia.com>.
Original code (2005) by Tue Abrahamsen "<tue.abrahamsen@gmail.com>", documented in 2006 by Nicholas J. Humfrey "<njh@aelius.com>".
You can look for information on this module at:
- Search CPAN
<http://metacpan.org/release/Audio-MPD>
- See open / report bugs
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Audio-MPD>
- Mailing-list
<http://groups.google.com/group/audio-mpd>
- Git repository
<http://github.com/jquelin/audio-mpd.git>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Audio-MPD>
- CPAN Ratings
<http://cpanratings.perl.org/d/Audio-MPD>
๐ซ AUTHOR ๐ซ
Jerome Quelin
๐ COPYRIGHT AND LICENSE ๐
This software is copyright (c) 2007 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page bestie, no cap, every single flag and file path intact ๐ โจ this was perl v5.34.0, dated 2022-06-08, and it's the Audio::MPD(3pm) page โ slay, you read the whole thing, so proud of you ๐ซถ๐๐ฆ
๐ฆ where this page comes from
- debian bookworm: libaudio-mpd-perl 2.004-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libaudio-mpd-perl 2.004-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libaudio-mpd-perl 2.004-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libaudio-mpd-perl 2.004-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libaudio-mpd-perl 2.004-3 ยท 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