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


\begin{DoxyCodeInclude}
\textcolor{comment}{/*}
\textcolor{comment}{ Super-concise video player example using Edje/Emotion/Elementary.}
\textcolor{comment}{}
\textcolor{comment}{ This is all in Edje by means of type:EXTERNAL, you don't need any C}
\textcolor{comment}{ code other than emotion and edje installed with edje\_external}
\textcolor{comment}{ support enabled.}
\textcolor{comment}{}
\textcolor{comment}{ Compile: edje\_cc     external-emotion-elm.edc}
\textcolor{comment}{ Run....: edje\_player external-emotion-elm.edj}
\textcolor{comment}{}
\textcolor{comment}{ */}
collections \{
   group \{ name: \textcolor{stringliteral}{"main"};
      min: 350 200; \textcolor{comment}{/* set a min window size */}

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

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

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

         part \{ name: \textcolor{stringliteral}{"title"};
            type: TEXT;
            effect: SOFT\_SHADOW;
            description \{ state: \textcolor{stringliteral}{"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: \textcolor{stringliteral}{"Sans:style=Bold"};
                  align: 0.5 0.0;
                  size: 10;
                  min: 0 1;
                  text: \textcolor{stringliteral}{""};
               \}
            \}
            description \{ state: \textcolor{stringliteral}{"visible"} 0.0;
               inherit: \textcolor{stringliteral}{"default"} 0.0;
               color: 255 255 255 255;
               color3: 0 0 0 255;
            \}
         \}

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

         part \{ name: \textcolor{stringliteral}{"controls-bg"}; \textcolor{comment}{/* controls background as}
\textcolor{comment}{                                        semi-transparent black at bottom edge */}
            type: RECT;
            clip\_to: \textcolor{stringliteral}{"controls-clipper"};
            description \{ state: \textcolor{stringliteral}{"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: \textcolor{stringliteral}{"play"}; \textcolor{comment}{/* play button at bottom-left (relative}
\textcolor{comment}{                                to controls-bg) */}
            type: EXTERNAL;
            source: \textcolor{stringliteral}{"elm/button"};
            clip\_to: \textcolor{stringliteral}{"controls-clipper"};
            description \{ state: \textcolor{stringliteral}{"default"} 0.0;
               rel1 \{
                  relative: 0.0 0.0;
                  offset: 0 0;
                  to: \textcolor{stringliteral}{"controls-bg"};
               \}
               rel2 \{
                  relative: 0.0 1.0;
                  offset: 50 -1;
                  to: \textcolor{stringliteral}{"controls-bg"};
               \}
               params.string: \textcolor{stringliteral}{"icon"} \textcolor{stringliteral}{"apps"};
            \}
         \}

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

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

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

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

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

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

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

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

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

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