\hypertarget{external_emotion_elm_8edc-example}{}\section{external\+\_\+emotion\+\_\+elm.\+edc}
Super-\/concise video player example using Edje/\+Emotion/\+Elementary.


\begin{DoxyCodeInclude}
/*
 Super-concise video player example using Edje/Emotion/Elementary.

 This is all in Edje by means of type:EXTERNAL, you don't need any C
 code other than emotion and edje installed with edje\_external
 support enabled.

 Compile: edje\_cc     external-emotion-elm.edc
 Run....: edje\_player external-emotion-elm.edj

 */
collections \{
   group \{ name: "main";
      min: 350 200; /* set a min window size */

      externals \{ /* declare the modules you want to load */
         external: "emotion"; /* video player engine */
         external: "elm"; /* toolkit/widgets */
      \}

      parts \{
         part \{ name: "bg"; /* dark gray rectangle as background */
            type: RECT;
            description \{ state: "default" 0.0;
               color: 64 64 64 255;
            \}
         \}

         part \{ name: "video"; /* video object */
            type: EXTERNAL;
            source: "emotion";
            description \{ state: "default" 0.0;
               params \{
                  /* explicitly select the emotion engine
                   * ['xine', 'gstreamer' or 'vlc']
                   * or comment the line to autoselect the engine */
                  // choice: "engine" "gstreamer";
               \}
            \}
         \}

         part \{ name: "title";
            type: TEXT;
            effect: SOFT\_SHADOW;
            description \{ state: "default" 0.0;
               color: 255 255 255 0;
               color3: 0 0 0 0;
               align: 0.5 0.0;
               rel1 \{
                  relative: 0.0 0.0;
                  offset: 10 2;
               \}
               rel2 \{
                  relative: 1.0 0.0;
                  offset: -11 10;
               \}
               text \{
                  font: "Sans:style=Bold";
                  align: 0.5 0.0;
                  size: 10;
                  min: 0 1;
                  text: "";
               \}
            \}
            description \{ state: "visible" 0.0;
               inherit: "default" 0.0;
               color: 255 255 255 255;
               color3: 0 0 0 255;
            \}
         \}

         part \{ name: "controls-clipper"; /* clipper to control visibility */
            type: RECT;
            description \{ state: "default" 0.0;
               color: 255 255 255 32;
            \}
            description \{ state: "visible" 0.0;
               color: 255 255 255 255;
            \}
         \}

         part \{ name: "controls-bg"; /* controls background as
                                        semi-transparent black at bottom edge */
            type: RECT;
            clip\_to: "controls-clipper";
            description \{ state: "default" 0.0;
               color: 0 0 0 128;
               rel1 \{
                  relative: 0.0 1.0;
                  offset: 0 -40;
               \}
               rel2 \{
                  relative: 1.0 1.0;
                  offset: -1 -1;
               \}
            \}
         \}

         part \{ name: "play"; /* play button at bottom-left (relative
                                to controls-bg) */
            type: EXTERNAL;
            source: "elm/button";
            clip\_to: "controls-clipper";
            description \{ state: "default" 0.0;
               rel1 \{
                  relative: 0.0 0.0;
                  offset: 0 0;
                  to: "controls-bg";
               \}
               rel2 \{
                  relative: 0.0 1.0;
                  offset: 50 -1;
                  to: "controls-bg";
               \}
               params.string: "icon" "apps";
            \}
         \}

         part \{ name: "open"; /* open file button next to play button */
            type: EXTERNAL;
            source: "elm/fileselector\_button";
            clip\_to: "controls-clipper";
            description \{ state: "default" 0.0;
               rel1 \{
                  relative: 0.0 0.0;
                  offset: 52 0;
                  to: "controls-bg";
               \}
               rel2 \{
                  relative: 0.0 1.0;
                  offset: 102 -1;
                  to: "controls-bg";
               \}
               params.string: "icon" "folder";
            \}
         \}

         part \{ name: "time"; /* time/progress */
            type: EXTERNAL;
            source: "elm/slider";
            clip\_to: "controls-clipper";
            description \{ state: "default" 0.0;
               rel1 \{
                  relative: 0.0 0.0;
                  offset: 104 0;
                  to: "controls-bg";
               \}
               rel2 \{
                  relative: 1.0 1.0;
                  offset: -1 -1;
                  to: "controls-bg";
               \}
            \}
         \}

         part \{ name: "controls-eventarea"; /* event area so we catch mouse in
                                               and out, repeat events so
                                               buttons get them */
            type: RECT;
            repeat\_events: 1;
            description \{
               state: "default" 0.0;
               color: 255 255 255 0; /* fully transparent as we don't
                                        need any visual feedback */
               rel1.to: "controls-bg";
               rel2.to: "controls-bg";
            \}
         \}

         programs \{
            /* animated 0.2 linear fade in/out if mouse is over controls */
            program \{ signal: "mouse,in";
               source: "controls-eventarea";
               action: STATE\_SET "visible" 0.0;
               transition: LINEAR 0.2;
               target: "controls-clipper";
               target: "title";
            \}
            program \{ signal: "mouse,out";
               source: "controls-eventarea";
               action: STATE\_SET "default" 0.0;
               transition: LINEAR 0.2;
               target: "controls-clipper";
               target: "title";
            \}

            /* toggle video playing state when play is clicked */
            program \{ name: "toggle-play-video";
               signal: "clicked";
               source: "play";
               script \{
                  new v = external\_param\_get\_bool(PART:"video", "play");
                  external\_param\_set\_bool(PART:"video", "play", !v);
               \}
            \}

            /* whenever file is chosen, set and play it */
            program \{ signal: "file,chosen";
               source: "open";
               action: PARAM\_COPY "open" "path" "video" "file";
               after: "play-video";
               after: "set-title";
            \}
            program \{ name: "play-video";
               action: PARAM\_SET "video" "play" "1";
            \}
            program \{ name: "set-title";
               action: PARAM\_COPY "open" "path" "title" "text";
            \}

            /* if position changes, set slider (time) */
            program \{ signal: "position\_update";
               source: "video";
               script \{
                  new Float:p, Float:len;

                  p = external\_param\_get\_float(PART:"video", "position");
                  len = external\_param\_get\_float(PART:"video", "play\_length");
                  if (len > 0.0)
                     external\_param\_set\_float(PART:"time", "value", p / len);
               \}
            \}

            /* if slider (time) changes, set the position (seek) */
            program \{ signal: "changed";
               source: "time";
               script \{
                  new Float:v, Float:len;

                  v = external\_param\_get\_float(PART:"time", "value");
                  len = external\_param\_get\_float(PART:"video", "play\_length");
                  if (len > 0.0)
                     external\_param\_set\_float(PART:"video", "position", v * len);
               \}
            \}
         \}
      \}
   \}
\}
\end{DoxyCodeInclude}
 