Emotion

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files
- Examples

Emotion

Date
  2003 (created)

# Table of Contents

- Introduction
- How does Emotion work?
- How to compile
- Next Steps
- Introductory Example

# Introduction

A media object library for Evas and Ecore.

Emotion is a library that allows playing audio and video files, using one of its backends (gstreamer, xine or generic shm player).

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:

- Creation and initialization functions to initialize the library.
- Video control functions to control video parameters.
- Audio control functions to control audio parameters.
- Play control functions to control playback.
- API available for accessing webcam to show cameras.
- API available for manipulating Emotion object. for general programming interface.

# Introductory Example

//Compile with:
// gcc -o emotion_basic_example emotion_basic_example.c `pkg-config --libs --cflags emotion evas ecore ecore-evas eo`
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#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 Eina_Bool
_playback_started_cb(void *data EINA_UNUSED,
Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{
printf("Emotion object started playback.\n");
return EINA_TRUE;
}
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];
if (!ecore_evas_init())
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;
ecore_evas_show(ee);
/* the canvas pointer, de facto */
e = ecore_evas_get(ee);
/* adding a background to this example */
bg = evas_object_rectangle_add(e);
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 */
evas_object_show(bg);
/* Creating the emotion object */
em = emotion_object_add(e);
emotion_object_init(em, NULL);
eo_do(em, eo_event_callback_add
(EMOTION_OBJECT_EVENT_PLAYBACK_STARTED, _playback_started_cb, NULL));
emotion_object_file_set(em, filename);
evas_object_move(em, 0, 0);
evas_object_resize(em, WIDTH, HEIGHT);
evas_object_show(em);
emotion_object_play_set(em, EINA_TRUE);
ecore_main_loop_begin();
ecore_evas_free(ee);
ecore_evas_shutdown();
return 0;
error:
fprintf(stderr, "you got to have at least one evas engine built and linked"
" up to ecore-evas for this example to run properly.\n");
ecore_evas_shutdown();
return -1;
}

More examples can be found at Emotion Examples.