fix cover image switching and previous track time setting

This commit is contained in:
zmike 2014-02-01 00:38:50 -05:00
parent 40284a5c8e
commit e6a4c911f8
1 changed files with 13 additions and 17 deletions

View File

@ -112,10 +112,8 @@ static Eina_Bool metadata_image_fetch(Empc_Fetch_Request_Internal *ireq, Evas_Ob
static inline unsigned char
bg_next_get(void)
{
char num = background_num;
if (num + 1 > 1)
num = 0;
return num;
char num = background_num + 1;
return num % 2;
}
static void
@ -178,6 +176,7 @@ controls_show(void)
static void
bg_changed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
{
elm_object_part_content_unset(layout, EMPC_BASE_SWALLOW_BACKGROUND);
elm_object_part_content_set(layout, EMPC_BASE_SWALLOW_BACKGROUND, bg[background_num]);
elm_object_signal_emit(layout, "empc,bg,done", "empc");
}
@ -269,6 +268,8 @@ songid_update(int songid)
empd_song_item = it = eina_hash_find(empd_current_queue, &songid);
/* don't allow set until item exists */
if (!it) return 0;
ret = songid - empd_songid;
empd_songid = songid;
if (itp)
{
elm_object_item_signal_emit(itp, "empc,state,not_playing", "empc");
@ -279,20 +280,19 @@ songid_update(int songid)
elm_object_item_signal_emit(it, "empc,state,playing", "empc");
elm_genlist_item_fields_update(it, EMPC_PLAYLIST_TEXT_TIME, ELM_GENLIST_ITEM_FIELD_TEXT);
so = elm_object_item_data_get(it);
ret = songid - empd_songid;
if (itp && ((so->album != sop->album) || (so->artist != sop->artist)))
if ((!itp) || (so->album != sop->album) || (so->artist != sop->artist))
{
if (songid >= empd_songid)
if (ret >= 0)
elm_object_signal_emit(layout, "empc,bg,next", "empc");
else
elm_object_signal_emit(layout, "empc,bg,prev", "empc");
background_num = bg_next_get();
if (itp)
background_num = bg_next_get();
}
if (songid >= empd_songid)
if (ret >= 0)
elm_object_signal_emit(layout, "empc,title,change,next", "empc");
else
elm_object_signal_emit(layout, "empc,title,change,prev", "empc");
empd_songid = songid;
return ret;
}
@ -398,7 +398,7 @@ static Eina_Bool
empc_current_song(void *d EINA_UNUSED, int t EINA_UNUSED, Empd_Empc_CurrentSong_Data *ev)
{
int sid;
Eina_Bool title, artist, album, palbum = !!empd_song_album;
Eina_Bool title, artist, album;
empd_song_track = ev->track;
sid = songid_update(ev->songid);
@ -408,19 +408,15 @@ empc_current_song(void *d EINA_UNUSED, int t EINA_UNUSED, Empd_Empc_CurrentSong_
/* yes, | is intentional. */
if (sid | title | artist)
title_update();
/* always fetch on first run */
if (!palbum)
metadata_image_fetch(NULL, bg[background_num], empd_song_artist, empd_song_album);
/* check for update fails */
else if (artist || album)
if (artist || album)
{
Evas_Object *o;
o = bg[bg_next_get()];
o = bg[background_num];
if ((empd_song_artist != evas_object_data_get(o, "artist")) ||
(empd_song_album != evas_object_data_get(o, "album")))
metadata_image_fetch(NULL, o, empd_song_artist, empd_song_album);
}
elm_object_part_text_set(layout, EMPC_BASE_TEXT_ARTIST, empd_song_artist);
elm_object_part_text_set(layout, EMPC_BASE_TEXT_ALBUM, empd_song_album);