This example shows how to setup a simple Emotion object, make it start playing and register a callback that tells when the playback started.
See the full code here.
We start this example by including some header files that will be necessary to work with Emotion, and to display some debug messages:
Then a callback will be declared, to be called when the object starts its playback:
Some basic setup of our canvas, window and background is necessary before displaying our object on it. This setup also includes reading the file to be opened from the program's argument list. Since this is not directly related to Emotion itself, we are just displaying the code for this without an explanation for it:
Finally, we start the Emotion part. First we have to create the object in this canvas, and initialize it:
Notice that we didn't specify which module will be used, so emotion will use the first module found. There's no guarantee of the order that the modules will be found, so if you need to use one of them specifically, please be explicit in the second argument of the function emotion_object_init().
Now the callback can be registered to this object. It's a normal Evas smart object callback, so we add it with evas_object_smart_callback_add():
The object itself is ready for use, but we need to load a file to it. This is done by the following function:
This object can play audio or video files. For the latter, the image must be displayed in our canvas, and that's why we need to add the object to the canvas. So, like any other Evas object in the canvas, we have to specify its position and size, and explicitly set its visibility. These are the position and dimension where the video will be displayed:
Since the basic steps were done, we can now start playing our file. For this, we can just call the basic playback control function, and then we can go to the main loop and watch the audio/video playing:
The rest of the code doesn't contain anything special:
This code just free the canvas, shutdown the library, and has an entry point for exiting on error.