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.
$npminstall@annoto/player
The package includes full typings and can be used in typescript/ES6/flow projects.
<body>
<script src="https://player.annoto.net/index.js"></script>
</body>
<script>
// Annoto modules is available at 'nn' global object:
// nn.annotoPlayer
</script>
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.
If you are using a javascript module loader such as RequireJS. Annoto exposes a standard UMD. For example for requireJS:
The main player class is AnnotoPlayer. After you have the player instance it can be used to load video sources, dynamically control Widget, get access to Widget API and much more.
Creating player using the annotoPlayer helper (CDN)
The annotoPlayer() helper is available only for the CDN. When using the npm package, please use the AnnotoPlayer constructor directly (see below)
import { annotoPlayer, IPlayerOptions } from'@annoto/player';import { IConfig } from'@annoto/widget-api';constoptions:IPlayerOptions;constwConfig:Omit<IConfig,'widgets'> = { clientId:'...',// [mandatory for widget] the clientId provided by Annoto ssoToken:'...',// JWT user SSO token (recomended, but can be dynamicaly authenticated using the API as well)};let player:AnnotoPlayer;annotoPlayer(document.querySelector('annoto-player'), options).then((p) => { player = p;returnPromise.all([player.loadSrc({ src:'https://www.youtube.com/watch?v=1T9EZi7KJcc', type:'video/youtube' }),player.setupWidget(wConfig), ]);}).then(() => {returnplayer.loadWidget(); // until this api call, the widget is not shown}).catch((err) => {console.error('player setup error: ', err);});
<body>
<annoto-player></annoto-player>
</body>
Creating player using the AnnotoPlayer constructor
The Player instance can be created using the AnnotoPlayer constructor which allows the most flexibility:
import { AnnotoPlayer, IPlayerOptions, WidgetService, IWidgetService, getConsoleLogger,} from'@annoto/player';import { IConfig } from'@annoto/widget-api';constoptions:IPlayerOptions; // optional player optionsconstwConfig:Omit<IConfig,'widgets'> = { clientId:'...',// [mandatory for widget] the clientId provided by Annoto ssoToken:'...',// JWT user SSO token (recomended, but can be dynamicaly authenticated using the API as well)};// IMPORTANT: there must be only a single WidgetService on a page// same widgetService must be used for all the players on a pageconstwidgetService=newWidgetService(); asyncfunctionsetupPlayer(el:HTMLElement, opt?:IPlayerOptions):Promise<AnnotoPlayer> {constpl=newAnnotoPlayer(getConsoleLogger('AnnotoPlayer'), widgetService, );awaitpl.setup(el, opt);return pl;}let player:AnnotoPlayer;setupPlayer(document.querySelector('annoto-player'), options).then((p) => { player = p;returnPromise.all([player.loadSrc({ src:'https://www.youtube.com/watch?v=1T9EZi7KJcc', type:'video/youtube' }),player.setupWidget(wConfig), ]);}).then(() => {returnplayer.loadWidget(); // until this api call, the widget is not shown}).catch((err) => {console.error('player setup error: ', err);});
<body> <annoto-player></annoto-player></body>
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.
Using the Widget API
The most common widget related api is available directly via the AnnotoPlayer instance, for example: setupWidget, loadWidget, destroyWidget.
For more advanced usages the IAnnotoApi can be obtained using await player.getWidgetApi()
Authenticating the User
The most recomended wait is to provide the User's SSO token to the widget configuration as show in Creating A Player.