From Music Player Daemon Community Wiki
- Description: MPD integration with Midnight Commander
* Enter - play current file
* F4 - enqueue current file
* F2 \ - play current (or all selected) file or dir
* F2 | - enqueue current (or all selected) file or dir
#!/usr/bin/perl
# dplay 0.1b
# copyright (c) 2004 - Miroslav Rudisin <miero@matfyz.cz>
unless (defined($ARGV[0])) {
print "dplay - [MP]Daemon play - command line playlist filler\nUsage: dplay [-e] [-d DIR_PREFIX] files\n";
exit;
}
use IO::Socket;
my $music_directory = "/pub";
my $remote = IO::Socket::INET->new(
PeerAddr => "localhost",
PeerPort => "6600",
Proto => "tcp",
);
unless ($remote) { die "cannot connect to mpd daemon" }
$remote->autoflush(1);
while ( <$remote> !~ /^OK|ACK/ ) { print }
my $last = -1;
if ($ARGV[0] ne '-e') {
print $remote "status\n";
while ( (my $line = <$remote>) !~ /^OK|ACK/ ) {
$last = $1 if $line =~ /^playlistlength: (\d+)/;
}
}
else {
shift @ARGV;
}
my $dir;
if ($ARGV[0] eq '-d') {
shift @ARGV;
$dir = shift @ARGV;
}
print $remote "command_list_begin\n";
while (my $s = shift @ARGV) {
$s = "$dir/$s" if $dir;
$s .= '/' if -d $s;
if ($s =~ m!^$music_directory/(.*)!) {
$s = $1;
$s =~ s/\"/\\\"/g;
print $remote "add \"$s\"\n";
}
}
print $remote "command_list_end\n";
while ( <$remote> !~ /^OK|ACK/ ) { print }
if ($last != -1) {
print $remote "play $last\n";
while ( <$remote> !~ /^OK|ACK/ ) { print }
}
print $remote "close\n";
close $remote;
regex/\.([Mm][Pp]3)$
View=%view{ascii} id3v2 --list %f
Open=dplay %d/%f &
Edit=dplay -e %d/%f &
regex/\.([Oo][Gg][Gg])$
View=%view{ascii} ogginfo %s
Open=dplay %d/%f &
Edit=dplay -e %d/%f &
+ ! t t
| Enqueue
dplay -e %d/%p &
+ ! t t
\ Play
dplay %d/%p &
+ t t
| Enqueue
dplay -e -d %d %u &
+ t t
\ Play
dplay -d %d %u &