Getting Started
If you are looking for industry leading Video Player with dual synchronous video playback, advanced layout capabilities and the power of Annoto interactivity, you are in the right place :)

Setup

The player is officially available via CDN and npm. Annoto works out of the box with not only HTML <script> tag, but also with all major bundlers/packagers/builders, such as Browserify, WebPack, etc.
NPM
CDN
1
$ npm install @annoto/player
Copied!
The package includes full typings and can be used in typescript/ES6/flow projects.
1
<body>
2
<script src="https://player.annoto.net/index.js"></script>
3
</body>
4
<script>
5
// Annoto modules is available at 'nn' global object:
6
// nn.annotoPlayer
7
</script>
Copied!

Creating a Player

Annoto player is exposed as UMD module, meaning it offers compatibility with the most popular script loaders and can be imported as commonjs/amd/es6. If you are not using any standard loader the player will be exposed on window as global variables. The simplest way to create a player is using the annotoPlayer() method:
Typescript
JS
HTML
1
import { annotoPlayer, PlayerOptions, PlayerServices } from '@annoto/player';
2
3
const options: PlayerOptions;
4
const services: PlayerServices;
5
6
annotoPlayer(document.querySelector('annoto-player'), options, services).then((player: AnnotoPlayer) => {
7
loadWidget(player);
8
9
return this.player.loadSrc({
10
src: 'https://www.youtube.com/watch?v=1T9EZi7KJcc',
11
type: 'video/youtube'
12
});
13
}).catch((err) => {
14
console.error('player setup error: ', err);
15
});
Copied!
1
var options;
2
var services;
3
4
nn.annotoPlayer(document.querySelector('annoto-player'), options, services).then(function(player) {
5
loadWidget(player);
6
7
return this.player.loadSrc({
8
src: 'https://www.youtube.com/watch?v=1T9EZi7KJcc',
9
type: 'video/youtube'
10
});
11
}).catch(function (err) {
12
console.error('player setup error: ', err);
13
});
Copied!
1
<body>
2
<annoto-player></annoto-player>
3
</body>
Copied!
This will create a new AnnotoPlayer instance and setup it for usage. After you have the player instance it can be used to load video sources, setup the Annoto widget and much more.
Notice the loadWidget(player) function call, we will implement it when we talk about setting up the widget. Loading the widget can be done asynchronous like we are doing in the example above.

Player Options

Annoto Player extends standard VideoJS options with some advanced functionality, for more details, please refer to the PlayerOptions.
PlayerOptions extends VideoJS options, so all options supported by the videojs player can be used.

Player services

The player accepts a number of optional services. The most important one is Authentication Provider, for proper Widget Single Sign On functionality the service must be implemented.

Setup the Widget

Setting up and loading Annoto Widget is a 2 step process:
1
import { IAnnotoApi, IConfig } from '@annoto/widget-api';
2
import { AnnotoPlayer } from '@annoto/player';
3
4
function loadWidget(player: AnnotoPlayer) {
5
const widgetConfig: IConfig;
6
7
return player.setupWidget(widgetConfig).then(() => { // #1
8
9
window.Annoto.on('ready', (api: IAnnotoApi) => {
10
console.log('widget api is ready: ', api);
11
});
12
13
return player.loadWidget(); // #2
14
}).catch((err) => {
15
console.error('Annoto widget setup err: ', err);
16
});
17
}
Copied!
  1. 1.
    First we setup the widget by calling player.setupWidget(widgetConfig), this will setup the widget and will allow to obtain the Widget API.
  2. 2.
    After the widget is setup, we can load it by calling `player.loadWidget()`.
All the options are optional, but to use the Annoto Widget in production (not in Demo mode), you would need to set the clientId provided by Annoto.
The Widget Configuration widgetConfig.widgets property is not supported and will be replaced internally by the player.