summaryrefslogtreecommitdiff
path: root/src/examples/emotion
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
commitdfb84c1657bfb14a5236b881193b81f4c0b8a69b (patch)
treeb51b210fc88a21eec8e5907b8bbfe12ebc669f90 /src/examples/emotion
parent532284dbbe4259a9f2291f44d3eff376849e8031 (diff)
efl: merge emotion.
this one was quite a huge work, but hopefully it's correct. NOTES: * removed vlc generic module, it should go into a separate package. * gstreamer is enabled by default (see --disable-gstreamer) * xine is disabled by default (see --enable-gstreamer) * generic is always built statically if supported * gstreamer and xine can't be configured as static (just lacks command line options, build system supports it) * v4l2 is enabled by default on linux if eeze is built (see --disable-v4l2) * emotion_test moved to src/tests/emotion and depends on EFL_ENABLE_TESTS (--with-tests), but is still installed if enabled. TODO (need your help!): * fix warnings with gstreamer and xine engine * call engine shutdown functions if building as static * remove direct usage of PACKAGE_*_DIR and use eina_prefix * add eina_prefix checkme file as evas and others * add support for $EFL_RUN_IN_TREE * create separate package for emotion_generic_modules * check docs hierarchy (doxygen is segv'in here) SVN revision: 82501
Diffstat (limited to 'src/examples/emotion')
-rw-r--r--src/examples/emotion/Makefile.am57
-rw-r--r--src/examples/emotion/emotion_basic_example.c81
-rw-r--r--src/examples/emotion/emotion_border_example.c238
-rw-r--r--src/examples/emotion/emotion_generic_example.c233
-rw-r--r--src/examples/emotion/emotion_generic_subtitle_example.c97
-rw-r--r--src/examples/emotion/emotion_signals_example.c173
6 files changed, 879 insertions, 0 deletions
diff --git a/src/examples/emotion/Makefile.am b/src/examples/emotion/Makefile.am
new file mode 100644
index 0000000000..b1bf86e654
--- /dev/null
+++ b/src/examples/emotion/Makefile.am
@@ -0,0 +1,57 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib/eina \
5-I$(top_srcdir)/src/lib/eo \
6-I$(top_srcdir)/src/lib/evas \
7-I$(top_srcdir)/src/lib/ecore \
8-I$(top_srcdir)/src/lib/ecore_evas \
9-I$(top_srcdir)/src/lib/emotion \
10-I$(top_builddir)/src/lib/eina \
11-I$(top_builddir)/src/lib/eo \
12-I$(top_builddir)/src/lib/evas \
13-I$(top_builddir)/src/lib/ecore \
14-I$(top_builddir)/src/lib/ecore_evas \
15-I$(top_builddir)/src/lib/emotion \
16@EMOTION_CFLAGS@
17
18LDADD = \
19$(top_builddir)/src/lib/eina/libeina.la \
20$(top_builddir)/src/lib/eo/libeo.la \
21$(top_builddir)/src/lib/evas/libevas.la \
22$(top_builddir)/src/lib/ecore/libecore.la \
23$(top_builddir)/src/lib/ecore_evas/libecore_evas.la \
24$(top_builddir)/src/lib/emotion/libemotion.la \
25@EMOTION_LDFLAGS@
26
27EXTRA_PROGRAMS = \
28emotion_basic_example \
29emotion_generic_example \
30emotion_generic_subtitle_example \
31emotion_border_example \
32emotion_signals_example
33
34SRCS = \
35emotion_basic_example.c \
36emotion_generic_example.c \
37emotion_generic_subtitle_example.c \
38emotion_border_example.c \
39emotion_signals_example.c
40
41examples: $(EXTRA_PROGRAMS)
42
43clean-local:
44 rm -f $(EXTRA_PROGRAMS)
45
46install-examples:
47 mkdir -p $(datadir)/emotion/examples
48 $(install_sh_DATA) -c $(SRCS) $(datadir)/emotion/examples
49
50uninstall-local:
51 for f in $(SRCS); do \
52 rm -f $(datadir)/emotion/examples/$$f ; \
53 done
54
55if ALWAYS_BUILD_EXAMPLES
56noinst_PROGRAMS = $(EXTRA_PROGRAMS)
57endif
diff --git a/src/examples/emotion/emotion_basic_example.c b/src/examples/emotion/emotion_basic_example.c
new file mode 100644
index 0000000000..7e3e4c2e4b
--- /dev/null
+++ b/src/examples/emotion/emotion_basic_example.c
@@ -0,0 +1,81 @@
1#include <Ecore.h>
2#include <Ecore_Evas.h>
3#include <Evas.h>
4#include <Emotion.h>
5#include <stdio.h>
6
7#define WIDTH (320)
8#define HEIGHT (240)
9
10static void
11_playback_started_cb(void *data, Evas_Object *o, void *event_info)
12{
13 printf("Emotion object started playback.\n");
14}
15
16int
17main(int argc, const char *argv[])
18{
19 Ecore_Evas *ee;
20 Evas *e;
21 Evas_Object *bg, *em;
22 const char *filename = NULL;
23
24 if (argc < 2)
25 {
26 printf("One argument is necessary. Usage:\n");
27 printf("\t%s <filename>\n", argv[0]);
28 }
29
30 filename = argv[1];
31
32 if (!ecore_evas_init())
33 return EXIT_FAILURE;
34
35 /* this will give you a window with an Evas canvas under the first
36 * engine available */
37 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
38 if (!ee)
39 goto error;
40
41 ecore_evas_show(ee);
42
43 /* the canvas pointer, de facto */
44 e = ecore_evas_get(ee);
45
46 /* adding a background to this example */
47 bg = evas_object_rectangle_add(e);
48 evas_object_name_set(bg, "our dear rectangle");
49 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
50 evas_object_move(bg, 0, 0); /* at canvas' origin */
51 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
52 evas_object_show(bg);
53
54 /* Creating the emotion object */
55 em = emotion_object_add(e);
56 emotion_object_init(em, NULL);
57
58 evas_object_smart_callback_add(
59 em, "playback_started", _playback_started_cb, NULL);
60
61 emotion_object_file_set(em, filename);
62
63 evas_object_move(em, 0, 0);
64 evas_object_resize(em, WIDTH, HEIGHT);
65 evas_object_show(em);
66
67 emotion_object_play_set(em, EINA_TRUE);
68
69 ecore_main_loop_begin();
70
71 ecore_evas_free(ee);
72 ecore_evas_shutdown();
73 return 0;
74
75error:
76 fprintf(stderr, "you got to have at least one evas engine built and linked"
77 " up to ecore-evas for this example to run properly.\n");
78
79 ecore_evas_shutdown();
80 return -1;
81}
diff --git a/src/examples/emotion/emotion_border_example.c b/src/examples/emotion/emotion_border_example.c
new file mode 100644
index 0000000000..9df53f4333
--- /dev/null
+++ b/src/examples/emotion/emotion_border_example.c
@@ -0,0 +1,238 @@
1#include <Ecore.h>
2#include <Ecore_Evas.h>
3#include <Evas.h>
4#include <Emotion.h>
5#include <stdio.h>
6#include <string.h>
7
8#define WIDTH (320)
9#define HEIGHT (240)
10
11static Eina_List *filenames = NULL;
12static Eina_List *curfile = NULL;
13
14static void
15_playback_started_cb(void *data, Evas_Object *o, void *event_info)
16{
17 printf("Emotion object started playback.\n");
18}
19
20static Evas_Object *
21_create_emotion_object(Evas *e)
22{
23 Evas_Object *em = emotion_object_add(e);
24
25 emotion_object_init(em, "gstreamer");
26
27 evas_object_smart_callback_add(
28 em, "playback_started", _playback_started_cb, NULL);
29
30 return em;
31}
32
33static void
34_on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info)
35{
36 Evas_Event_Key_Down *ev = event_info;
37 Evas_Object *em = data;
38
39 if (!strcmp(ev->keyname, "Return"))
40 {
41 emotion_object_play_set(em, EINA_TRUE);
42 }
43 else if (!strcmp(ev->keyname, "space"))
44 {
45 emotion_object_play_set(em, EINA_FALSE);
46 }
47 else if (!strcmp(ev->keyname, "Escape"))
48 {
49 ecore_main_loop_quit();
50 }
51 else if (!strcmp(ev->keyname, "n"))
52 {
53 const char *file;
54 if (!curfile)
55 curfile = filenames;
56 else
57 curfile = eina_list_next(curfile);
58 file = eina_list_data_get(curfile);
59 fprintf(stderr, "playing next file: %s\n", file);
60 emotion_object_file_set(em, file);
61 }
62 else if (!strcmp(ev->keyname, "p"))
63 {
64 const char *file;
65 if (!curfile)
66 curfile = eina_list_last(filenames);
67 else
68 curfile = eina_list_prev(curfile);
69 file = eina_list_data_get(curfile);
70 fprintf(stderr, "playing next file: %s\n", file);
71 emotion_object_file_set(em, file);
72 }
73 else if (!strcmp(ev->keyname, "b"))
74 {
75 emotion_object_border_set(em, 0, 0, 50, 50);
76 }
77 else if (!strcmp(ev->keyname, "0"))
78 {
79 emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_NONE);
80 }
81 else if (!strcmp(ev->keyname, "w"))
82 {
83 emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_WIDTH);
84 }
85 else if (!strcmp(ev->keyname, "h"))
86 {
87 emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_HEIGHT);
88 }
89 else if (!strcmp(ev->keyname, "2"))
90 {
91 emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_BOTH);
92 }
93 else if (!strcmp(ev->keyname, "c"))
94 {
95 emotion_object_keep_aspect_set(em, EMOTION_ASPECT_CROP);
96 }
97 else
98 {
99 fprintf(stderr, "unhandled key: %s\n", ev->keyname);
100 }
101}
102
103static void
104_frame_decode_cb(void *data, Evas_Object *o, void *event_info)
105{
106 // fprintf(stderr, "smartcb: frame_decode\n");
107}
108
109static void
110_length_change_cb(void *data, Evas_Object *o, void *event_info)
111{
112 fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(o));
113}
114
115static void
116_position_update_cb(void *data, Evas_Object *o, void *event_info)
117{
118 fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(o));
119}
120
121static void
122_progress_change_cb(void *data, Evas_Object *o, void *event_info)
123{
124 fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n",
125 emotion_object_progress_status_get(o),
126 emotion_object_progress_info_get(o));
127}
128
129static void
130_frame_resize_cb(void *data, Evas_Object *o, void *event_info)
131{
132 int w, h;
133 emotion_object_size_get(o, &w, &h);
134 fprintf(stderr, "smartcb: frame_resize: %dx%d\n", w, h);
135}
136
137static void /* adjust canvas' contents on resizes */
138_canvas_resize_cb(Ecore_Evas *ee)
139{
140 int w, h;
141 Evas_Object *bg, *em;
142
143 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
144
145 bg = ecore_evas_data_get(ee, "bg");
146 em = ecore_evas_data_get(ee, "emotion");
147
148 evas_object_resize(bg, w, h);
149 evas_object_move(em, 10, 10);
150 evas_object_resize(em, w - 20, h - 20);
151}
152
153int
154main(int argc, const char *argv[])
155{
156 Ecore_Evas *ee;
157 Evas *e;
158 Evas_Object *bg, *em;
159 int i;
160
161 if (argc < 2)
162 {
163 printf("One argument is necessary. Usage:\n");
164 printf("\t%s <filename>\n", argv[0]);
165 }
166
167 eina_init();
168 for (i = 1; i < argc; i++)
169 filenames = eina_list_append(filenames, eina_stringshare_add(argv[i]));
170
171 curfile = filenames;
172
173 if (!ecore_evas_init())
174 return EXIT_FAILURE;
175
176 /* this will give you a window with an Evas canvas under the first
177 * engine available */
178 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
179 if (!ee)
180 goto error;
181
182 ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
183
184 ecore_evas_show(ee);
185
186 /* the canvas pointer, de facto */
187 e = ecore_evas_get(ee);
188
189 /* adding a background to this example */
190 bg = evas_object_rectangle_add(e);
191 evas_object_name_set(bg, "our dear rectangle");
192 evas_object_color_set(bg, 255, 0, 0, 255); /* white bg */
193 evas_object_move(bg, 0, 0); /* at canvas' origin */
194 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
195 evas_object_show(bg);
196
197 ecore_evas_data_set(ee, "bg", bg);
198
199 /* Creating the emotion object */
200 em = _create_emotion_object(e);
201 emotion_object_file_set(em, eina_list_data_get(curfile));
202 evas_object_move(em, 10, 10);
203 evas_object_resize(em, WIDTH, HEIGHT);
204 evas_object_resize(em, WIDTH - 20, HEIGHT - 20);
205 emotion_object_keep_aspect_set(em, EMOTION_ASPECT_KEEP_BOTH);
206 emotion_object_bg_color_set(em, 0, 128, 0, 255);
207 evas_object_show(em);
208
209 ecore_evas_data_set(ee, "emotion", em);
210
211 evas_object_smart_callback_add(em, "frame_decode", _frame_decode_cb, NULL);
212 evas_object_smart_callback_add(em, "length_change", _length_change_cb, NULL);
213 evas_object_smart_callback_add(em, "position_update", _position_update_cb, NULL);
214 evas_object_smart_callback_add(em, "progress_change", _progress_change_cb, NULL);
215 evas_object_smart_callback_add(em, "frame_resize", _frame_resize_cb, NULL);
216
217 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em);
218 evas_object_focus_set(bg, EINA_TRUE);
219
220 emotion_object_play_set(em, EINA_TRUE);
221
222 ecore_main_loop_begin();
223
224 ecore_evas_free(ee);
225 ecore_evas_shutdown();
226 return 0;
227
228error:
229 fprintf(stderr, "you got to have at least one evas engine built and linked"
230 " up to ecore-evas for this example to run properly.\n");
231
232 EINA_LIST_FREE(filenames, curfile)
233 eina_stringshare_del(eina_list_data_get(curfile));
234
235 ecore_evas_shutdown();
236 eina_shutdown();
237 return -1;
238}
diff --git a/src/examples/emotion/emotion_generic_example.c b/src/examples/emotion/emotion_generic_example.c
new file mode 100644
index 0000000000..b8382862d5
--- /dev/null
+++ b/src/examples/emotion/emotion_generic_example.c
@@ -0,0 +1,233 @@
1#include <Ecore.h>
2#include <Ecore_Evas.h>
3#include <Evas.h>
4#include <Emotion.h>
5#include <stdio.h>
6#include <string.h>
7#include <unistd.h>
8
9#define WIDTH (320)
10#define HEIGHT (240)
11
12static Eina_List *filenames = NULL;
13static Eina_List *curfile = NULL;
14
15static void
16_playback_started_cb(void *data, Evas_Object *o, void *event_info)
17{
18 printf("Emotion object started playback.\n");
19}
20
21static void
22_playback_stopped_cb(void *data, Evas_Object *o, void *event_info)
23{
24 printf("Emotion playback stopped.\n");
25 emotion_object_play_set(o, EINA_FALSE);
26 emotion_object_position_set(o, 0);
27}
28
29static Evas_Object *
30_create_emotion_object(Evas *e)
31{
32 Evas_Object *em = emotion_object_add(e);
33
34 emotion_object_init(em, "generic");
35
36 evas_object_smart_callback_add(
37 em, "playback_started", _playback_started_cb, NULL);
38 evas_object_smart_callback_add(
39 em, "playback_finished", _playback_stopped_cb, NULL);
40
41 return em;
42}
43
44static void
45_on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info)
46{
47 Evas_Event_Key_Down *ev = event_info;
48 Evas_Object *em = data;
49
50 if (!strcmp(ev->keyname, "Return"))
51 {
52 emotion_object_play_set(em, EINA_TRUE);
53 }
54 else if (!strcmp(ev->keyname, "space"))
55 {
56 emotion_object_play_set(em, EINA_FALSE);
57 }
58 else if (!strcmp(ev->keyname, "Escape"))
59 {
60 ecore_main_loop_quit();
61 }
62 else if (!strcmp(ev->keyname, "t"))
63 {
64 int w, h;
65 emotion_object_size_get(em, &w, &h);
66 fprintf(stderr, "example -> size: %dx%d\n", w, h);
67 }
68 else if (!strcmp(ev->keyname, "s"))
69 {
70 float len, pos;
71 len = emotion_object_play_length_get(em);
72 pos = 0.98 * len;
73 fprintf(stderr, "skipping to position %0.3f\n", pos);
74 emotion_object_position_set(em, pos);
75 }
76 else if (!strcmp(ev->keyname, "1"))
77 {
78 fprintf(stderr, "setting speed to 1.0\n");
79 emotion_object_play_speed_set(em, 1.0);
80 }
81 else if (!strcmp(ev->keyname, "2"))
82 {
83 fprintf(stderr, "setting speed to 2.0\n");
84 emotion_object_play_speed_set(em, 2.0);
85 }
86 else if (!strcmp(ev->keyname, "n"))
87 {
88 const char *file;
89 if (!curfile)
90 curfile = filenames;
91 else
92 curfile = eina_list_next(curfile);
93 file = eina_list_data_get(curfile);
94 fprintf(stderr, "playing next file: %s\n", file);
95 emotion_object_file_set(em, file);
96 }
97 else if (!strcmp(ev->keyname, "p"))
98 {
99 const char *file;
100 if (!curfile)
101 curfile = eina_list_last(filenames);
102 else
103 curfile = eina_list_prev(curfile);
104 file = eina_list_data_get(curfile);
105 fprintf(stderr, "playing next file: %s\n", file);
106 emotion_object_file_set(em, file);
107 }
108 else if (!strcmp(ev->keyname, "d"))
109 {
110 evas_object_del(em);
111 }
112 else if (!strcmp(ev->keyname, "l"))
113 {
114 // force frame dropping
115 sleep(5);
116 }
117 else
118 {
119 fprintf(stderr, "unhandled key: %s\n", ev->keyname);
120 }
121}
122
123static void
124_frame_decode_cb(void *data, Evas_Object *o, void *event_info)
125{
126 // fprintf(stderr, "smartcb: frame_decode\n");
127}
128
129static void
130_length_change_cb(void *data, Evas_Object *o, void *event_info)
131{
132 fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(o));
133}
134
135static void
136_position_update_cb(void *data, Evas_Object *o, void *event_info)
137{
138 fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(o));
139}
140
141static void
142_progress_change_cb(void *data, Evas_Object *o, void *event_info)
143{
144 fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n",
145 emotion_object_progress_status_get(o),
146 emotion_object_progress_info_get(o));
147}
148
149static void
150_frame_resize_cb(void *data, Evas_Object *o, void *event_info)
151{
152 int w, h;
153 emotion_object_size_get(o, &w, &h);
154 fprintf(stderr, "smartcb: frame_resize: %dx%d\n", w, h);
155}
156
157int
158main(int argc, const char *argv[])
159{
160 Ecore_Evas *ee;
161 Evas *e;
162 Evas_Object *bg, *em;
163 int i;
164
165 if (argc < 2)
166 {
167 printf("One argument is necessary. Usage:\n");
168 printf("\t%s <filename>\n", argv[0]);
169 }
170
171 eina_init();
172 for (i = 1; i < argc; i++)
173 filenames = eina_list_append(filenames, eina_stringshare_add(argv[i]));
174
175 curfile = filenames;
176
177 if (!ecore_evas_init())
178 return EXIT_FAILURE;
179
180 /* this will give you a window with an Evas canvas under the first
181 * engine available */
182 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
183 if (!ee)
184 goto error;
185
186 ecore_evas_show(ee);
187
188 /* the canvas pointer, de facto */
189 e = ecore_evas_get(ee);
190
191 /* adding a background to this example */
192 bg = evas_object_rectangle_add(e);
193 evas_object_name_set(bg, "our dear rectangle");
194 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
195 evas_object_move(bg, 0, 0); /* at canvas' origin */
196 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
197 evas_object_show(bg);
198
199 /* Creating the emotion object */
200 em = _create_emotion_object(e);
201 emotion_object_file_set(em, eina_list_data_get(curfile));
202 evas_object_move(em, 0, 0);
203 evas_object_resize(em, WIDTH, HEIGHT);
204 evas_object_show(em);
205
206 evas_object_smart_callback_add(em, "frame_decode", _frame_decode_cb, NULL);
207 evas_object_smart_callback_add(em, "length_change", _length_change_cb, NULL);
208 evas_object_smart_callback_add(em, "position_update", _position_update_cb, NULL);
209 evas_object_smart_callback_add(em, "progress_change", _progress_change_cb, NULL);
210 evas_object_smart_callback_add(em, "frame_resize", _frame_resize_cb, NULL);
211
212 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em);
213 evas_object_focus_set(bg, EINA_TRUE);
214
215 emotion_object_play_set(em, EINA_TRUE);
216
217 ecore_main_loop_begin();
218
219 ecore_evas_free(ee);
220 ecore_evas_shutdown();
221 return 0;
222
223error:
224 fprintf(stderr, "you got to have at least one evas engine built and linked"
225 " up to ecore-evas for this example to run properly.\n");
226
227 EINA_LIST_FREE(filenames, curfile)
228 eina_stringshare_del(eina_list_data_get(curfile));
229
230 ecore_evas_shutdown();
231 eina_shutdown();
232 return -1;
233}
diff --git a/src/examples/emotion/emotion_generic_subtitle_example.c b/src/examples/emotion/emotion_generic_subtitle_example.c
new file mode 100644
index 0000000000..448b505449
--- /dev/null
+++ b/src/examples/emotion/emotion_generic_subtitle_example.c
@@ -0,0 +1,97 @@
1#include <Ecore.h>
2#include <Ecore_Evas.h>
3#include <Evas.h>
4#include <Emotion.h>
5#include <stdio.h>
6
7#define WIDTH (320)
8#define HEIGHT (240)
9
10static void
11_playback_started_cb(void *data, Evas_Object *o, void *event_info)
12{
13 printf("Emotion object started playback.\n");
14}
15
16static void
17_on_delete(Ecore_Evas *ee)
18{
19 ecore_main_loop_quit();
20}
21
22int
23main(int argc, const char *argv[])
24{
25 Ecore_Evas *ee;
26 Evas *e;
27 Evas_Object *bg, *em;
28 const char *filename = NULL;
29 const char *subtitle_filename = NULL;
30
31 if (argc < 2)
32 {
33 printf("At least one argument is necessary. Usage:\n");
34 printf("\t%s <filename> <subtitle filename>\n", argv[0]);
35 return -1;
36 }
37
38 filename = argv[1];
39
40 if (argc > 2)
41 subtitle_filename = argv[2];
42
43 if (!ecore_evas_init())
44 return EXIT_FAILURE;
45
46 /* this will give you a window with an Evas canvas under the first
47 * engine available */
48 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
49 if (!ee)
50 goto error;
51
52 ecore_evas_callback_delete_request_set(ee, _on_delete);
53
54 ecore_evas_show(ee);
55
56 /* the canvas pointer, de facto */
57 e = ecore_evas_get(ee);
58
59 /* adding a background to this example */
60 bg = evas_object_rectangle_add(e);
61 evas_object_name_set(bg, "our dear rectangle");
62 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
63 evas_object_move(bg, 0, 0); /* at canvas' origin */
64 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
65 evas_object_show(bg);
66
67 /* Creating the emotion object */
68 em = emotion_object_add(e);
69 emotion_object_init(em, "generic");
70
71 if (subtitle_filename)
72 emotion_object_video_subtitle_file_set(em, subtitle_filename);
73
74 evas_object_smart_callback_add(
75 em, "playback_started", _playback_started_cb, NULL);
76
77 emotion_object_file_set(em, filename);
78
79 evas_object_move(em, 0, 0);
80 evas_object_resize(em, WIDTH, HEIGHT);
81 evas_object_show(em);
82
83 emotion_object_play_set(em, EINA_TRUE);
84
85 ecore_main_loop_begin();
86
87 ecore_evas_free(ee);
88 ecore_evas_shutdown();
89 return 0;
90
91error:
92 fprintf(stderr, "you got to have at least one evas engine built and linked"
93 " up to ecore-evas for this example to run properly.\n");
94
95 ecore_evas_shutdown();
96 return -1;
97}
diff --git a/src/examples/emotion/emotion_signals_example.c b/src/examples/emotion/emotion_signals_example.c
new file mode 100644
index 0000000000..2469c468ba
--- /dev/null
+++ b/src/examples/emotion/emotion_signals_example.c
@@ -0,0 +1,173 @@
1#include <Ecore.h>
2#include <Ecore_Evas.h>
3#include <Evas.h>
4#include <Emotion.h>
5#include <stdio.h>
6
7#define WIDTH (320)
8#define HEIGHT (240)
9
10static void
11_display_info(Evas_Object *o)
12{
13 int w, h;
14 printf("playing: %d\n", emotion_object_play_get(o));
15 printf("meta title: %s\n",
16 emotion_object_meta_info_get(o, EMOTION_META_INFO_TRACK_TITLE));
17 printf("seek position: %0.3f\n",
18 emotion_object_position_get(o));
19 printf("play length: %0.3f\n",
20 emotion_object_play_length_get(o));
21 printf("is seekable: %d\n",
22 emotion_object_seekable_get(o));
23 emotion_object_size_get(o, &w, &h);
24 printf("video geometry: %dx%d\n", w, h);
25 printf("video width / height ratio: %0.3f\n",
26 emotion_object_ratio_get(o));
27 printf("\n");
28}
29
30static void
31_playback_started_cb(void *data, Evas_Object *o, void *event_info)
32{
33 printf(">>> Emotion object started playback.\n");
34 _display_info(o);
35}
36
37static void
38_playback_finished_cb(void *data, Evas_Object *o, void *event_info)
39{
40 printf(">>> Emotion object finished playback.\n");
41 _display_info(o);
42}
43
44static void
45_open_done_cb(void *data, Evas_Object *o, void *event_info)
46{
47 printf(">>> Emotion object open done.\n");
48 _display_info(o);
49}
50
51static void
52_position_update_cb(void *data, Evas_Object *o, void *event_info)
53{
54 printf(">>> Emotion object first position update.\n");
55 evas_object_smart_callback_del(o, "position_update", _position_update_cb);
56 _display_info(o);
57}
58
59static void
60_frame_decode_cb(void *data, Evas_Object *o, void *event_info)
61{
62 printf(">>> Emotion object first frame decode.\n");
63 evas_object_smart_callback_del(o, "frame_decode", _frame_decode_cb);
64 _display_info(o);
65}
66
67static void
68_decode_stop_cb(void *data, Evas_Object *o, void *event_info)
69{
70 printf(">>> Emotion object decode stop.\n");
71 _display_info(o);
72}
73
74static void
75_frame_resize_cb(void *data, Evas_Object *o, void *event_info)
76{
77 printf(">>> Emotion object frame resize.\n");
78 _display_info(o);
79}
80
81static void
82_setup_emotion_callbacks(Evas_Object *o)
83{
84 evas_object_smart_callback_add(
85 o, "playback_started", _playback_started_cb, NULL);
86 evas_object_smart_callback_add(
87 o, "playback_finished", _playback_finished_cb, NULL);
88 evas_object_smart_callback_add(
89 o, "open_done", _open_done_cb, NULL);
90 evas_object_smart_callback_add(
91 o, "position_update", _position_update_cb, NULL);
92 evas_object_smart_callback_add(
93 o, "frame_decode", _frame_decode_cb, NULL);
94 evas_object_smart_callback_add(
95 o, "decode_stop", _decode_stop_cb, NULL);
96 evas_object_smart_callback_add(
97 o, "frame_resize", _frame_resize_cb, NULL);
98}
99
100int
101main(int argc, const char *argv[])
102{
103 Ecore_Evas *ee;
104 Evas *e;
105 Evas_Object *bg, *em;
106 const char *filename = NULL;
107 const char *module = NULL;
108
109 if (argc < 2)
110 {
111 printf("At least one argument is necessary. Usage:\n");
112 printf("\t%s <filename> [module_name]\n", argv[0]);
113 goto error;
114 }
115
116 filename = argv[1];
117
118 if (argc >= 3)
119 module = argv[2];
120
121 if (!ecore_evas_init())
122 return EXIT_FAILURE;
123
124 /* this will give you a window with an Evas canvas under the first
125 * engine available */
126 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
127 if (!ee)
128 goto error;
129
130 ecore_evas_show(ee);
131
132 /* the canvas pointer, de facto */
133 e = ecore_evas_get(ee);
134
135 /* adding a background to this example */
136 bg = evas_object_rectangle_add(e);
137 evas_object_name_set(bg, "our dear rectangle");
138 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
139 evas_object_move(bg, 0, 0); /* at canvas' origin */
140 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
141 evas_object_show(bg);
142
143 /* Creating the emotion object */
144 em = emotion_object_add(e);
145
146 /* Try to load the specified module - NULL for auto-discover */
147 if (!emotion_object_init(em, module))
148 fprintf(stderr, "Emotion: \"%s\" module could not be initialized.\n", module);
149
150 _display_info(em);
151 _setup_emotion_callbacks(em);
152
153 if (!emotion_object_file_set(em, filename))
154 fprintf(stderr, "Emotion: Could not load the file \"%s\"\n", filename);
155
156 evas_object_move(em, 0, 0);
157 evas_object_resize(em, WIDTH, HEIGHT);
158 evas_object_show(em);
159
160 emotion_object_play_set(em, EINA_TRUE);
161
162 ecore_main_loop_begin();
163
164 ecore_evas_free(ee);
165 ecore_evas_shutdown();
166 return 0;
167
168 ecore_evas_free(ee);
169
170error:
171 ecore_evas_shutdown();
172 return -1;
173}