3
#ifndef EFL_BETA_API_SUPPORT
4
# define EFL_BETA_API_SUPPORT
18
static Eina_List *filenames = NULL;
19
static Eina_List *curfile = NULL;
22
_playback_started_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
24
printf("Emotion object started playback.\n");
28
_playback_stopped_cb(void *data EINA_UNUSED, const Efl_Event *ev)
30
printf("Emotion playback stopped.\n");
31
emotion_object_play_set(ev->object, EINA_FALSE);
32
emotion_object_position_set(ev->object, 0);
36
_create_emotion_object(Evas *e)
38
Evas_Object *em = emotion_object_add(e);
40
emotion_object_init(em, "generic");
42
efl_event_callback_add
43
(em, EFL_CANVAS_VIDEO_EVENT_PLAYBACK_START, _playback_started_cb, NULL);
44
efl_event_callback_add
45
(em, EFL_CANVAS_VIDEO_EVENT_PLAYBACK_STOP, _playback_stopped_cb, NULL);
51
_on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
53
Evas_Event_Key_Down *ev = event_info;
54
Evas_Object *em = data;
56
if (!strcmp(ev->key, "Return"))
58
emotion_object_play_set(em, EINA_TRUE);
60
else if (!strcmp(ev->key, "space"))
62
emotion_object_play_set(em, EINA_FALSE);
64
else if (!strcmp(ev->key, "Escape"))
66
ecore_main_loop_quit();
68
else if (!strcmp(ev->key, "t"))
71
emotion_object_size_get(em, &w, &h);
72
fprintf(stderr, "example -> size: %dx%d\n", w, h);
74
else if (!strcmp(ev->key, "s"))
77
len = emotion_object_play_length_get(em);
79
fprintf(stderr, "skipping to position %0.3f\n", pos);
80
emotion_object_position_set(em, pos);
82
else if (!strcmp(ev->key, "1"))
84
fprintf(stderr, "setting speed to 1.0\n");
85
emotion_object_play_speed_set(em, 1.0);
87
else if (!strcmp(ev->key, "2"))
89
fprintf(stderr, "setting speed to 2.0\n");
90
emotion_object_play_speed_set(em, 2.0);
92
else if (!strcmp(ev->key, "n"))
98
curfile = eina_list_next(curfile);
99
file = eina_list_data_get(curfile);
100
fprintf(stderr, "playing next file: %s\n", file);
101
emotion_object_file_set(em, file);
103
else if (!strcmp(ev->key, "p"))
107
curfile = eina_list_last(filenames);
109
curfile = eina_list_prev(curfile);
110
file = eina_list_data_get(curfile);
111
fprintf(stderr, "playing next file: %s\n", file);
112
emotion_object_file_set(em, file);
114
else if (!strcmp(ev->key, "d"))
118
else if (!strcmp(ev->key, "l"))
125
fprintf(stderr, "unhandled key: %s\n", ev->key);
130
_frame_decode_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
136
_length_change_cb(void *data EINA_UNUSED, const Efl_Event *ev)
138
fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(ev->object));
142
_position_update_cb(void *data EINA_UNUSED, const Efl_Event *ev)
144
fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(ev->object));
148
_progress_change_cb(void *data EINA_UNUSED, const Efl_Event *ev)
150
fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n",
151
emotion_object_progress_status_get(ev->object),
152
emotion_object_progress_info_get(ev->object));
155
EFL_CALLBACKS_ARRAY_DEFINE(emotion_object_example_callbacks,
156
{ EFL_CANVAS_VIDEO_EVENT_FRAME_DECODE, _frame_decode_cb },
157
{ EFL_CANVAS_VIDEO_EVENT_LENGTH_CHANGE, _length_change_cb },
158
{ EFL_CANVAS_VIDEO_EVENT_POSITION_CHANGE, _position_update_cb },
159
{ EFL_CANVAS_VIDEO_EVENT_PROGRESS_CHANGE, _progress_change_cb });
162
main(int argc, const char *argv[])
166
Evas_Object *bg, *em;
171
printf("One argument is necessary. Usage:\n");
172
printf("\t%s <filename>\n", argv[0]);
176
for (i = 1; i < argc; i++)
177
filenames = eina_list_append(filenames, eina_stringshare_add(argv[i]));
181
if (!ecore_evas_init())
186
ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
193
e = ecore_evas_get(ee);
196
bg = evas_object_rectangle_add(e);
197
evas_object_name_set(bg, "our dear rectangle");
198
evas_object_color_set(bg, 255, 255, 255, 255);
199
evas_object_move(bg, 0, 0);
200
evas_object_resize(bg, WIDTH, HEIGHT);
201
evas_object_show(bg);
204
em = _create_emotion_object(e);
205
emotion_object_file_set(em, eina_list_data_get(curfile));
206
evas_object_move(em, 0, 0);
207
evas_object_resize(em, WIDTH, HEIGHT);
208
evas_object_show(em);
210
efl_event_callback_array_add(em, emotion_object_example_callbacks(), NULL);
212
evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em);
213
evas_object_focus_set(bg, EINA_TRUE);
215
emotion_object_play_set(em, EINA_TRUE);
217
ecore_main_loop_begin();
220
ecore_evas_shutdown();
224
fprintf(stderr, "error: Requires at least one Evas engine built and linked"
225
" to ecore-evas for this example to run properly.\n");
227
EINA_LIST_FREE(filenames, curfile)
228
eina_stringshare_del(eina_list_data_get(curfile));
230
ecore_evas_shutdown();