Executing the VideoPlayer command produces a function call.
By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.
That XML representation of a worksheet can be inserted directly.
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.
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.
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:
|
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.