Emotion
Date
2003 (created)

Table of Contents

Introduction

A media object library for Evas and Ecore.

Emotion is a library that allows playing audio and video files.

It is integrated into Ecore through its mainloop, and is transparent to the user of the library how the decoding of audio and video is being done. Once the objects are created, the user can set callbacks to the specific events and set options to this object, all in the main loop (no threads are needed).

Emotion is also integrated with Evas. The emotion object returned by emotion_object_add() is an Evas smart object, so it can be manipulated with default Evas object functions. Callbacks can be added to the signals emitted by this object with evas_object_smart_callback_add().

How does Emotion work?

The Emotion library uses Evas smart objects to allow you to manipulate the created object as any other Evas object, and to connect to its signals, handling them when needed. It's also possible to swallow Emotion objects inside Edje themes, and expect it to behave as a normal image or rectangle when regarding to its dimensions.

How to compile

Emotion is a library your application links to. The procedure for this is very simple. You simply have to compile your application with the appropriate compiler flags that the pkg-config script outputs. For example:

Compiling C or C++ files into object files:

gcc -c -o main.o main.c `pkg-config --cflags emotion`

Linking object files into a binary executable:

gcc -o my_application main.o `pkg-config --libs emotion`

See pkgconfig

Next Steps

After you understood what Emotion is and installed it in your system you should proceed understanding the programming interface. We'd recommend you to take a while to learn Ecore and Evas to get started.

Recommended reading:

Introductory Example

//Compile with:
// gcc -o emotion_basic_example emotion_basic_example.c `pkg-config --libs --cflags emotion evas ecore ecore-evas eo`
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif
#include <Eo.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Evas.h>
#include <Emotion.h>
#include <stdio.h>
#define WIDTH (320)
#define HEIGHT (240)
static void
_playback_started_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
printf("Emotion object started playback.\n");
}
int
main(int argc, const char *argv[])
{
Ecore_Evas *ee;
Evas *e;
Evas_Object *bg, *em;
const char *filename = NULL;
if (argc < 2)
{
printf("One argument is necessary. Usage:\n");
printf("\t%s <filename>\n", argv[0]);
}
filename = argv[1];
return EXIT_FAILURE;
/* this will give you a window with an Evas canvas under the first
* engine available */
ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
if (!ee)
goto error;
/* the canvas pointer, de facto */
e = ecore_evas_get(ee);
/* adding a background to this example */
evas_object_name_set(bg, "our dear rectangle");
evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
evas_object_move(bg, 0, 0); /* at canvas' origin */
evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
/* Creating the emotion object */
emotion_object_init(em, NULL);
efl_event_callback_add
(em, EFL_CANVAS_VIDEO_EVENT_PLAYBACK_START, _playback_started_cb, NULL);
emotion_object_file_set(em, filename);
evas_object_move(em, 0, 0);
evas_object_resize(em, WIDTH, HEIGHT);
return 0;
error:
fprintf(stderr, "error: Requires at least one Evas engine built and linked"
" to ecore-evas for this example to run properly.\n");
return -1;
}

More examples can be found at Emotion Examples.