What I do is create the worker thread once during the startup of the script, and put the thread to sleep. Then when I want it to do something, I use threads:shared to turn it on and pass it a string to be used (a mp3 name).
If it is only mp3 files you want to play, you might be able to use a piped open to your mp3 player, and just feed it filenames on STDIN. I've done this in linux. (I realize you are on windows, but this just demonstrates the idea)
#!/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;
In reply to Re: Proc::Background (or runing something seperate)
by zentara
in thread Proc::Background (or runing something seperate)
by Ace128
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |