[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: implementing a CDPlayer fast forward button



On Thu, 24 Feb 2000 00:54:50 -0800, Jeff W. wrote:
> on a cdplayer, you hold down the fast forward button and it continuously
> advances by several seconds at a time.  So I tried putting code to do
> just that in a "on_btnFF_pressed" event.  But when I do that, it only
> advances once, not continuously.  How can I make it so that while I'm
> holding down on a button, the code within that function keeps being
> executed, until I let go of the button?  Thanks.

Connect to the "pressed" and "released" events (this is code from a MIDI
player I wrote):

  gtk_signal_connect(GTK_OBJECT(ffwdButton),
                     "pressed",
                     GTK_SIGNAL_FUNC(fastForwardPressedCallback),
                     0);

  gtk_signal_connect(GTK_OBJECT(ffwdButton), 
                     "released",
                     GTK_SIGNAL_FUNC(fastForwardReleasedCallback),
                     0);


  static void fastForwardPressedCallback(GtkWidget *widget, gpointer data)
  {
    /* tell CD player to do fast forward */
  }

  static void fastForwardReleasedCallback(GtkWidget *widget, gpointer data)
  {
    /* tell CD player to stop fast forward */
  }

Note that fastForwardPressedCallback() should return immediately, or you
won't be able to catch the "released" signal. If fast forward is a single
ioctl() to the CD player, just issue the ioctl and return. In
fastForwardReleasedCallback() you just use another ioctl to return to
normal play operation.

If you have to do fast forward manually, than don't do it in
fastForwardPressedCallback(), but use this function to start a timeout
function with gtk_timeout_add() that will do the dirty job. In
fastForwardReleasedCallback() you just stop the timeout function (or
change a variable that will tell the timeout function to stop).


Erik

-- 
unix soit qui mal y pense





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]