Audio-Play-MPG123
view release on metacpan or search on metacpan
do $RC;
# contains tuples of the form [url, repeat]
@playlist=();
$p_url;
$p_repeat;
$player = new Audio::Play::MPG123 mpg123args => ["-b4096"];
# do uri-style escaping PLUS escape space to · and back (sorry for that :()
sub uri_esc($) {
local $_ = shift;
s/([^\x21-\x24\x26-\x7e\xa0-\xb6\xb8-\xff])/sprintf "%c%02x", 0x25, ord($1)/ge;
s/%20/·/g;
$_;
}
sub uri_unesc($) {
local $_ = shift;
s/·/%20/g;
s/%([0-9a-f][0-9a-f])/chr(hex($1))/gei;
$_;
}
sub write_rc {
require Data::Dumper;
print "writing $RC... ";
open RC, ">$RC" or die "$RC: $!";
$p_repeat = $playlist[0][1];
}
if ($p_url) {
$p_repeat--;
load_url($p_url);
mp3log("+", $p_url);
$player->stat;
}
}
sub add_url($) {
my $url = shift;
push @playlist, [$url, 1];
next_song unless $player->state;
mp3log("a", $url);
}
sub shuffle {
for (my $i = @playlist; $i--; ) {
my $j = int rand $i+1;
@playlist[$j, $i] = @playlist[$i, $j];
( run in 0.669 second using v1.01-cache-2.11-cpan-65fba6d93b7 )