POE::C...nt::MPD(3pm)

πŸ“¦
version 2.001 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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 πŸ‘‘

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::Commands for general commands
  • POE::Component::Client::MPD::Playlist for playlist-related commands. those events begin with "pl.".
  • POE::Component::Client::MPD::Collection for 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::Stats object: command "stats"
  • an Audio::MPD::Common::Status object: command "status"
  • an Audio::MPD::Common::Item object: 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 πŸ‘‘

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