3
#ifndef EFL_BETA_API_SUPPORT
4
# define EFL_BETA_API_SUPPORT
17
static Eina_List *filenames = NULL;
18
static Eina_List *curfile = NULL;
21
_playback_started_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
23
printf("Emotion object started playback.\n");
27
_create_emotion_object(Evas *e)
29
Evas_Object *em = emotion_object_add(e);
31
emotion_object_init(em, "gstreamer1");
33
efl_event_callback_add(em, EFL_CANVAS_VIDEO_EVENT_PLAYBACK_START, _playback_started_cb, NULL);
39
_on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
41
Evas_Event_Key_Down *ev = event_info;
42
Evas_Object *em = data;
44
if (!strcmp(ev->key, "Return"))
46
emotion_object_play_set(em, EINA_TRUE);
48
else if (!strcmp(ev->key, "space"))
50
emotion_object_play_set(em, EINA_FALSE);
52
else if (!strcmp(ev->key, "Escape"))
54
ecore_main_loop_quit();
56
else if (!strcmp(ev->key, "n"))
62
curfile = eina_list_next(curfile);
63
file = eina_list_data_get(curfile);
64
fprintf(stderr, "playing next file: %s\n", file);
65
emotion_object_file_set(em, file);
67
else if (!strcmp(ev->key, "p"))
71
curfile = eina_list_last(filenames);
73
curfile = eina_list_prev(curfile);
74
file = eina_list_data_get(curfile);
75
fprintf(stderr, "playing next file: %s\n", file);
76
emotion_object_file_set(em, file);
78
else if (!strcmp(ev->key, "b"))
80
emotion_object_border_set(em, 0, 0, 50, 50);
82
else if (!strcmp(ev->key, "0"))
84
emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_NONE);
86
else if (!strcmp(ev->key, "w"))
88
emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_WIDTH);
90
else if (!strcmp(ev->key, "h"))
92
emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_HEIGHT);
94
else if (!strcmp(ev->key, "2"))
96
emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_BOTH);
98
else if (!strcmp(ev->key, "c"))
100
emotion_object_keep_aspect_set(em, EMOTION_ASPECT_CROP);
104
fprintf(stderr, "unhandled key: %s\n", ev->key);
109
_frame_decode_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
115
_length_change_cb(void *data EINA_UNUSED, const Efl_Event *ev)
117
fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(ev->object));
121
_position_update_cb(void *data EINA_UNUSED, const Efl_Event *ev)
123
fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(ev->object));
127
_progress_change_cb(void *data EINA_UNUSED, const Efl_Event *ev)
129
fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n",
130
emotion_object_progress_status_get(ev->object),
131
emotion_object_progress_info_get(ev->object));
135
_frame_resize_cb(void *data EINA_UNUSED, const Efl_Event *ev)
138
emotion_object_size_get(ev->object, &w, &h);
139
fprintf(stderr, "smartcb: frame_resize: %dx%d\n", w, h);
143
_canvas_resize_cb(Ecore_Evas *ee)
146
Evas_Object *bg, *em;
148
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
150
bg = ecore_evas_data_get(ee, "bg");
151
em = ecore_evas_data_get(ee, "emotion");
153
evas_object_resize(bg, w, h);
154
evas_object_move(em, 10, 10);
155
evas_object_resize(em, w - 20, h - 20);
158
EFL_CALLBACKS_ARRAY_DEFINE(emotion_object_example_callbacks,
159
{ EFL_CANVAS_VIDEO_EVENT_FRAME_DECODE, _frame_decode_cb },
160
{ EFL_CANVAS_VIDEO_EVENT_LENGTH_CHANGE, _length_change_cb },
161
{ EFL_CANVAS_VIDEO_EVENT_POSITION_CHANGE, _position_update_cb },
162
{ EFL_CANVAS_VIDEO_EVENT_PROGRESS_CHANGE, _progress_change_cb },
163
{ EFL_CANVAS_VIDEO_EVENT_FRAME_RESIZE, _frame_resize_cb });
166
main(int argc, const char *argv[])
170
Evas_Object *bg, *em;
175
printf("One argument is necessary. Usage:\n");
176
printf("\t%s <filename>\n", argv[0]);
180
for (i = 1; i < argc; i++)
181
filenames = eina_list_append(filenames, eina_stringshare_add(argv[i]));
185
if (!ecore_evas_init())
190
ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
194
ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
199
e = ecore_evas_get(ee);
202
bg = evas_object_rectangle_add(e);
203
evas_object_name_set(bg, "our dear rectangle");
204
evas_object_color_set(bg, 255, 0, 0, 255);
205
evas_object_move(bg, 0, 0);
206
evas_object_resize(bg, WIDTH, HEIGHT);
207
evas_object_show(bg);
209
ecore_evas_data_set(ee, "bg", bg);
212
em = _create_emotion_object(e);
213
emotion_object_file_set(em, eina_list_data_get(curfile));
214
evas_object_move(em, 10, 10);
215
evas_object_resize(em, WIDTH, HEIGHT);
216
evas_object_resize(em, WIDTH - 20, HEIGHT - 20);
217
emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_BOTH);
218
emotion_object_bg_color_set(em, 0, 128, 0, 255);
219
evas_object_show(em);
221
ecore_evas_data_set(ee, "emotion", em);
223
efl_event_callback_array_add(em, emotion_object_example_callbacks(), NULL);
225
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em);
226
evas_object_focus_set(bg, EINA_TRUE);
228
emotion_object_play_set(em, EINA_TRUE);
230
ecore_main_loop_begin();
233
ecore_evas_shutdown();
237
fprintf(stderr, "error: Requires at least one Evas engine built and linked"
238
" to ecore-evas for this example to run properly.\n");
240
EINA_LIST_FREE(filenames, curfile)
241
eina_stringshare_del(eina_list_data_get(curfile));
243
ecore_evas_shutdown();