712 lines
18 KiB
C
712 lines
18 KiB
C
#include "private.h"
|
|
#include "utils.h"
|
|
#include "theme.h"
|
|
#include "config.h"
|
|
#include "media.h"
|
|
#include <Ethumb_Client.h>
|
|
#include <Emotion.h>
|
|
|
|
typedef struct _Media Media;
|
|
struct _Media
|
|
{
|
|
Evas_Object_Smart_Clipped_Data __clipped_data;
|
|
Evas_Object *o_clip;
|
|
Evas_Object *o_img;
|
|
Evas_Object *o_ctrl;
|
|
Evas_Object *o_busy;
|
|
Evas_Object *o_event;
|
|
|
|
Ecore_Con_Url *url;
|
|
Ecore_Event_Handler *_prog_hdlr, *_compl_hdlr;
|
|
|
|
const char *src, *ext, *realf;
|
|
|
|
double down_perc;
|
|
|
|
int tmpfd;
|
|
int w, h, iw, ih, sw, sh;
|
|
int mode, resizes;
|
|
|
|
Media_Type type;
|
|
|
|
struct
|
|
{
|
|
Evas_Coord x, y;
|
|
Eina_Bool down : 1;
|
|
} down;
|
|
|
|
Eina_Bool downloading : 1;
|
|
Eina_Bool queued : 1;
|
|
};
|
|
|
|
static Evas_Smart *_smart = NULL;
|
|
static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
|
|
|
|
static void _smart_calculate(Evas_Object *obj);
|
|
|
|
static void
|
|
_media_cb_img_preloaded(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(data))) return;
|
|
evas_object_show(sd->o_img);
|
|
evas_object_show(sd->o_clip);
|
|
}
|
|
|
|
static void
|
|
_img_type_init(Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
|
|
sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
|
|
evas_object_smart_member_add(sd->o_img, obj);
|
|
evas_object_clip_set(sd->o_img, sd->o_clip);
|
|
evas_object_raise(sd->o_event);
|
|
evas_object_event_callback_add(sd->o_img, EVAS_CALLBACK_IMAGE_PRELOADED,
|
|
_media_cb_img_preloaded, obj);
|
|
evas_object_image_load_orientation_set(sd->o_img, EINA_TRUE);
|
|
evas_object_image_file_set(sd->o_img, sd->realf, NULL);
|
|
evas_object_image_size_get(sd->o_img, &sd->iw, &sd->ih);
|
|
evas_object_image_preload(sd->o_img, EINA_FALSE);
|
|
/* TODO: anim handle */
|
|
}
|
|
|
|
static void
|
|
_img_type_calc(Media *sd, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
{
|
|
if (!sd) return;
|
|
if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0))
|
|
{
|
|
w = 1;
|
|
h = 1;
|
|
}
|
|
else
|
|
{
|
|
int iw = 1, ih = 1;
|
|
|
|
if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_BG)
|
|
{
|
|
iw = w;
|
|
ih = (sd->ih * w) / sd->iw;
|
|
if (ih < h)
|
|
{
|
|
ih = h;
|
|
iw = (sd->iw * h) / sd->ih;
|
|
if (iw < w) iw = w;
|
|
}
|
|
}
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_POP)
|
|
{
|
|
iw = w;
|
|
ih = (sd->ih * w) / sd->iw;
|
|
if (ih > h)
|
|
{
|
|
ih = h;
|
|
iw = (sd->iw * h) / sd->ih;
|
|
if (iw > w) iw = w;
|
|
}
|
|
if ((iw > sd->iw) || (ih > sd->ih))
|
|
{
|
|
iw = sd->iw;
|
|
ih = sd->ih;
|
|
}
|
|
}
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_STRETCH)
|
|
{
|
|
iw = w;
|
|
ih = h;
|
|
}
|
|
x += ((w - iw) / 2);
|
|
y += ((h - ih) / 2);
|
|
w = iw;
|
|
h = ih;
|
|
}
|
|
|
|
evas_object_move(sd->o_img, x, y);
|
|
evas_object_resize(sd->o_img, w, h);
|
|
}
|
|
|
|
static void
|
|
_media_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
|
{
|
|
Media *sd;
|
|
Evas_Event_Mouse_Down *ev;
|
|
|
|
ev = event;
|
|
if (!(sd = evas_object_smart_data_get(data))) return;
|
|
if (sd->down.down) return;
|
|
if (ev->button != 1) return;
|
|
sd->down.x = ev->canvas.x;
|
|
sd->down.y = ev->canvas.y;
|
|
sd->down.down = EINA_TRUE;
|
|
}
|
|
|
|
static void
|
|
_media_cb_mouse_up(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
|
{
|
|
Media *sd;
|
|
Evas_Coord dx, dy;
|
|
Evas_Event_Mouse_Up *ev;
|
|
|
|
ev = event;
|
|
if (!(sd = evas_object_smart_data_get(data))) return;
|
|
if (!sd->down.down) return;
|
|
sd->down.down = EINA_FALSE;
|
|
dx = abs(ev->canvas.x - sd->down.x);
|
|
dy = abs(ev->canvas.y - sd->down.y);
|
|
if ((dx <= elm_config_finger_size_get()) &&
|
|
(dy <= elm_config_finger_size_get()))
|
|
evas_object_smart_callback_call(data, "clicked", NULL);
|
|
}
|
|
|
|
static Eina_Bool
|
|
_media_cb_prog(void *data, int type EINA_UNUSED, void *event)
|
|
{
|
|
Media *sd;
|
|
Evas_Object *obj;
|
|
Ecore_Con_Event_Url_Progress *ev;
|
|
|
|
if (!(obj = data)) return EINA_TRUE;
|
|
if (!(ev = event)) return EINA_TRUE;
|
|
if (!(sd = evas_object_smart_data_get(obj))) return EINA_TRUE;
|
|
if (ev->url_con != sd->url) return EINA_TRUE;
|
|
|
|
if (ev->down.total > 0.0)
|
|
{
|
|
double perc;
|
|
|
|
if (!sd->downloading)
|
|
edje_object_signal_emit(sd->o_busy, "downloading", PACKAGE_NAME);
|
|
sd->downloading = EINA_TRUE;
|
|
perc = (ev->down.now / ev->down.total);
|
|
if (perc != sd->down_perc)
|
|
{
|
|
Edje_Message_Float msg;
|
|
|
|
sd->down_perc = perc;
|
|
msg.val = perc;
|
|
edje_object_message_send(sd->o_busy, EDJE_MESSAGE_FLOAT, 1, &msg);
|
|
}
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
}
|
|
|
|
static Eina_Bool
|
|
_media_cb_compl(void *data, int type EINA_UNUSED, void *event)
|
|
{
|
|
Media *sd;
|
|
Evas_Object *obj;
|
|
Ecore_Con_Event_Url_Complete *ev;
|
|
|
|
if (!(obj = data)) return EINA_TRUE;
|
|
if (!(ev = event)) return EINA_TRUE;
|
|
if (!(sd = evas_object_smart_data_get(obj))) return EINA_TRUE;
|
|
if (ev->url_con != sd->url) return EINA_TRUE;
|
|
|
|
edje_object_signal_emit(sd->o_busy, "done", PACKAGE_NAME);
|
|
ecore_event_handler_del(sd->_prog_hdlr);
|
|
ecore_event_handler_del(sd->_compl_hdlr);
|
|
ecore_con_url_free(sd->url);
|
|
sd->_prog_hdlr = NULL;
|
|
sd->_compl_hdlr = NULL;
|
|
sd->url = NULL;
|
|
|
|
switch (sd->type)
|
|
{
|
|
case MEDIA_TYPE_IMG:
|
|
_img_type_init(obj);
|
|
break;
|
|
/* case MEDIA_TYPE_SCALE: */
|
|
/* _scale_type_init(obj); */
|
|
/* break; */
|
|
/* case MEDIA_TYPE_EDJE: */
|
|
/* _edje_type_init(obj); */
|
|
/* break; */
|
|
/* case MEDIA_TYPE_MOV: */
|
|
/* _mov_type_init(obj); */
|
|
/* break; */
|
|
default:
|
|
break;
|
|
}
|
|
|
|
evas_object_raise(sd->o_busy);
|
|
evas_object_raise(sd->o_event);
|
|
|
|
_smart_calculate(obj);
|
|
|
|
return EINA_FALSE;
|
|
}
|
|
|
|
static void
|
|
_smart_add(Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = calloc(1, sizeof(Media)))) return;
|
|
evas_object_smart_data_set(obj, sd);
|
|
|
|
_parent_sc.add(obj);
|
|
|
|
sd->o_clip = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
evas_object_color_set(sd->o_clip, 255, 255, 255, 255);
|
|
evas_object_smart_member_add(sd->o_clip, obj);
|
|
}
|
|
|
|
static void
|
|
_smart_del(Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
if (((sd->mode & MEDIA_OPTIONS_MASK) & MEDIA_SAVE) &&
|
|
(sd->type == MEDIA_TYPE_MOV) && (sd->o_img))
|
|
emotion_object_last_position_save(sd->o_img);
|
|
if (sd->url)
|
|
{
|
|
ecore_event_handler_del(sd->_prog_hdlr);
|
|
ecore_event_handler_del(sd->_compl_hdlr);
|
|
ecore_con_url_free(sd->url);
|
|
}
|
|
|
|
sd->_prog_hdlr = NULL;
|
|
sd->_compl_hdlr = NULL;
|
|
sd->url = NULL;
|
|
|
|
if (sd->tmpfd >= 0)
|
|
{
|
|
if (sd->realf) unlink(sd->realf);
|
|
close(sd->tmpfd);
|
|
}
|
|
|
|
if (sd->src) eina_stringshare_del(sd->src);
|
|
if (sd->realf) eina_stringshare_del(sd->realf);
|
|
|
|
if (sd->o_clip) evas_object_del(sd->o_clip);
|
|
if (sd->o_img) evas_object_del(sd->o_img);
|
|
if (sd->o_ctrl) evas_object_del(sd->o_ctrl);
|
|
if (sd->o_busy) evas_object_del(sd->o_busy);
|
|
if (sd->o_event) evas_object_del(sd->o_event);
|
|
|
|
_parent_sc.del(obj);
|
|
}
|
|
|
|
static void
|
|
_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
{
|
|
Media *sd;
|
|
Evas_Coord ow, oh;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
|
|
if ((ow == w) && (oh == h)) return;
|
|
evas_object_smart_changed(obj);
|
|
evas_object_resize(sd->o_clip, ow, oh);
|
|
}
|
|
|
|
static void
|
|
_smart_calculate(Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
|
if ((ow != sd->w) || (oh != sd->h)) sd->resizes++;
|
|
else sd->resizes = 0;
|
|
|
|
sd->w = ow;
|
|
sd->h = oh;
|
|
switch (sd->type)
|
|
{
|
|
case MEDIA_TYPE_IMG:
|
|
_img_type_calc(sd, ox, oy, ow, oh);
|
|
break;
|
|
/* case MEDIA_TYPE_SCALE: */
|
|
/* _scale_type_calc(sd, ox, oy, ow, oh); */
|
|
/* break; */
|
|
/* case MEDIA_TYPE_EDJE: */
|
|
/* _edje_type_calc(sd, ox, oy, ow, oh); */
|
|
/* break; */
|
|
/* case MEDIA_TYPE_MOV: */
|
|
/* _mov_type_calc(sd, ox, oy, ow, oh); */
|
|
/* break; */
|
|
/* case MEDIA_TYPE_THUMB: */
|
|
/* _thumb_type_calc(sd, ox, oy, ow, oh); */
|
|
/* break; */
|
|
case MEDIA_TYPE_UNKNOWN:
|
|
return;
|
|
default:
|
|
break;
|
|
}
|
|
evas_object_move(sd->o_clip, ox, oy);
|
|
evas_object_resize(sd->o_clip, ow, oh);
|
|
if (sd->o_busy)
|
|
{
|
|
evas_object_move(sd->o_busy, ox, oy);
|
|
evas_object_resize(sd->o_busy, ow, oh);
|
|
}
|
|
if (sd->o_event)
|
|
{
|
|
evas_object_move(sd->o_event, ox, oy);
|
|
evas_object_resize(sd->o_event, ow, oh);
|
|
}
|
|
}
|
|
|
|
static void
|
|
_smart_move(Evas_Object *obj, Evas_Coord x EINA_UNUSED, Evas_Coord y EINA_UNUSED)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
evas_object_smart_changed(obj);
|
|
}
|
|
|
|
static void
|
|
_smart_init(void)
|
|
{
|
|
static Evas_Smart_Class sc;
|
|
|
|
evas_object_smart_clipped_smart_set(&_parent_sc);
|
|
|
|
sc = _parent_sc;
|
|
sc.name = "media";
|
|
sc.version = EVAS_SMART_CLASS_VERSION;
|
|
sc.add = _smart_add;
|
|
sc.del = _smart_del;
|
|
sc.resize = _smart_resize;
|
|
sc.move = _smart_move;
|
|
sc.calculate = _smart_calculate;
|
|
|
|
_smart = evas_smart_class_new(&sc);
|
|
}
|
|
|
|
Evas_Object *
|
|
_media_add(Evas_Object *parent, const char *src, int mode, Media_Type type)
|
|
{
|
|
Evas *evas;
|
|
Evas_Object *obj = NULL;
|
|
Media *sd = NULL;
|
|
|
|
if (!parent) return NULL;
|
|
|
|
if (!(evas = evas_object_evas_get(parent))) return NULL;
|
|
|
|
if (!_smart) _smart_init();
|
|
|
|
obj = evas_object_smart_add(evas, _smart);
|
|
if (!(sd = evas_object_smart_data_get(obj))) return obj;
|
|
|
|
sd->src = eina_stringshare_add(src);
|
|
sd->mode = mode;
|
|
sd->type = type;
|
|
sd->tmpfd = -1;
|
|
|
|
#if HAVE_MKSTEMPS
|
|
if (_util_link_is_url(sd->src) && (type != MEDIA_TYPE_MOV))
|
|
{
|
|
const char *ext = NULL;
|
|
char *buff;
|
|
|
|
if (!strncasecmp(sd->src, "www.", 4))
|
|
{
|
|
buff = alloca(strlen(sd->src) + 10);
|
|
strcpy(buff, "http://");
|
|
strcat(buff, sd->src);
|
|
}
|
|
else if (!strncasecmp(sd->src, "ftp.", 4))
|
|
{
|
|
buff = alloca(strlen(sd->src) + 10);
|
|
strcpy(buff, "ftp://");
|
|
strcat(buff, sd->src);
|
|
}
|
|
else
|
|
buff = (char *)sd->src;
|
|
|
|
if ((ext = _util_file_extension_get(src, extn_img)))
|
|
sd->ext = ext;
|
|
else if ((ext = _util_file_extension_get(src, extn_scale)))
|
|
sd->ext = ext;
|
|
else if ((ext = _util_file_extension_get(src, extn_edj)))
|
|
sd->ext = ext;
|
|
else if ((ext = _util_file_extension_get(src, extn_mov)))
|
|
sd->ext = ext;
|
|
else
|
|
{
|
|
switch (type)
|
|
{
|
|
case MEDIA_TYPE_IMG:
|
|
sd->ext = ".png";
|
|
break;
|
|
case MEDIA_TYPE_SCALE:
|
|
sd->ext = ".svg";
|
|
break;
|
|
case MEDIA_TYPE_EDJE:
|
|
sd->ext = ".edj";
|
|
break;
|
|
case MEDIA_TYPE_MOV:
|
|
case MEDIA_TYPE_THUMB:
|
|
case MEDIA_TYPE_UNKNOWN:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (sd->ext)
|
|
{
|
|
Eina_Tmpstr *path;
|
|
char tmp[PATH_MAX];
|
|
|
|
snprintf(tmp, sizeof(tmp), "express-media-XXXXXX%s", sd->ext);
|
|
sd->tmpfd = eina_file_mkstemp(tmp, &path);
|
|
if (sd->tmpfd >= 0)
|
|
{
|
|
if (!(sd->url = ecore_con_url_new(buff)))
|
|
{
|
|
unlink(tmp);
|
|
close(sd->tmpfd);
|
|
}
|
|
else
|
|
{
|
|
ecore_con_url_fd_set(sd->url, sd->tmpfd);
|
|
if (!ecore_con_url_get(sd->url))
|
|
{
|
|
unlink(tmp);
|
|
close(sd->tmpfd);
|
|
}
|
|
else
|
|
{
|
|
sd->o_busy = edje_object_add(evas_object_evas_get(obj));
|
|
evas_object_smart_member_add(sd->o_busy, obj);
|
|
_theme_apply(sd->o_busy, "express/mediabusy");
|
|
evas_object_show(sd->o_busy);
|
|
edje_object_signal_emit(sd->o_busy, "busy",
|
|
PACKAGE_NAME);
|
|
|
|
sd->realf = eina_stringshare_add(path);
|
|
sd->_prog_hdlr =
|
|
ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS,
|
|
_media_cb_prog, obj);
|
|
sd->_compl_hdlr =
|
|
ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE,
|
|
_media_cb_compl, obj);
|
|
|
|
}
|
|
}
|
|
|
|
eina_tmpstr_del(path);
|
|
}
|
|
else
|
|
ERR("Eina Mkstemp Failed For File: %s", tmp);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 13)
|
|
if (!sd->url)
|
|
{
|
|
Efreet_Uri *uri;
|
|
const char *file;
|
|
|
|
file = eina_stringshare_printf("file://%s", sd->src);
|
|
uri = efreet_uri_decode(file);
|
|
eina_stringshare_del(file);
|
|
if (!uri) goto err;
|
|
sd->realf = uri->path;
|
|
eina_stringshare_ref(sd->realf);
|
|
efreet_uri_free(uri);
|
|
}
|
|
#else
|
|
if (!sd->url) sd->realf = eina_stringshare_add(sd->src);
|
|
#endif
|
|
|
|
if ((mode & MEDIA_SIZE_MASK) == MEDIA_THUMB)
|
|
{
|
|
/* TODO: type thumb init */
|
|
}
|
|
else
|
|
{
|
|
switch (type)
|
|
{
|
|
case MEDIA_TYPE_IMG:
|
|
if (!sd->url) _img_type_init(obj);
|
|
break;
|
|
/* case MEDIA_TYPE_SCALE: */
|
|
/* break; */
|
|
/* case MEDIA_TYPE_EDJE: */
|
|
/* break; */
|
|
/* case MEDIA_TYPE_MOV: */
|
|
/* break; */
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
sd->o_event = evas_object_rectangle_add(evas);
|
|
evas_object_color_set(sd->o_event, 0, 0, 0, 0);
|
|
evas_object_repeat_events_set(sd->o_event, EINA_TRUE);
|
|
evas_object_smart_member_add(sd->o_event, obj);
|
|
evas_object_clip_set(sd->o_event, sd->o_clip);
|
|
evas_object_show(sd->o_event);
|
|
|
|
evas_object_event_callback_add(sd->o_event, EVAS_CALLBACK_MOUSE_DOWN,
|
|
_media_cb_mouse_down, obj);
|
|
evas_object_event_callback_add(sd->o_event, EVAS_CALLBACK_MOUSE_UP,
|
|
_media_cb_mouse_up, obj);
|
|
|
|
return obj;
|
|
|
|
#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 13)
|
|
err:
|
|
if (obj) evas_object_del(obj);
|
|
return NULL;
|
|
#endif
|
|
}
|
|
|
|
void
|
|
_media_mute_set(Evas_Object *obj, Eina_Bool mute)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
if (sd->type != MEDIA_TYPE_MOV) return;
|
|
emotion_object_audio_mute_set(sd->o_img, mute);
|
|
if (mute)
|
|
edje_object_signal_emit(sd->o_ctrl, "mute,set", PACKAGE_NAME);
|
|
else
|
|
edje_object_signal_emit(sd->o_ctrl, "mute,unset", PACKAGE_NAME);
|
|
}
|
|
|
|
void
|
|
_media_play_set(Evas_Object *obj, Eina_Bool play)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
if (sd->type != MEDIA_TYPE_MOV) return;
|
|
emotion_object_play_set(sd->o_img, play);
|
|
if (play)
|
|
{
|
|
evas_object_smart_callback_call(obj, "play", NULL);
|
|
edje_object_signal_emit(sd->o_ctrl, "play,set", PACKAGE_NAME);
|
|
}
|
|
else
|
|
{
|
|
evas_object_smart_callback_call(obj, "pause", NULL);
|
|
edje_object_signal_emit(sd->o_ctrl, "pause,set", PACKAGE_NAME);
|
|
}
|
|
}
|
|
|
|
Eina_Bool
|
|
_media_play_get(Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE;
|
|
if (sd->type != MEDIA_TYPE_MOV) return EINA_FALSE;
|
|
return emotion_object_play_get(sd->o_img);
|
|
}
|
|
|
|
void
|
|
_media_position_set(Evas_Object *obj, double pos)
|
|
{
|
|
Media *sd;
|
|
double len = 0.0;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
if (sd->type != MEDIA_TYPE_MOV) return;
|
|
len = emotion_object_play_length_get(sd->o_img);
|
|
emotion_object_position_set(sd->o_img, len * pos);
|
|
}
|
|
|
|
void
|
|
_media_volume_set(Evas_Object *obj, double vol)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
if (sd->type != MEDIA_TYPE_MOV) return;
|
|
emotion_object_audio_volume_set(sd->o_img, vol);
|
|
edje_object_part_drag_value_set(sd->o_ctrl, "express.voldrag", vol, vol);
|
|
}
|
|
|
|
void
|
|
_media_visualize_set(Evas_Object *obj, Eina_Bool visualize)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
if (sd->type != MEDIA_TYPE_MOV) return;
|
|
if (visualize)
|
|
{
|
|
if (emotion_object_vis_supported(sd->o_img,
|
|
EMOTION_VIS_LIBVISUAL_INFINITE))
|
|
emotion_object_vis_set(sd->o_img, EMOTION_VIS_LIBVISUAL_INFINITE);
|
|
}
|
|
else
|
|
emotion_object_vis_set(sd->o_img, EMOTION_VIS_NONE);
|
|
}
|
|
|
|
void
|
|
_media_stop(Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
if (sd->type != MEDIA_TYPE_MOV) return;
|
|
evas_object_smart_callback_call(obj, "stop", NULL);
|
|
evas_object_del(obj);
|
|
}
|
|
|
|
const char *
|
|
_media_get(const Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return NULL;
|
|
return sd->realf;
|
|
}
|
|
|
|
Media_Type
|
|
_media_src_type_get(const char *src)
|
|
{
|
|
Media_Type type = MEDIA_TYPE_UNKNOWN;
|
|
|
|
if (_util_file_extension_get(src, extn_img))
|
|
type = MEDIA_TYPE_IMG;
|
|
else if (_util_file_extension_get(src, extn_scale))
|
|
type = MEDIA_TYPE_SCALE;
|
|
else if (_util_file_extension_get(src, extn_edj))
|
|
type = MEDIA_TYPE_EDJE;
|
|
else if (_util_file_extension_get(src, extn_mov))
|
|
type = MEDIA_TYPE_MOV;
|
|
return type;
|
|
}
|
|
|
|
Evas_Object *
|
|
_media_control_get(Evas_Object *obj)
|
|
{
|
|
Media *sd;
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return NULL;
|
|
return sd->o_ctrl;
|
|
}
|
|
|
|
void
|
|
_media_unknown_handle(const char *handler, const char *src)
|
|
{
|
|
const char *cmd;
|
|
char buff[PATH_MAX];
|
|
char *esc;
|
|
|
|
cmd = "xdg-open";
|
|
if (!(esc = ecore_file_escape_name(src))) return;
|
|
if ((handler) && (*handler)) cmd = handler;
|
|
snprintf(buff, sizeof(buff), "%s %s", cmd, esc);
|
|
free(esc);
|
|
ecore_exe_run(buff, NULL);
|
|
}
|