Disclaimer: Please keep in mind that this is an OpenTok Labs project which means that it's not officially supported by TokBox.
The OpenTok Accelerator Annotation provides functionality you can add to your OpenTok applications that enables users to have the ability to annotate on a local or remote screen. This section shows you how to prepare and use the OpenTok Annotations Accelerator Pack as part of an application.
$ npm install --save opentok-annotation
If using browserify or webpack:
const annotation = ;
Otherwise, include the accelerator pack in your html:
. . . and it will be available in global scope as
Click here for a list of all OpenTok accelerator packs.
Explore the code
options fields are used in the
|Set the OpenTok session (object).||
|Set the Common layer API (object) - Automatically set if using Core.||
|Set the callback to receive the image data on screen capture (function).||
To initialize the accelerator pack:
var annotation = options;
Once initialized, the following methods are available:
Creates an external window (if required) and links the annotation toolbar to the session. An external window is ONLY required if sharing the current browser window.
@param Object session@param Object options@param Boolean optionsscreensharing - Using an external window@param Array optionsitems - Custom set of tools@param Array optionscolors - Custom color palette@returns Promise < Resolve: undefined | Object Reference to external annotation window >
Create and link a canvas to the toolbar and session. See notes about resizing the canvas below
@param Object pubSub - Either the or@param Object container - The parent container for the canvas element@param Object options@param Object optionsexternalWindow - Reference to the an external annotation window publisher only@param Object optionsabsoluteParent - Reference element for resize if other than container
Trigger a manual resize of the canvas.
Add a subscriber's video to the external annotation window.
@param Object stream - The subscriber stream object
End annotation, clean up the toolbar and canvas(es)
AnnotationAccPack triggers the following events via the common layer:
||Annotation linked to session and toolbar created.|
||Annotation canvas has been linked to the toolbar.|
||The annotation canvas has been resized.|
||The external annotation window has been closed.|
||Annotation has ended. Toolbar and canvases have been cleaned up.|
If using the common layer, you can subscribe to these events by calling
_accPack and providing a callback function:
If using the Accelerator Core you can subscribe to these events by calling
otCore and providing a callback function:
Best Practices for Resizing the Canvas
linkCanvas method refers to a parent DOM element called the
absoluteParent. When resizing the canvas, the annotation accelerator pack also resizes the canvas container element using inline properties. Because of this, we need another element to reference for dimensions. For this, we use the