I am somewhat new to Ruby and Tk, I have made a couple of simple
programs, but now I’m working on a Music Automation Program… like for
a Radio Station… something that will play song after song, infinitely.
Right now I need a means to delay the next song for the number of
seconds that the current song is playing. I’ve heard of a Tk::after
method, but I am having trouble understanding how it works.
Any help, links, or examples would be greatly appreciated…
Right now I need a means to delay the next song for the number of
seconds that the current song is playing.
I’m using the Snack audio toolkit for ruby, so I already know how long
the song is… I don’t need to constantly check if the song is
playing… I just need to have a block of code run after a set number of
seconds.
Right now I need a means to delay the next song for the number of
seconds that the current song is playing.
I’m using the Snack audio toolkit for ruby, so I already know how long
the song is… I don’t need to constantly check if the song is
playing… I just need to have a block of code run after a set number of
seconds.
I’m using the Snack audio toolkit for ruby, so I already know how long
the song is… I don’t need to constantly check if the song is
playing… I just need to have a block of code run after a set number of
seconds.
Snack toolkit can call a callback procedure at end of the sound.
Isn’t it enough for your purpose?
I don’t know Snack for Ruby (rbsnack) library.
Even if rbsnack doesn’t support such callback,
you can call the feature of Tcl/Tk from Ruby/Tk
(if your Tcl/Tk can load Snack, and your Ruby/Tk loads the Tcl/Tk’s
libs).
Right now I need a means to delay the next song for the number of
seconds that the current song is playing.
I’m using the Snack audio toolkit for ruby, so I already know how long
the song is… I don’t need to constantly check if the song is
playing… I just need to have a block of code run after a set number of
seconds.
In ffi-tk:
ruby -rffi-tk -e ‘Tk::After.ms(5000){ puts “hi” }; Tk.mainloop’
Thanks, this works… but I can’t get it to loop! I’m going to try using
this with a TkTimer widget… but is there perchance a loop option in
this widget as well? Something like TkTimer’s loop?
i.e. ‘TkTimer.start(5000, -1){puts “hi”}’
Thanks, this works… but I can’t get it to loop! I’m going to try using
this with a TkTimer widget… but is there perchance a loop option in
this widget as well? Something like TkTimer’s loop?
i.e. ‘TkTimer.start(5000, -1){puts “hi”}’
interval argument of TkTimer can accept a proc object.
The proc is called when decide the interval time for the next call.
So, the proc must return a milisecond value of integer.
playing… I just need to have a block of code run after a set number of
this widget as well? Something like TkTimer’s loop?
i.e. ‘TkTimer.start(5000, -1){puts “hi”}’
playing… I just need to have a block of code run after a set number of
this widget as well? Something like TkTimer’s loop?
i.e. ‘TkTimer.start(5000, -1){puts “hi”}’