POE::C...nt::MPD(3pm)
π POE::Component::Client::MPD β the User Contributed Perl Documentation page, but make it cute π
okay bestie, sit down, hydrate, and let me tell you about POE::Component::Client::MPD, a full-blown poe-aware mpd client library, version 2.001. that's the whole vibe. β¨
πΈ NAME πΈ
POE::Component::Client::MPD β a full-blown poe-aware mpd client library. periodt. π
π VERSION π
version 2.001 π¦
β¨ SYNOPSIS β¨
use POE qw{ Component::Client::MPD };
POE::Component::Client::MPD->spawn( {
host => 'localhost',
port => 6600,
password => 's3kr3t', # mpd password
alias => 'mpd', # poe alias
status_msgs_to => 'myapp', # session to send status info to
} );
# ... later on ...
$_[KERNEL]->post( mpd => 'next' );
like yes, that's literally it, and later on you just post to mpd and say next. main character energy fr fr π
π DESCRIPTION π
POCOCM (yes that's the nickname, we're on a nickname basis now) gives you a clear message-passing interface β sitting on top of POE β for talking to and controlling MPD, aka the Music Player Daemon. the moment a new POCOCM object is created, a connection to the MPD server gets established. no waiting around, she's already there π«Ά
after that, commands get sent to the server as messages are passed. that's the whole loop, bestie. π¨
π§ ATTRIBUTES π§
π host
the hostname where MPD is running. defaults to the environment var MPD_HOST, then to 'localhost'. heads up though β MPD_HOST can be shaped like password@host:port, and each of password@ or :port can be omitted. so it's flexible, not chaotic. π
π port
the port that MPD server listens to. defaults to the environment var MPD_PORT, then to the parsed MPD_HOST (cf above, keep up β¨), then to 6600.
π password
the password to access special MPD functions. defaults to the environment var MPD_PASSWORD, then to the parsed MPD_HOST (cf above again), then to the empty string. no password, no problem, no cap.
π alias
a string to alias the newly created POE session. defaults to "mpd".
π status_msgs_to
a session (name or id) to whom to send connection status to. optional, although recommended. no default. when this is set, pococm will send additional events to that session, such as "mpd_connected" when pococm is connected, "mpd_disconnected" when pococm is disconnected, etc. so bestie, you do need to register some handlers for those events β don't leave her on read π
π©· METHODS π©·
π« my $id = POE::Component::Client::MPD->spawn( \%params );
this method will create a POE session responsible for communicating with mpd. it returns the poe id of the session newly created. you can tune it by passing some arguments as a hash reference. see the attributes above for the allowed values. slay. π₯
π PUBLIC EVENTS ACCEPTED π
π MPD-related events
the goal of a POCOCM session is to drive a remote MPD server. this can be achieved by a lot of events β and by "a lot" I mean a LOT. because there are so many of them, they've been regrouped logically into modules. it's giving organized. π
however, note that to use those events, you need to send them to the POCOCM session that you created with spawn() (see above). indeed, the logical split is only internal: you are to use the same peer. one peer, many modules, that's the arrangement π
for a list of public events that update and/or query MPD, see embedded pod in:
POE::Component::Client::MPD::Commandsfor general commandsPOE::Component::Client::MPD::Playlistfor playlist-related commands. those events begin with"pl.".POE::Component::Client::MPD::Collectionfor collection-related commands. those events begin with"coll.".
π disconnect( )
request the POCOCM to be shutdown. leave mpd running. generally sent when one wants to exit her program. she leaves, mpd stays. respectful. π«Ά
π¦ EVENTS FIRED π¦
a POCOCM session will fire events, either to answer an incoming event, or to inform about some changes regarding the remote MPD server. she's chatty like that. π
π Answer events
for each incoming event received by the POCOCM session, it will fire back one of the following answers:
mpd_result( $msg, $answer )
indicates a success. $msg is a POE::Component::Client::MPD::Message object with the original request, to identify the issued command (see POE::Component::Client::MPD::Message pod for more information). its status() attribute is true, further confirming success. π
$answer is what has been answered by the MPD server. depending on the command, it can be either:
"undef": commands"play", etc.- an
Audio::MPD::Common::Statsobject: command"stats" - an
Audio::MPD::Common::Statusobject: command"status" - an
Audio::MPD::Common::Itemobject: commands"song", etc. - an array reference: commands
"coll.files", etc. - etc.
refer to the documentation of each event to know what type of answer you can expect.
mpd_error( $msg, $errstr )
indicates a failure. $msg is a POE::Component::Client::MPD::Message object with the original request, to identify the issued command (see POE::Component::Client::MPD::Message pod for more information). its status() attribute is false, further confirming failure. π
$errstr is what the error message as returned been answered by the MPD server.
π Auto-generated events
if you supplied the "status_msgs_to" attribute, the following events are fired to this peer by pococm:
mpd_connect_error( $reason )
called when pococm-conn could not connect to a mpd server. it can be either retriable, or fatal. check $reason for more information.
mpd_connected( )
called when pococm-conn made sure we're talking to a mpd server. π
mpd_disconnected( )
called when pococm-conn has been disconnected from mpd server. π
π SEE ALSO π
you can find more information on the mpd project on its homepage at <http://www.musicpd.org>, or its wiki <http://mpd.wikia.com>. you may want to have a look at Audio::MPD, a non-POE aware module to access MPD.
you can look for information on this module at:
- Search CPAN
<http://search.cpan.org/dist/POE-Component-Client-MPD>
- See open / report bugs
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-Client-MPD>
- Mailing-list (same as
Audio::MPD)
<http://groups.google.com/group/audio-mpd>
- Git repository
<http://github.com/jquelin/poe-component-client-mpd>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/POE-Component-Client-MPD>
- CPAN Ratings
<http://cpanratings.perl.org/d/POE-Component-Client-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. β¨
and that's the whole page, bestie β this one's from perl v5.40.1, dated 2025-04-11, and it lives under the name POE::C...nt::MPD(3pm). go forth and control that music daemon, you absolute icon π«ΆππΈ
π¦ where this page comes from
- debian trixie: libpoe-component-client-mpd-perl 2.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpoe-component-client-mpd-perl 2.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpoe-component-client-mpd-perl 2.001-5 Β· 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