forrest has asked for the wisdom of the Perl Monks concerning the following question:
To play a single mp3 with Xmms::Remote, I create a one-file playlist and call the play method. Then -- here's the tricky part -- I have to find out when the song is over so I can play the next one.
The only way to detect this is the is_playing() method, which will return true as long as xmms is still playing. I have to put the next song on as soon as it returns false.
In the meantime, while the mp3 is playing, I have to handle all the usual Perl/Tk events, button-clicks and whatnot. Naively polling for the end of the song would lock up the app.
I'm new to Perl/Tk and event-based programming, but it seems this event I'm waiting for (is_playing returning false) is a lot like the events Perl/Tk's MainLoop is waiting on already.
Forgive me if I'm stupid and I missed some obvious documentation somewhere, but can anyone tell me how I can set up my own non-gui-related Perl/Tk event to handle this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: setting up non-gui callbacks in Perl/Tk
by pg (Canon) on Nov 09, 2003 at 07:26 UTC | |
by forrest (Beadle) on Nov 09, 2003 at 22:15 UTC | |
|
Re: setting up non-gui callbacks in Perl/Tk
by PodMaster (Abbot) on Nov 09, 2003 at 05:56 UTC |