Chinese (People's Republic of China)  English  Français


Supinfo-Projects.com
Supinfo Students' projects



Projects
  Last project
  Top projects
  All projects

195 User's online
3168 Projects


My Supinfo-Projects

   Login
   Create account


Synopsis

   12 Hits
   Visitors Score : 16
    (3 Voter)
   0 Comments

   Read the article

Evaluate this article

20
18
16
14
12
10
8
6
4
2
0


Comment this article

Author :

Email :

Your comment :



 
2005 - Pérennisation
EFL: Write a Dvd player in 17 lines
[60 mn of reading - published 5/18/2005 5:37:58 PM - Target : Confirmé]

Author

mat_lamLamar MATHIEU
Student-Engineer Supinfo Caraïbes
SUPINFO graduate year  2006

   Write to the person
   All projects of the same author
   Mini-CV of the author

3 Emotion: write a Dvd player in 17 lines of code

3.1 EFL Installation

This article will not provide installation instructions. There are a lot of existing documentaion: http://get-e.org

3.2 The code

Instead of beginning with a traditional “Hello World”, why not write a Dvd player?! This is a Rasterman idea (the main developer of the EFL) to show off the power and the simplicity of Emotion.

 

 

#include “Evas.h”

#include “Ecore.h”

#include “Ecore_Evas.h”

#include “Emotion.h” //substitute the "" with braquets

 

int main(int argc, char **argv){

   Evas_Object *video;

   Ecore_Evas *ee;

   ecore_evas_init();

   ecore_evas_show(ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 800, 600));

   video = emotion_object_add(ecore_evas_get(ee));

   emotion_object_file_set(video, "dvd:/");

   emotion_object_play_set(video, 1);

   evas_object_resize(video, 800, 600);

   evas_object_show(video);

   ecore_main_loop_begin();

   ecore_evas_shutdown();

}

 

 To compile:

$ gcc my_dvd_player.c -o my_dvd_player \

         `emotion-config --cflags --libs`

 

3.2 Details

 

First, let’s talk about the inclusions. We need Evas, Ecore_Evas and Emotion:

 

#include “Evas.h”

#include “Ecore.h”

#include “Ecore_Evas.h”

#include “Emotion.h” //substitute with braquets

 

Thanks to Emotion, the video will be an Evas Object. We need an Ecore_Evas object which will allow us to easily create a window with an Evas canvas into it. The ecore_evas_init() function start the Ecore_Evas system.

 

Evas_Object *video;  //video object

Ecore_Evas *ee;      //Evas window

ecore_evas_init();

 

We create an 800x600 Evas window with Ecore_Evas. And we show it:

 

ecore_evas_show(ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 800, 600));

 

If we did not want to write an 17 lines Dvd player, we would have wrote this :

 

ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 800, 600);

ecore_evas_show(ee);

 This is more comprehensive. The ecore_evas_software_x11_new() function use the software_X11 backend to create the Evas canvas. We could have used the gl_X11 (OpenGl acceleration) or the fb (framebuffer).

 

 The evas_object_show() function ... shows the Ecore_Evas window. 

Now, we know how to create a X11 window with the EFL. We could have displayed a “Hello World” but we will display a Video:

 

 

video = emotion_object_add(ecore_evas_get(ee));

emotion_object_file_set(video, "dvd:/");

emotion_object_play_set(video, 1);

 

The emotion API is easy to understand. An Emotion object is an Evas object. We create it in our Evas canvas. The ecore_evas_get() returns the Evas canvas of our window.

 

The emotion_object_file_set() sets the file to play. Here, we set “dvd:/” wich will read the content of  /dev/dvd. We can choose any video file or stream. Emotion can read all files that Xine can read. Even Mp3!

 

The video starts by setting to 1 a boolean. Now, we just have to resize the video to the size of the window and then show it.

 

evas_object_resize(video, 800, 600);

evas_object_show(video);

 

 That’s all! We just have to begin the main loop. When the main loop ends, the Ecore_Evas system will be stopped.

 

ecore_main_loop_begin();

ecore_evas_shutdown();

 

dvd_player_start.jpeg

Figure 7. our tiny player can handle menu navigation!

 

 



Articles de la même catégorie

 Pages : Top


10 Hits
0 Comments
Z object Publishing Environment
[20 mn of reading - published 5/18/2005 5:12:45 PM - Target : Débutant]

More


11 Hits
0 Comments
Custom EJB security in JBoss
[20 mn of reading - published 5/18/2005 4:32:39 PM - Target : Expert]

More


8 Hits
0 Comments
PHP/MySQL : The duet of shock
[10 mn of reading - published 5/18/2005 3:57:32 PM - Target : Débutant]

More

Powered by Campus-Booster Technology
Conditions d'utilisation & Copyright | Respect de la vie privée
© Copyright 1965-2006 Supinfo Paris, Paris Academy of Computer Science
Supinfo, Ecole Supérieure d'Informatique et Paris Academy Of Computer Science are trade marks.
23, rue de Château LANDON - 75010 PARIS - Phone : +33 (0) 153359 700 Fax : +33 (0) 153359 701

Web site autided by :