Just is just a short snippet(s) to show people making "mp3 playlists", how you can play directly from a list with PAUSE commands. It demonstrates the "-R", (remote control) option of
mpg123.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
#read README.remote in mpg123 sources
$|++;
#my $pid = open(FH,"| mpg123 -R 2>&1 ");
my $pid = open(FH,"| mpg123 -R >/dev/null 2>&1 ");
print "$pid\n";
my $mw = new MainWindow;
my $startbut = $mw->Button(-text =>'Start Play',
-command => sub{
syswrite(FH, "LOAD 1bb.mp3\n") ;
})->pack;
my $pausebut = $mw->Button(-text =>'Pause',
-command => sub{
syswrite(FH, "PAUSE\n") ;
})->pack;
my $exitbut = $mw->Button(-text =>'Exit',
-command => sub{ exit })->pack;
MainLoop;
__END__
########################################################
#OR with IPC::OPen3
#######################################################
#!/usr/bin/perl
use warnings;
use strict;
use IPC::Open3;
use Tk;
#read README.remote in mpg123 sources
$|++;
my $pid = open3(\*WRITE,\*READ,0,"mpg123 -R 2>&1");
waitpid($pid, 1);
my $mw = new MainWindow;
my $t = $mw->Scrolled('Text',
-bg=>'black',-fg=>'yellow')->pack;
my $startbut = $mw->Button(-text =>'Start Play',
-command => sub{
print WRITE "LOAD 1bb.mp3\n";
})->pack;
my $pausebut = $mw->Button(-text =>'Pause',
-command => sub{
print WRITE "PAUSE\n";
})->pack;
my $exitbut = $mw->Button(-text =>'Exit',
-command => sub{ exit })->pack;
$mw->fileevent(\*READ, 'readable', [\&fill_text_widget,$t]);
MainLoop;
sub fill_text_widget {
my($widget) = @_;
my $text = <READ>;
$widget->delete('1.0','end');
$widget->insert('1.0',"$text");
$widget->yview('end');
}
__END__