static void ol_osd_module_set_played_time (struct OlDisplayModule *module, guint64 played_time) { ol_assert (module != NULL); OlOsdModule *priv = ol_display_module_get_data (module); ol_assert (priv != NULL); if (priv->lrc != NULL && priv->window != NULL) { OlLrcIter *iter = ol_lrc_iter_from_timestamp (priv->lrc, played_time); if (_advance_to_nonempty_lyric (iter)) { gint id = ol_lrc_iter_get_id (iter); if (id != priv->lrc_id) { if (id == priv->lrc_next_id) { /* advance to the next line */ ol_osd_window_set_percentage (priv->window, priv->current_line, 1.0); priv->current_line = 1 - priv->current_line; priv->lrc_id = priv->lrc_next_id; priv->lrc_next_id = -1; ol_osd_window_set_current_line (priv->window, priv->current_line); } else { /* The user seeks the position or there is only 1 line in OSD window. Reset the lyrics. */ priv->lrc_id = id; priv->current_line = 0; ol_osd_window_set_current_line (priv->window, 0); ol_osd_window_set_lyric (priv->window, priv->current_line, ol_lrc_iter_get_text (iter)); ol_osd_module_update_next_lyric (priv, iter); } } gdouble percentage = ol_lrc_iter_compute_percentage (iter, played_time); ol_osd_window_set_current_percentage (priv->window, percentage); if (percentage > 0.5 && priv->lrc_next_id == -1) ol_osd_module_update_next_lyric (priv, iter); } else if (priv->lrc_id != -1) { clear_lyrics (priv); } ol_lrc_iter_free (iter); } }
static void ol_scroll_module_set_played_time (struct OlDisplayModule *module, guint64 played_time) { ol_assert (module != NULL); OlScrollModule *priv = ol_display_module_get_data (module); ol_assert (priv != NULL); if (priv->lrc != NULL && priv->scroll != NULL) { OlLrcIter *iter = ol_lrc_iter_from_timestamp (priv->lrc, played_time); ol_scroll_window_set_progress (priv->scroll, ol_lrc_iter_get_id (iter), ol_lrc_iter_compute_percentage (iter, played_time)); ol_lrc_iter_free (iter); } }