Audio::MPD(3pm)

๐Ÿ“ฆ
version 2.004 ยท 2 versions
  • 2.004 ยท debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 2.004 ยท ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– 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::MPD is 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. The POE::Component::Client::MPD module is way safer โ€” you're advised to use it instead of Audio::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

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