2.0.59 • Published 6 years ago

opentok-annotation v2.0.59

Weekly downloads
1,648
License
MIT
Repository
github
Last release
6 years ago

logo

Accelerator Annotation for JavaScript

Build Status GitHub release license MIT npm

Quick start

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.

Install

$ npm install --save opentok-annotation

If using browserify or webpack:

const annotation = require('opentok-annotation');

Otherwise, include the accelerator pack in your html:

<script src="../your/path/to/opentok-annotation.js"></script>

. . . and it will be available in global scope as AnnotationAccPack


Click here for a list of all OpenTok accelerator packs.

Explore the code

The following options fields are used in the AnnotationAccPack constructor:

FeatureFieldRequired
Set the OpenTok session (object).sessiontrue
Set the Common layer API (object) - Automatically set if using Core.accPackfalse
Set the callback to receive the image data on screen capture (function).onScreenCapturefalse

To initialize the accelerator pack:

var annotation = new annotationAccPack(options);

Once initialized, the following methods are available:

start

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} [options.screensharing] - Using an external window
@param {Array} [options.items] - Custom set of tools
@param {Array} [options.colors] - Custom color palette
@returns {Promise} < Resolve: undefined | {Object} Reference to external annotation window >

linkCanvas

Create and link a canvas to the toolbar and session. See notes about resizing the canvas below

@param {Object} pubSub - Either the publisher(sharing) or subscriber(viewing)
@param {Object} container - The parent container for the canvas element
@param {Object} options
@param {Object} [options.externalWindow] - Reference to the an external annotation window (publisher only)
@param {Object} [options.absoluteParent] - Reference element for resize if other than container

resizeCanvas

Trigger a manual resize of the canvas.

addSubscriberToExternalWindow

Add a subscriber's video to the external annotation window.

@param {Object} stream - The subscriber stream object

end

End annotation, clean up the toolbar and canvas(es)


The AnnotationAccPack triggers the following events via the common layer:

EventDescription
startAnnotationAnnotation linked to session and toolbar created.
linkAnnotationAnnotation canvas has been linked to the toolbar.
resizeCanvasThe annotation canvas has been resized.
annotationWindowClosed (screen sharing only)The external annotation window has been closed.
endAnnotationAnnotation has ended. Toolbar and canvases have been cleaned up.

If using the common layer, you can subscribe to these events by calling registerEventListener on _accPack and providing a callback function:

accPack.registerEventListener('eventName', callback);

If using the Accelerator Core you can subscribe to these events by calling on on otCore and providing a callback function:

otCore.on('eventName', callback)

Best Practices for Resizing the Canvas

The 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 absoluteParent.

Multiparty video communication sample app using the Screensharing and Accelerator Annotation with best-practices for Javascript here.

2.0.59

6 years ago

2.0.58

6 years ago

2.0.57

6 years ago

2.0.56

6 years ago

2.0.55

7 years ago

2.0.54

7 years ago

2.0.53

7 years ago

2.0.52

7 years ago

2.0.51

7 years ago

2.0.50

7 years ago

2.0.49

7 years ago

2.0.48

7 years ago

2.0.47

7 years ago

2.0.46

7 years ago

2.0.45

7 years ago

2.0.44

7 years ago

2.0.43

7 years ago

2.0.42

7 years ago

2.0.41

7 years ago

2.0.40

7 years ago

2.0.39

7 years ago

2.0.38

7 years ago

2.0.37

7 years ago

2.0.36

7 years ago

2.0.35

7 years ago

2.0.34

7 years ago

2.0.33

7 years ago

2.0.32

7 years ago

2.0.31

7 years ago

2.0.30

7 years ago

2.0.29

7 years ago

2.0.28

7 years ago

2.0.27

7 years ago

2.0.25

7 years ago

2.0.24

7 years ago

2.0.22

7 years ago

2.0.21

8 years ago

2.0.20

8 years ago

2.0.19

8 years ago

2.0.17

8 years ago

2.0.16

8 years ago

2.0.15

8 years ago

2.0.14

8 years ago

2.0.12

8 years ago

2.0.11

8 years ago

2.0.10

8 years ago

2.0.9

8 years ago

2.0.8

8 years ago

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.48

8 years ago

1.0.47

8 years ago

1.0.46

8 years ago

1.0.45

8 years ago

1.0.44

8 years ago

1.0.43

8 years ago

1.0.42

8 years ago

1.0.41

8 years ago

1.0.40

8 years ago

1.0.39

8 years ago

1.0.38

8 years ago

1.0.37

8 years ago

1.0.36

8 years ago

1.0.35

8 years ago

1.0.34

8 years ago

1.0.33

8 years ago

1.0.32

8 years ago

1.0.31

8 years ago

1.0.30

8 years ago

1.0.29

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago