Hi there.
I am currently working on a mp3 player using gtk2-perl for the GUI and Audio::Play::MPG123 module for mp3 playback. I know that this probably have been done a trillion times before, but this one fits my special needs.
Now I have run in to a problem which I can't really decide how to tackle:
In my GUI i have a progressbar/timeline (GtkHScale widget) which needs to be continuously updated with the position in the current playing song.
When you start your Gtk GUI you run the Gtk2->main() function.That function controls the flow of the program and only gives me a chance to run code when a GUI event occur (eg. button pressed runs some sub etc.)
This leads me to the question:
How would I go about having the timeline continuously updated when I don't control the flow of the program?
I have some ideas:
(These are just ideas, I don't know if they would work or not)
treads: have some kind of function that updates the timeline running in a separate thread.
timerObject: maybe there is some glib/gtk/perl object that can run a given function several times in a given interval.
Since I'm kind of stuck I appreciate any help I can get.