For those interested in learning Edje and wonder what is the so called
"external" support, here is a small demo video player that I wrote
entirely in Emotion. You need the last Emotion to get the position in
slider.

PS: I'm not in the mood for wiki, if you are please add it there somewhere :-)


/*
  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     emotion-elementary-externals.edc
  Run....: edje_player emotion-elementary-externals.edj

 */
collections {
   group { name: "main";

      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;
            }
         }

         part { name: "title";
            type: TEXT;
            effect: SOFT_SHADOW;
            description { state: "default" 0.0;
               color: 255 255 255 255;
               color3: 0 0 0 255;
               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: "";
               }
            }
         }

         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";
            }
            program { signal: "mouse,out";
               source: "controls-eventarea";
               action: STATE_SET "default" 0.0;
               transition: LINEAR 0.2;
               target: "controls-clipper";
            }

            /* 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);
               }
            }
         }
      }
   }
}


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to