#!/usr/bin/perl -w # use IO::File; use IO::Socket::INET; use Getopt::Long; my $type = 'audio/mpegurl'; my $host = 'localhost'; my $port = 5895; my $replace = 0; sub usage { die "$0 [ -r ] [ -m host ] [ -p port ] playlist.m3u" } GetOptions('h' => \&usage, 'p' => \$port, 'replace|r!' => \$replace, 'm=s' => \$host); my $pl_content; if (@ARGV) { my $f = new IO::File($ARGV[0]) || die "$ARGV[0]: $!"; $pl_content = join('', <$f>); } else { $pl_content = join('', ); } my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'udp', Type => SOCK_DGRAM) || die "socket: $!"; print $sock "playlist-delete\n" if $replace; print $sock "enqueue-inline $type ",length($pl_content),"\n", $pl_content; print $sock "play\n"; close $sock;