\hypertarget{emotion_signals_example_8c-example}{}\doxysection{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.

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}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile\ with:}}
\DoxyCodeLine{\textcolor{comment}{//\ gcc\ -\/o\ emotion\_signals\_example\ emotion\_signals\_example.c\ `pkg-\/config\ -\/-\/libs\ -\/-\/cflags\ emotion\ evas\ ecore\ ecore-\/evas\ eo`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifndef\ EFL\_BETA\_API\_SUPPORT}}
\DoxyCodeLine{\textcolor{preprocessor}{\#\ define\ EFL\_BETA\_API\_SUPPORT}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Evas.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Emotion_8h}{Emotion.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ WIDTH\ \ (320)}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ HEIGHT\ (240)}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_display\_info(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ w,\ h;}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}playing:\ \%d\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Emotion__Play_ga7b146cbe71db82e9c3e280f4277e7071}{emotion\_object\_play\_get}}(o));}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}meta\ title:\ \%s\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Emotion__Info_ga614f84b677bef65fe5125fa0242831fe}{emotion\_object\_meta\_info\_get}}(o,\ \mbox{\hyperlink{Emotion_8h_ga90fb0b9d7b2c320f25118765ddcc8213ad104229a0d0ac128ce0b6fbb9c96aaa7}{EMOTION\_META\_INFO\_TRACK\_TITLE}}));}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}seek\ position:\ \%0.3f\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Emotion__Play_ga9beedba3ec525744c059d584c9bb1ddd}{emotion\_object\_position\_get}}(o));}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}play\ length:\ \%0.3f\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Emotion__Play_ga9b082b70fd1fba55a5fb0d9d72859888}{emotion\_object\_play\_length\_get}}(o));}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}is\ seekable:\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Emotion__Play_gae83146066bfc2eb13066571fad3e1fdd}{emotion\_object\_seekable\_get}}(o));}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Emotion__Video_gae454b8c2d733de79da8013d64b7a2384}{emotion\_object\_size\_get}}(o,\ \&w,\ \&h);}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}video\ geometry:\ \%dx\%d\(\backslash\)n"{}},\ w,\ h);}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}video\ width\ /\ height\ ratio:\ \%0.3f\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Emotion__Video_gaf1bc96bcdbba85bdf19e9b960c9e9f6c}{emotion\_object\_ratio\_get}}(o));}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_playback\_started\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ Efl\_Event\ *ev)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}>>>\ Emotion\ object\ started\ playback.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \_display\_info(ev-\/>object);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_playback\_finished\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ Efl\_Event\ *ev)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}>>>\ Emotion\ object\ finished\ playback.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \_display\_info(ev-\/>object);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_open\_done\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ Efl\_Event\ *ev)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}>>>\ Emotion\ object\ open\ done.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \_display\_info(ev-\/>object);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_position\_update\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ Efl\_Event\ *ev)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}>>>\ Emotion\ object\ first\ position\ update.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ efl\_event\_callback\_del(ev-\/>object,\ EFL\_CANVAS\_VIDEO\_EVENT\_POSITION\_CHANGE,\ \_position\_update\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \_display\_info(ev-\/>object);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_frame\_decode\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ Efl\_Event\ *ev)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}>>>\ Emotion\ object\ first\ frame\ decode.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ efl\_event\_callback\_del(ev-\/>object,\ EFL\_CANVAS\_VIDEO\_EVENT\_FRAME\_DECODE,\ \_frame\_decode\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \_display\_info(ev-\/>object);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_decode\_stop\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ Efl\_Event\ *ev)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}>>>\ Emotion\ object\ decode\ stop.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \_display\_info(ev-\/>object);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_frame\_resize\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ Efl\_Event\ *ev)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}>>>\ Emotion\ object\ frame\ resize.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \_display\_info(ev-\/>object);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{EFL\_CALLBACKS\_ARRAY\_DEFINE(emotion\_object\_example\_callbacks,}
\DoxyCodeLine{\ \ \ \ \ \ \ \{\ EFL\_CANVAS\_VIDEO\_EVENT\_PLAYBACK\_START,\ \_playback\_started\_cb\ \},}
\DoxyCodeLine{\ \ \ \ \ \ \ \{\ EFL\_CANVAS\_VIDEO\_EVENT\_PLAYBACK\_STOP,\ \_playback\_finished\_cb\ \},}
\DoxyCodeLine{\ \ \ \ \ \ \ \{\ EFL\_CANVAS\_VIDEO\_EVENT\_OPEN\_DONE,\ \_open\_done\_cb\ \},}
\DoxyCodeLine{\ \ \ \ \ \ \ \{\ EFL\_CANVAS\_VIDEO\_EVENT\_POSITION\_CHANGE,\ \_position\_update\_cb\ \},}
\DoxyCodeLine{\ \ \ \ \ \ \ \{\ EFL\_CANVAS\_VIDEO\_EVENT\_FRAME\_DECODE,\ \_frame\_decode\_cb\ \},}
\DoxyCodeLine{\ \ \ \ \ \ \ \{\ EFL\_CANVAS\_VIDEO\_EVENT\_PLAYBACK\_STOP,\ \_decode\_stop\_cb\ \},}
\DoxyCodeLine{\ \ \ \ \ \ \ \{\ EFL\_CANVAS\_VIDEO\_EVENT\_FRAME\_RESIZE,\ \_frame\_resize\_cb\ \});}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Ecore\_Evas\ *ee;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}}\ *e;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *bg,\ *em;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename\ =\ NULL;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *module\ =\ NULL;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (argc\ <\ 2)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}At\ least\ one\ argument\ is\ necessary.\ Usage:\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)t\%s\ <filename>\ [module\_name]\(\backslash\)n"{}},\ argv[0]);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ filename\ =\ argv[1];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (argc\ >=\ 3)}
\DoxyCodeLine{\ \ \ \ \ module\ =\ argv[2];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}())}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{return}\ EXIT\_FAILURE;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ this\ will\ give\ you\ a\ window\ with\ an\ Evas\ canvas\ under\ the\ first}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ engine\ available\ */}}
\DoxyCodeLine{\ \ \ ee\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_gaaa770b6f2f1395f9eeb0e50e26c3f933}{ecore\_evas\_new}}(NULL,\ 10,\ 10,\ WIDTH,\ HEIGHT,\ NULL);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!ee)}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ the\ canvas\ pointer,\ de\ facto\ */}}
\DoxyCodeLine{\ \ \ e\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga6f8d214cd55bc940d7cc62fecd8dbc06}{ecore\_evas\_get}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ adding\ a\ background\ to\ this\ example\ */}}
\DoxyCodeLine{\ \ \ bg\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(e);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga48f9cbae79a45e5f672dbe2076a0cf36}{evas\_object\_name\_set}}(bg,\ \textcolor{stringliteral}{"{}our\ dear\ rectangle"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(bg,\ 255,\ 255,\ 255,\ 255);\ \textcolor{comment}{/*\ white\ bg\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(bg,\ 0,\ 0);\ \textcolor{comment}{/*\ at\ canvas'\ origin\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg,\ WIDTH,\ HEIGHT);\ \textcolor{comment}{/*\ covers\ full\ canvas\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bg);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ Creating\ the\ emotion\ object\ */}}
\DoxyCodeLine{\ \ \ em\ =\ \mbox{\hyperlink{group__Emotion__Init_ga24f8978589d49e62ca8829f61fac83a9}{emotion\_object\_add}}(e);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ Try\ to\ load\ the\ specified\ module\ -\/\ NULL\ for\ auto-\/discover\ */}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!emotion\_object\_init(em,\ module))}
\DoxyCodeLine{\ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Emotion:\ \(\backslash\)"{}\%s\(\backslash\)"{}\ module\ could\ not\ be\ initialized.\(\backslash\)n"{}},\ module);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \_display\_info(em);}
\DoxyCodeLine{\ \ \ efl\_event\_callback\_array\_add(em,\ emotion\_object\_example\_callbacks(),\ NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{group__Emotion__Init_gaf0373828f33bd62aa6070f6c890f91a6}{emotion\_object\_file\_set}}(em,\ filename))}
\DoxyCodeLine{\ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Emotion:\ Could\ not\ load\ the\ file\ \(\backslash\)"{}\%s\(\backslash\)"{}\(\backslash\)n"{}},\ filename);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(em,\ 0,\ 0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(em,\ WIDTH,\ HEIGHT);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(em);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Emotion__Play_ga63c5faf9e23046ccb292027df2486cbb}{emotion\_object\_play\_set}}(em,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(ee);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{error:}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 