Video Player Component - Maple Help

Home : Support : Online Help : Programming : Document Tools : Components : Video Player Component

DocumentTools[Components]

 VideoPlayer
 generate XML for a VideoPlayer Component

 Calling Sequence VideoPlayer( filenm, opts )

Parameters

 filenm - (optional) string; video filename, as a string opts - (optional) ; one or more keyword options as described below

Options

 • action : list([And(numeric,nonnegative),string]):= [] ; A list of lists. Each entry is a list containing a nonnegative time position and a string of Maple Notation Action code which will execute when the player reaches that position.
 • defaultdimensions : truefalse:=true ; Indicates whether the default player dimensions should be used.
 • height : posint:=400 ; The height in pixels of the component, which is not used if the default dimensions are enabled.
 • hidecontrols : truefalse:=false ; Indicates whether the player controls are hidden.
 • identity : {name,string}; The reference name of the component.
 • loop : truefalse:=false ; Indicates whether the playback stops upon reaching the stopping time, or loops back to the starting time.
 • showcontrols : truefalse:=true ; Indicates whether the player controls are shown when the mouse pointer hovers over the component.
 • startindex : nonnegint:=0 ; The starting time, representing seconds.
 • stopindex : nonnegint:=0 ; The stopping time, representing seconds.
 • width : posint:=600 ; The width in pixels of the component, which is not used if the default dimensions are enabled.

Description

 • The VideoPlayer command in the Component Constructors package returns an XML function call which represents a VideoPlayer Component.
 • The generated XML may be used with the results of commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document may be inserted into the current document using the InsertContent command.

Examples

 > $\mathrm{with}\left(\mathrm{DocumentTools}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Components}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Layout}\right):$

Executing the VideoPlayer command produces a function call.

 > $S≔\mathrm{VideoPlayer}\left(\mathrm{identity}="VideoPlayer0"\right)$
 ${S}{≔}{\mathrm{_XML_EC-VideoPlayer}}{}\left({"id"}{=}{"VideoPlayer0"}{,}{"file"}{=}{""}{,}{"default-dimensions"}{=}{"true"}{,}{"pixel-width"}{=}{"600"}{,}{"pixel-height"}{=}{"400"}{,}{"loop"}{=}{"false"}{,}{"start-index"}{=}{"0"}{,}{"stop-index"}{=}{"0"}{,}{"hide-controls"}{=}{"false"}{,}{"show-controls"}{=}{"false"}\right)$ (1)

By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.

 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

That XML representation of a worksheet can be inserted directly.

 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

 > $f≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/videos/videoplayer.mp4"\right):$
 > $V≔\mathrm{VideoPlayer}\left(f,\mathrm{identity}="VideoPlayer0",\mathrm{defaultdimensions}=\mathrm{false},\mathrm{height}=300,\mathrm{hidecontrols},\mathrm{showcontrols}\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(V\right)\right)\right)\right):$

The previous example's call to the InsertContent command inserted a component with identity "VideoPlayer0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "VideoPlayer0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.

The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.

 > $\mathrm{lookup}≔\mathrm{InsertContent}\left(\mathrm{xml},\mathrm{output}=\mathrm{table}\right)$
 ${\mathrm{lookup}}{≔}{\mathrm{table}}\left(\left[{"VideoPlayer0"}{=}{"VideoPlayer1"}\right]\right)$ (2)

 > $\mathrm{lookup}\left["VideoPlayer0"\right]$
 ${"VideoPlayer1"}$ (3)
 > $\mathrm{GetProperty}\left(\mathrm{lookup}\left["VideoPlayer0"\right],\mathrm{loop}\right)$
 ${\mathrm{false}}$ (4)

The following two examples make use of action code for a VideoPlayer component to update the content of a TextArea component.

The next example requires the update procedure to be defined in the session for the actions to function.

 > $g≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/videos/world.mp4"\right):$
 > $W≔\mathrm{VideoPlayer}\left(g,\mathrm{identity}="VideoPlayer0",\mathrm{height}=133,\mathrm{defaultdimensions}=\mathrm{false},\mathrm{action}=\left[\left[1.25,"update\left(\text{'}:-TextArea0\text{'},1\right);"\right],\left[9,"update\left(\text{'}:-TextArea0\text{'},2\right);"\right]\right]\right):$
 > $T≔\mathrm{TextArea}\left(\mathrm{identity}="TextArea0",\mathrm{width}=36,\mathrm{depth}=4,\mathrm{wrap},\mathrm{showborders}=\mathrm{false}\right):$

The action code strings in the VideoComponent represented by W call a procedure update which is defined below.

 > update := proc(comp, x)     local text := "";     if x = 1 then         text := "Maple: The Essential Tool for Mathematics and Modeling";     elif x = 2 then         text := "The result of over 30 years of cutting-edge research and development, Maple combines the world's most powerful mathematical computation engine with an intuitive, clickable user interface.";     end if;     DocumentTools:-SetProperty(comp, value, text ); end proc:
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(W\right)\right)\right),\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(T\right)\right)\right)\right):$

Now we insert the components. When played the action code will execute when the play reaches the designated positions.

 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

Note that when the mouse cursor hovers over the progress bar of the VideoPlayer Component the action markers are revealed. The action code can be inspected, edited, or removed as a right-click menu choice of the action markers in the progress bar.

The next example uses action code which is self-contained, and unlike the previous example does not require a procedure defined in the session.

 > $g≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/videos/world.mp4"\right):$
 > $\mathrm{message1}≔"Maple: The Essential Tool for Mathematics and Modeling":$$\mathrm{message2}≔"The result of over 30 years of cutting-edge research and development, Maple combines the world\text{'}s most powerful mathematical computation engine with an intuitive, clickable user interface.":$
 > $\mathrm{actionstring1}≔\mathrm{sprintf}\left("DocumentTools:-SetProperty\left(\text{'}%a\text{'}, value, %a\right);",\mathrm{TextArea1},\mathrm{message1}\right):$
 > $\mathrm{actionstring2}≔\mathrm{sprintf}\left("DocumentTools:-SetProperty\left(\text{'}%a\text{'}, value, %a\right);",\mathrm{TextArea1},\mathrm{message2}\right):$
 > $W≔\mathrm{VideoPlayer}\left(g,\mathrm{identity}="VideoPlayer0",\mathrm{height}=133,\mathrm{defaultdimensions}=\mathrm{false},\mathrm{action}=\left[\left[1.25,\mathrm{actionstring1}\right],\left[9,\mathrm{actionstring2}\right]\right]\right):$$T≔\mathrm{TextArea}\left(\mathrm{identity}="TextArea1",\mathrm{width}=36,\mathrm{depth}=4,\mathrm{wrap},\mathrm{showborders}=\mathrm{false}\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(W\right)\right)\right),\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(T\right)\right)\right)\right):$$\mathrm{InsertContent}\left(\mathrm{xml}\right):$

 > 

Compatibility

 • The DocumentTools[Components][VideoPlayer] command was introduced in Maple 2015.