\hypertarget{emotion_signals_example_8c-example}{}\section{emotion\+\_\+signals\+\_\+example.\+c}
This example shows that some of the information available from the emotion object, like the media file play length, aspect ratio, etc. can be not available just after setting the file to the emotion object.

One callback is declared for each of the following signals, and some of the info about the file is displayed. Also notice that the order that these signals are emitted can change depending on the module being used. Following is the full source code of this example\+:


\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{// gcc -o emotion\_signals\_example emotion\_signals\_example.c `pkg-config --libs --cflags emotion evas ecore
       ecore-evas eo`}

\textcolor{preprocessor}{#define EFL\_EO\_API\_SUPPORT}
\textcolor{preprocessor}{#define EFL\_BETA\_API\_SUPPORT}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}>}
\textcolor{preprocessor}{#include <Evas.h>}
\textcolor{preprocessor}{#include <\hyperlink{Emotion_8h}{Emotion.h}>}
\textcolor{preprocessor}{#include <stdio.h>}

\textcolor{preprocessor}{#define WIDTH  (320)}
\textcolor{preprocessor}{#define HEIGHT (240)}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_display\_info(\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o)
\{
   \textcolor{keywordtype}{int} w, h;
   printf(\textcolor{stringliteral}{"playing: %d\(\backslash\)n"}, \hyperlink{group__Emotion__Play_gad98af85afb4a56479adaf39f4e205ecd}{emotion\_object\_play\_get}(o));
   printf(\textcolor{stringliteral}{"meta title: %s\(\backslash\)n"},
          \hyperlink{group__Emotion__Info_ga3c9a3919e9d253f2106842c21172b573}{emotion\_object\_meta\_info\_get}(o, 
      \hyperlink{Emotion_8h_ga90fb0b9d7b2c320f25118765ddcc8213ad104229a0d0ac128ce0b6fbb9c96aaa7}{EMOTION\_META\_INFO\_TRACK\_TITLE}));
   printf(\textcolor{stringliteral}{"seek position: %0.3f\(\backslash\)n"},
          \hyperlink{group__Emotion__Play_gae92dbeafe773cebd59740dc32ae7da1d}{emotion\_object\_position\_get}(o));
   printf(\textcolor{stringliteral}{"play length: %0.3f\(\backslash\)n"},
          \hyperlink{group__Emotion__Play_ga7afce8907b1bb37b1f08292019957e5a}{emotion\_object\_play\_length\_get}(o));
   printf(\textcolor{stringliteral}{"is seekable: %d\(\backslash\)n"},
          \hyperlink{group__Emotion__Play_ga1abc85aa331e33d58552692724ff4f4c}{emotion\_object\_seekable\_get}(o));
   \hyperlink{group__Emotion__Video_ga43910636929c5488347a022b9305b029}{emotion\_object\_size\_get}(o, &w, &h);
   printf(\textcolor{stringliteral}{"video geometry: %dx%d\(\backslash\)n"}, w, h);
   printf(\textcolor{stringliteral}{"video width / height ratio: %0.3f\(\backslash\)n"},
          \hyperlink{group__Emotion__Video_ga8edfce29000a58e41e1a8bca83ae66d8}{emotion\_object\_ratio\_get}(o));
   printf(\textcolor{stringliteral}{"\(\backslash\)n"});
\}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_playback\_started\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED},
            \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} *o, \textcolor{keyword}{const} \hyperlink{struct__Eo__Event__Description}{Eo\_Event\_Description} *desc 
      \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *event\_info \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   printf(\textcolor{stringliteral}{">>> Emotion object started playback.\(\backslash\)n"});
   \_display\_info(o);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_playback\_finished\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED},
            \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} *o, \textcolor{keyword}{const} \hyperlink{struct__Eo__Event__Description}{Eo\_Event\_Description} *desc 
      \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *event\_info \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   printf(\textcolor{stringliteral}{">>> Emotion object finished playback.\(\backslash\)n"});
   \_display\_info(o);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_open\_done\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED},
            \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} *o, \textcolor{keyword}{const} \hyperlink{struct__Eo__Event__Description}{Eo\_Event\_Description} *desc 
      \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *event\_info \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   printf(\textcolor{stringliteral}{">>> Emotion object open done.\(\backslash\)n"});
   \_display\_info(o);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_position\_update\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED},
            \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} *o, \textcolor{keyword}{const} \hyperlink{struct__Eo__Event__Description}{Eo\_Event\_Description} *desc 
      \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *event\_info \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   printf(\textcolor{stringliteral}{">>> Emotion object first position update.\(\backslash\)n"});
   eo\_do(o, eo\_event\_callback\_del(EMOTION\_OBJECT\_EVENT\_POSITION\_UPDATE,
             \_position\_update\_cb, NULL));
   \_display\_info(o);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_frame\_decode\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED},
            \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} *o, \textcolor{keyword}{const} \hyperlink{struct__Eo__Event__Description}{Eo\_Event\_Description} *desc 
      \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *event\_info \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   printf(\textcolor{stringliteral}{">>> Emotion object first frame decode.\(\backslash\)n"});
   eo\_do(o, eo\_event\_callback\_del(EMOTION\_OBJECT\_EVENT\_FRAME\_DECODE,
            \_frame\_decode\_cb, NULL));
   \_display\_info(o);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_decode\_stop\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED},
            \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} *o, \textcolor{keyword}{const} \hyperlink{struct__Eo__Event__Description}{Eo\_Event\_Description} *desc 
      \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *event\_info \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   printf(\textcolor{stringliteral}{">>> Emotion object decode stop.\(\backslash\)n"});
   \_display\_info(o);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_frame\_resize\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED},
            \hyperlink{group__Eo_ga9f3010a50b61a892d41f4ec2bda73f4c}{Eo} *o, \textcolor{keyword}{const} \hyperlink{struct__Eo__Event__Description}{Eo\_Event\_Description} *desc 
      \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *event\_info \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   printf(\textcolor{stringliteral}{">>> Emotion object frame resize.\(\backslash\)n"});
   \_display\_info(o);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keyword}{static} \textcolor{keyword}{const} \hyperlink{struct__Eo__Callback__Array__Item}{Eo\_Callback\_Array\_Item} emotion\_object\_example\_callbacks[] = \{
       \{ EMOTION\_OBJECT\_EVENT\_PLAYBACK\_STARTED, \_playback\_started\_cb \},
       \{ EMOTION\_OBJECT\_EVENT\_PLAYBACK\_FINISHED, \_playback\_finished\_cb \},
       \{ EMOTION\_OBJECT\_EVENT\_OPEN\_DONE, \_open\_done\_cb \},
       \{ EMOTION\_OBJECT\_EVENT\_POSITION\_UPDATE, \_position\_update\_cb \},
       \{ EMOTION\_OBJECT\_EVENT\_FRAME\_DECODE, \_frame\_decode\_cb \},
       \{ EMOTION\_OBJECT\_EVENT\_DECODE\_STOP, \_decode\_stop\_cb \},
       \{ EMOTION\_OBJECT\_EVENT\_FRAME\_RESIZE, \_frame\_resize\_cb \},
       \{ NULL, NULL \}
\};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_setup\_emotion\_callbacks(\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o)
\{
   eo\_do(o, \hyperlink{group__Eo__Events_gaf41a8e360cf16c3eeb401ab0444a3004}{eo\_event\_callback\_add}
     (EMOTION\_OBJECT\_EVENT\_PLAYBACK\_STARTED, \_playback\_started\_cb, NULL));
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *argv[])
\{
   Ecore\_Evas *ee;
   \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg, *em;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *filename = NULL;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *module = NULL;

   \textcolor{keywordflow}{if} (argc < 2)
     \{
        printf(\textcolor{stringliteral}{"At least one argument is necessary. Usage:\(\backslash\)n"});
        printf(\textcolor{stringliteral}{"\(\backslash\)t%s <filename> [module\_name]\(\backslash\)n"}, argv[0]);
        \textcolor{keywordflow}{goto} \hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error};
     \}

   filename = argv[1];

   \textcolor{keywordflow}{if} (argc >= 3)
     module = argv[2];

   \textcolor{keywordflow}{if} (!\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}())
     \textcolor{keywordflow}{return} EXIT\_FAILURE;

   \textcolor{comment}{/* this will give you a window with an Evas canvas under the first}
\textcolor{comment}{    * engine available */}
   ee = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 10, 10, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!ee)
     \textcolor{keywordflow}{goto} \hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error};

   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee);

   \textcolor{comment}{/* the canvas pointer, de facto */}
   e = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee);

   \textcolor{comment}{/* adding a background to this example */}
   bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(e);
   evas\_object\_name\_set(bg, \textcolor{stringliteral}{"our dear rectangle"});
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(bg, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(bg, WIDTH, HEIGHT); \textcolor{comment}{/* covers full canvas */}
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg);

   \textcolor{comment}{/* Creating the emotion object */}
   em = \hyperlink{group__Emotion__Init_ga9b89c712866a0ae77d4cdc6c676e6c01}{emotion\_object\_add}(e);

   \textcolor{comment}{/* Try to load the specified module - NULL for auto-discover */}
   \textcolor{keywordflow}{if} (!emotion\_object\_init(em, module))
     fprintf(stderr, \textcolor{stringliteral}{"Emotion: \(\backslash\)"%s\(\backslash\)" module could not be initialized.\(\backslash\)n"}, module);

   \_display\_info(em);
   \_setup\_emotion\_callbacks(em);

   \textcolor{keywordflow}{if} (!\hyperlink{group__Emotion__Init_ga1b288409a547989d867fd735f7eec556}{emotion\_object\_file\_set}(em, filename))
     fprintf(stderr, \textcolor{stringliteral}{"Emotion: Could not load the file \(\backslash\)"%s\(\backslash\)"\(\backslash\)n"}, filename);

   \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(em, 0, 0);
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(em, WIDTH, HEIGHT);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(em);

   \hyperlink{group__Emotion__Play_ga9be5c239d2100e2c16e18c171e1c1790}{emotion\_object\_play\_set}(em, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});

   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

   \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(ee);
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();
   \textcolor{keywordflow}{return} 0;

   \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(ee);

\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error}:
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();
   \textcolor{keywordflow}{return} -1;
\}
\end{DoxyCodeInclude}
 