Mozilla Skin*/?>

CL2 Project JS Reference

From ConduitWiki

Conduit Live 2 has an extensive API for controlling node widgets.

Some node widgets are explicitly scripting-oriented (like Script Widget); others have a scripting interface behind the scenes.

For example, the Movie/Image Source node widget can be controlled using scripts. There are two ways to accomplish this:

  • Use the command line to manipulate the node widget directly through scripts.
  • Write an onRender script for the node widget. This function will get called each time the node widget renders its output.

The Script Editor is the interface for both of these tasks. It's found in the Tools menu.

To control the Movie/Image Source widget directly, try the following simple test:

  • Load a video file in the default source node widget. (Its name should be "source"; if not, you can rename it by entering that name in its top-right corner text box.)
  • Play the project (Output menu > Play).
  • Open the Script Editor and type the following line.

To create an onRender script, make sure "source" is selected in the pop-up menu at the top of the Script Editor, then enter the following in the Script text box and press Save:

this.onRender = function() {
   sys.trace("position: "+this.playPosition);

Now, as the node renders, it will write out its current position (in seconds) to the Trace output in the Script Editor.

Finding out object properties

An easy way to explore the JavaScript APIs within Conduit Live 2 is to use the Script Editor's command line. With the Object.keys() function, you can print out all the methods and properties available on any particular object.

Open the Script Editor (Tools menu > Show Project Script Editor), then enter the following on the command line, and press Enter:


The trace output view will display the result value of the keys call, which is an array and looks something like this:


To find out whether a key is actually a property or a function that can be called, use the following: