DocumentTools[Components]
VideoPlayer
generate XML for a VideoPlayer Component
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
VideoPlayer( filenm, opts )
filenm
-
(optional) string; video filename, as a string
opts
(optional) ; one or more keyword options as described below
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.
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.
with⁡DocumentTools:
with⁡DocumentTools:-Components:
with⁡DocumentTools:-Layout:
Executing the VideoPlayer command produces a function call.
S≔VideoPlayer⁡identity=VideoPlayer0
S ≔ _XML_EC-VideoPlayer⁡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
By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡S:
That XML representation of a worksheet can be inserted directly.
InsertContent⁡xml:
f≔cat⁡kernelopts⁡datadir,/videos/videoplayer.mp4:
V≔VideoPlayer⁡f,identity=VideoPlayer0,defaultdimensions=false,height=300,hidecontrols,showcontrols:
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡V:
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.
lookup≔InsertContent⁡xml,output=table
lookup ≔ tableVideoPlayer0=VideoPlayer1
lookupVideoPlayer0
VideoPlayer1
GetProperty⁡lookupVideoPlayer0,loop
false
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≔cat⁡kernelopts⁡datadir,/videos/world.mp4:
W≔VideoPlayer⁡g,identity=VideoPlayer0,height=133,defaultdimensions=false,action=1.25,update(':-TextArea0',1);,9,update(':-TextArea0',2);:
T≔TextArea⁡identity=TextArea0,width=36,depth=4,wrap,showborders=false:
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:
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡W,Group⁡Input⁡Textfield⁡T:
Now we insert the components. When played the action code will execute when the play reaches the designated positions.
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.
message1≔Maple: The Essential Tool for Mathematics and Modeling:message2≔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.:
actionstring1≔sprintf⁡DocumentTools:-SetProperty('%a', value, %a);,TextArea1,message1:
actionstring2≔sprintf⁡DocumentTools:-SetProperty('%a', value, %a);,TextArea1,message2:
W≔VideoPlayer⁡g,identity=VideoPlayer0,height=133,defaultdimensions=false,action=1.25,actionstring1,9,actionstring2:T≔TextArea⁡identity=TextArea1,width=36,depth=4,wrap,showborders=false:
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡W,Group⁡Input⁡Textfield⁡T:InsertContent⁡xml:
The DocumentTools[Components][VideoPlayer] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
See Also
Component Code
Component Constructors
DocumentTools
Embedded Components
XMLTools
Download Help Document