static void ui_playback_ready (void) { title_change_cb (); set_slider_length (aud_drct_get_length ()); time_counter_cb (); /* update time counter 4 times a second */ if (! update_song_timeout_source) update_song_timeout_source = g_timeout_add (250, (GSourceFunc) time_counter_cb, NULL); gtk_widget_show (label_time); }
static gboolean ui_slider_change_value_cb (GtkRange * range, GtkScrollType scroll, gdouble value) { gint length = aud_drct_get_length (); gint time = CLAMP ((gint) value, 0, length); set_time_label (time, length); if (slider_is_moving) slider_seek_time = time; else if (time != slider_seek_time) // avoid seeking twice do_seek (time); return FALSE; }
static gboolean time_counter_cb (void) { if (slider_is_moving) return TRUE; slider_seek_time = -1; // delayed reset to avoid seeking twice gint time = aud_drct_get_time (); gint length = aud_drct_get_length (); if (length > 0) set_slider (time); set_time_label (time, length); return TRUE; }
static void do_seek (gint time) { gint length = aud_drct_get_length (); time = CLAMP (time, 0, length); set_slider (time); set_time_label (time, length); aud_drct_seek (time); // Trick: Unschedule and then schedule the update function. This gives the // player 1/4 second to perform the seek before we update the display again, // in an attempt to reduce flickering. if (update_song_timeout_source) { g_source_remove (update_song_timeout_source); update_song_timeout_source = g_timeout_add (250, (GSourceFunc) time_counter_cb, NULL); } }
void ui_main_evlistener_playback_begin (void * hook_data, void * user_data) { mainwin_disable_seekbar(); mainwin_update_song_info(); gtk_widget_show (mainwin_stime_min); gtk_widget_show (mainwin_stime_sec); gtk_widget_show (mainwin_minus_num); gtk_widget_show (mainwin_10min_num); gtk_widget_show (mainwin_min_num); gtk_widget_show (mainwin_10sec_num); gtk_widget_show (mainwin_sec_num); if (aud_drct_get_ready () && aud_drct_get_length () > 0) { gtk_widget_show (mainwin_position); gtk_widget_show (mainwin_sposition); } ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); title_change (); info_change (); }