Actionscript 3 / External Interface API:

 

This allows a client developer to place actionscript inside of a Flash 9 animation, or javascript/vbscript on a webpage, that can interface with CoSolvent Player to provide a basic level of control.

 

The addEventListener and addPropertyChangeListener methods support the following event and property names:

Events:
  • EVENT_ACTIVATED (indicates the timeline is ready for playback)
  • EVENT_PAUSED
  • EVENT_STARTED
  • EVENT_BUFFERING
  • EVENT_RESUME
  • EVENT_DEACTIVATED
  • EVENT_TIME_UPDATE (natural progression of time)
  • EVENT_CLIENT_TIME_UPDATE (time update triggered by client)
  • EVENT_ITEM_ACTIVATED (when a vitem is activated, provides object {itemId: <itemId>, layerName: "<layerName>", activated: true|false})
  • EVENT_ITEM_DEACTIVATED (when a vitem is deactivated, provides object {itemId: <itemId>, layerName: "<layerName>", activated: true|false})
Properties:
  • currentTime
  • totalPlaybackTime
Actions:

Special actions may be registered by name and added to the timeline to be performed at particular points in time. See actions.

Events and actions may be registered once csp_callbacksRegistered has been received from the player.

For actionscript 3, a property implementing the api is attached to the root timeline of each avm2 asset on the main timeline. The following functions are accessed through that property (the property is called csplayer), or through javascript/vbscript on the flash object itself (if using ExternalInterface, prepend csp_ to each function call):

 

/**
* Start the timeline playback if it is not already started.
*/
function play() : void;

/**
* Pause timeline playback if it is not already paused.
*/
function pause() : void;

/**
* Read-only property, true if playback is ongoing, false otherwise
*/
function get isPlaying() : Boolean;

/**
* Read-only property, current position of the virtual timeline in milliseconds
*/
function get currentTime() : int;

/**
* Read-only property, the current total virtual timeline length in milliseconds
*/
function get totalPlaybackTime() : int;

/**
* Seek to a time relative to the entire virtual timeline.
* @param time - global time in milliseconds
*/
function gotoTime(time : int) : void;

/**
* Seek ahead from the current time.
* @param time - time in milliseconds
*/
function seekAhead(time : int) : void;

/**
* Seek back from the current time.
* @param time - time in milliseconds.
*/
function seekBack(time : int) : void;

/**
* Seek to a specific frame within a particular clip.
* Note: for this to work, the clip you refer to must support seek by frame (i.e. it is an swf)
* @param clip - the video layer index, zero based
* @param frame - frame within the referenced clip
*/
function gotoClipFrame(clip : int, frame : int) : void;

/**
* Control the visibility of the script pane.
* @param visible - true if the script should be visible, false otherwise
*/
function setScriptVisible(visible : Boolean) : void;

/**
* Enable/disable the player control bar.
* @param enabled - if true, the control bar will be enabled, false will disable
*/
function setControlsEnabled(enabled : Boolean) : void;

/**
* Seek to the start of the next video in the video layer.
* @param andPlay
*/
function gotoNextVideo(andPlay : Boolean) : void;

/**
* Seek to the start of the previous video in the video layer.
* @param andPlay
*/
function gotoPrevVideo(andPlay : Boolean) : void;

/**
* Play from start until end and then jumpTo.
* @param start either {clip:<clipIndex>,time:<milliseconds>} or {clip:<clipIndex>,frame:<frame number>}
* @param end ""
* @param jumpTo ""
*/
function reviewSegment(start:Object, end:Object, jumpTo:Object):void;

/**
* Return the 0-based index of the currently active clip in the video layer.
* @return a 0-based index as a Number
*/
function getCurrentClipIndex():Number;

/**
* Set a timeline marker with a name millisecond time pair
* @param name - unique marker name
* @param time - milllisecond time to associate with the marker
*/
function setMarker(name:String, time:int) : void;

/**
* Get the time value associated with a marker
* @param name - name of the marker
* @return a millisecond time value associated with the marker, or -1 if none exists
*/
function getMarkerTime(name:String) : int;

/**
* Seek directly to the time associated with a particular marker.
* @param name - name of the marker
*/
function gotoMarker(name:String) : void;

/**
* Adds an action callback to be associated with a time on the virtual timeline.  
* @param name the name of the action to perform
* @param time the global virtual timeline value in milliseconds
* @param args any arguments required for the action
* @param tolerance the tolerance window for the action to trigger (action will only trigger once)  
*/
function addAction(name:String, time:Number, args:Array = null, tolerance:Number = 100) : void;
  
/**
* Register a new action by name.   
* @param name a unique name for the action
* @param callback the callback that performs the action
*/
function registerAction(name:String, callback:*) : void;

/**
* Add an external listener to the named timeline event
* @param event - the name of the event
* @param callback - the name of an external function or an as3 function
*/
function addEventListener(event:String, callback:*):void;

/**
* Remove a listener from an event
* @param event - the name of the event
* @param callback - the name of an external function or an as3 function associated with the event
*/
function removeEventListener(event:String, callback:*):void;

/**
* Add an external listener to be notified when a certain property changes
* @param property - the name of the property
* @param callback - the name of an external function or an as3 function
*/
function addPropertyChangeListener(property:String, callback:*):void;

/**
* Remove a property change listener
* @param property - the name of the property
* @param callback - the name of an external function or an as3 function associated with the property
*/
function removePropertyChangeListener(property:String, callback:*):void;