Fandom

Music Player Daemon Community Wiki

Hack:dplay

525pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

dplay Edit

  • Description: MPD integration with Midnight Commander
  • Author: miEro
  • Instructions:
* 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
  • Sources
    • ~/bin/dplay
#!/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);

print while <$remote> !~ /^OK|ACK/;

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;
}

my $dir;
if ($ARGV[0] eq '-d') {
        shift;
        $dir = shift;
}

print $remote "command_list_begin\n";
while (my $s = shift) {
        $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";
print while <$remote> !~ /^OK|ACK/;
if ($last != -1) {
        print $remote "play $last\n";
        print while <$remote> !~ /^OK|ACK/;
}
print $remote "close\n";

close $remote;
    • ~/.mc/bindings
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 &
    • ~/.mc/menu
+ ! 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 &

Also on Fandom

Random Wiki