Ejemplo n.º 1
0
static void
ol_osd_module_update_next_lyric (OlOsdModule *osd, OlLrcIter *iter)
{
  if (osd->line_count == 1)
  {
    osd->lrc_next_id = -1;
    return;
  }
  if (ol_lrc_iter_next (iter))
    _advance_to_nonempty_lyric (iter);
  gint id;
  const char *text = NULL;
  if (ol_lrc_iter_is_valid (iter))
  {
    id = ol_lrc_iter_get_id (iter);
    text = ol_lrc_iter_get_text (iter);
  }
  else
  {
    id = -1;
    text = "";
  }
  if (osd->lrc_next_id != id)
  {
    int next_line = 1 - osd->current_line;
    osd->lrc_next_id = id;
    ol_osd_window_set_lyric (osd->window, next_line, text);
    ol_osd_window_set_percentage (osd->window, next_line, 0.0);
  }
}
Ejemplo n.º 2
0
static void _seek_cb (OlScrollWindow *scroll,
                      guint id,
                      gdouble percentage,
                      gpointer userdata)
{
  OlScrollModule *module = userdata;
  if (module->lrc)
  {
    OlLrcIter *iter = ol_lrc_iter_from_id (module->lrc, id);
    if (!ol_lrc_iter_is_valid (iter))
    {
      ol_errorf ("Seek to an invalid ID: %u\n", id);
      ol_lrc_iter_free (iter);
      return;
    }
    gint64 iter_time = ol_lrc_iter_get_timestamp (iter);
    guint64 duration = ol_lrc_iter_get_duration (iter);
    ol_lrc_iter_free (iter);
    gint64 new_time = iter_time + duration * percentage;
    ol_player_seek (module->player, new_time);
    ol_scroll_window_set_progress (module->scroll,
                                   id,
                                   percentage);
    /* avoid players send played time before seeked. */
    g_usleep (200000);
  }
}
Ejemplo n.º 3
0
static gboolean
_advance_to_nonempty_lyric (OlLrcIter *iter)
{
  for (; ol_lrc_iter_is_valid (iter); ol_lrc_iter_next (iter))
  {
    if (!ol_is_string_empty (ol_lrc_iter_get_text (iter)))
      return TRUE;
  }
  return FALSE;
}