1 package Xchat::VPIT::MPD;
10 use lib get_info 'xchatdir';
17 hook_command $_, sub {
18 my $mpd = Audio::MPD->new;
20 print $ph "Couldn't connect to the MPD server\n";
24 my $status = $mpd->status;
26 print $ph "MPD doesn't seem to be running\n";
29 if ($status->state eq 'stop') {
30 print $ph "MPD is stopped\n";
34 my $song = $mpd->current;
36 if ($title = $song->title) {
37 $title = $_ . ' - ' . $title for grep defined, $song->album, $song->artist;
41 $title = $1 if $title =~ m!/([^/]*)$!;
44 my $time = $status->time;
45 my $duration = sprintf '[%d:%02d/%d:%02d]',
46 $time->sofar_mins, $time->sofar_secs,
47 $time->total_mins, $time->total_secs;
48 command 'ACTION np: ' . $title . ' ' . $duration;
52 help_text => "$_, output which song is currently played by mpd"
55 $ph = Xchat::XPI->new(
58 desc => 'Music Player Daemon client',
59 author => 'Vincent Pit (VPIT)',
60 email => 'perl@profvince.com',
61 url => 'http://www.profvince.com',