From 03f462b761e1fb0933ee4c23adbd64aeb7110e4f Mon Sep 17 00:00:00 2001 From: jq Date: Mon, 21 May 2007 17:20:34 +0000 Subject: [PATCH] [project @ 6182] r4795@merlin: jquelin | 2007-05-20 15:26:39 +0200 new event: song --- lib/POE/Component/Client/MPD.pm | 4 ++-- lib/POE/Component/Client/MPD/Commands.pm | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/POE/Component/Client/MPD.pm b/lib/POE/Component/Client/MPD.pm index e81d0a4..7fc8739 100644 --- a/lib/POE/Component/Client/MPD.pm +++ b/lib/POE/Component/Client/MPD.pm @@ -76,7 +76,7 @@ sub spawn { # -- MPD interaction: general commands 'version' => '_onpub_version', 'kill' => '_onpub_kill', - #'password' => '_onpub_password', +# # 'password' => '_onpub_password', 'updatedb' => '_onpub_updatedb', 'urlhandlers' => '_onpub_urlhandlers', # -- MPD interaction: handling volume & output @@ -88,7 +88,7 @@ sub spawn { 'stats' => '_onpub_stats', 'status' => '_onpub_status', 'current' => '_onpub_current', -# # song + 'song' => '_onpub_song', # # songid # -- MPD interaction: altering settings # # repeat diff --git a/lib/POE/Component/Client/MPD/Commands.pm b/lib/POE/Component/Client/MPD/Commands.pm index d89768f..42c21a1 100644 --- a/lib/POE/Component/Client/MPD/Commands.pm +++ b/lib/POE/Component/Client/MPD/Commands.pm @@ -239,6 +239,27 @@ sub _onpub_current { } +# +# event: song( [$song] ) +# +# Return a POCOCM::Item::Song representing the song number $song. +# If $song is not supplied, returns the current song. +# +sub _onpub_song { + my ($k,$song) = @_[KERNEL, ARG0]; + + my $msg = POE::Component::Client::MPD::Message->new( { + _from => $_[SENDER]->ID, + _request => $_[STATE], + _answer => $SEND, + _commands => [ defined $song ? "playlistinfo $song" : 'currentsong' ], + _cooking => $AS_ITEMS, + _transform => $AS_SCALAR, + } ); + $_[KERNEL]->yield( '_send', $msg ); +} + + # -- MPD interaction: altering settings # -- MPD interaction: controlling playback -- 2.11.4.GIT