add support for video thumbnails from meta data and album artwork for audio files.

Summary:
Generally these images are better quality than those
from the Interwebz and local so let's use em!

For now using emotion_object_meta_preview_get()
as Apple stores them in this tag.

emotion_object_meta_image_get() is also available
and I've heard also it is used similarly, but
am yet to find a file that does that.

Reviewers: raster

Differential Revision: https://phab.enlightenment.org/D4555

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
v-0.4.0
Al Poole 6 years ago committed by Cedric BAIL
parent d66c83a547
commit 2340469f42
  1. 8
      src/bin/video.c
  2. 2
      src/bin/video.h
  3. 67
      src/bin/win.c

@ -999,6 +999,14 @@ video_meta_year_get(Evas_Object *obj)
return emotion_object_meta_info_get(sd->o_vid, EMOTION_META_INFO_TRACK_YEAR);
}
Evas_Object *
video_meta_artwork_get(Evas_Object *obj, const char *path, int type)
{
Video *sd = evas_object_smart_data_get(obj);
if (!sd) return NULL;
return emotion_file_meta_artwork_get(sd->o_vid, path, type);
}
const char *
video_meta_genre_get(Evas_Object *obj)
{

@ -56,5 +56,5 @@ const char *video_meta_year_get(Evas_Object *obj);
const char *video_meta_genre_get(Evas_Object *obj);
const char *video_meta_comment_get(Evas_Object *obj);
void video_file_autosub_set(Evas_Object *obj, const char *file, const char *sub);
Evas_Object * video_meta_artwork_get(Evas_Object *obj, const char *path, int type);
#endif

@ -62,6 +62,7 @@ _cb_win_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
if (inf->mouse_idle_timeout) ecore_timer_del(inf->mouse_idle_timeout);
if (inf->albumart_timeout) ecore_timer_del(inf->albumart_timeout);
if (inf->down_timeout) ecore_timer_del(inf->down_timeout);
EINA_LIST_FREE(inf->file_list, vid)
{
if (vid->file) eina_stringshare_del(vid->file);
@ -214,6 +215,62 @@ _cb_fetched(void *data)
}
}
Eina_Bool
_local_artwork_get(void *data)
{
Evas_Object *win = data;
Inf *inf = evas_object_data_get(win, "inf");
if (!inf) return EINA_FALSE;
if (!inf->vid) return EINA_FALSE;
const char *file = NULL;
const char *filename = video_file_get(inf->vid);
Efreet_Uri *uri = efreet_uri_decode(filename);
if (uri)
{
file = ecore_file_realpath(uri->path);
efreet_uri_free(uri);
}
else
{
file = filename;
}
if ((!video_has_video_get(inf->vid)) && (video_has_audio_get(inf->vid)))
{
char *path = albumart_file_get(file);
if (path)
{
if (ecore_file_exists(path))
{
win_art(win, path);
free(path);
return EINA_TRUE;
}
Evas_Object *artwork = video_meta_artwork_get(inf->vid, file, EMOTION_ARTWORK_PREVIEW_IMAGE);
if (!artwork) artwork = video_meta_artwork_get(inf->vid, file, EMOTION_ARTWORK_IMAGE);
if (artwork)
{
evas_object_image_save(artwork, path, NULL, NULL);
evas_object_del(artwork);
free(path);
}
else
{
free(path);
return EINA_FALSE;
}
}
}
return EINA_TRUE;
}
static Eina_Bool
_cb_albumart_delay(void *data)
{
@ -230,7 +287,6 @@ _cb_albumart_delay(void *data)
const char *title = video_meta_title_get(inf->vid);
const char *artist = video_meta_artist_get(inf->vid);
const char *album = video_meta_album_get(inf->vid);
albumart_find(file, title, artist, album, NULL, _cb_fetched, win);
}
else albumart_find(NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@ -241,7 +297,6 @@ void
win_do_play(Evas_Object *win)
{
Inf *inf = evas_object_data_get(win, "inf");
video_play_set(inf->vid, EINA_TRUE);
elm_layout_signal_emit(inf->lay, "action,play", "rage");
}
@ -678,8 +733,12 @@ win_show(Evas_Object *win, int w, int h)
}
evas_object_show(win);
}
if (inf->albumart_timeout) ecore_timer_del(inf->albumart_timeout);
inf->albumart_timeout = ecore_timer_add(0.2, _cb_albumart_delay, win);
if (!_local_artwork_get(win))
{
if (inf->albumart_timeout) ecore_timer_del(inf->albumart_timeout);
inf->albumart_timeout = ecore_timer_add(0.2, _cb_albumart_delay, win);
}
if (!video_has_video_get(inf->vid))
elm_layout_signal_emit(inf->lay, "state,novideo", "rage");

Loading…
Cancel
Save