Customise Annoto Widget configuration

When the Annoto plugin is loaded by the Kaltura player, it triggers custom events that allows you to get access to the configuration and the API for full customisation and control of the widget.

Listen to Kaltura Player events

To subscribe to Kaltura player events please use Kaltura player API:

kWidget.addReadyCallback(function (playerId) {
var player = document.getElementById(playerId);
player.kBind('annotoPluginSetup', function (params) {
var config = params.config;
// Modify the Annoto configuration
});
player.kBind('annotoPluginReady', function (annotoApi) {
// Make use of the Annoto API
});
});

For detailed information on the Kaltura player API, please refer to http://player.kaltura.com/docs/api

Modify Annoto configuration

annotoPluginSetup is triggered first by the Annoto plugin and provides opportunity to modify the Annoto widget configuration before the widget is bootstrapped.

Once the widget is bootstrapped by the plugin annotoPluginReady is triggered and provides access to the Annoto API.

Below is an example of modifying some basic widget options:

player.kBind('annotoPluginSetup', function (params) {
var config = params.config;
var widget = config.widgets[0];
var ux = config.ux || {};
var align = config.align || {};
var features = config.features || {};
config.ux = ux;
config.align = align;
config.features = features;
config.clientId = 'eyJhbGciOiJ...';
config.position = 'right';
config.demoMode = false;
config.locale = 'en';
features.tabs = true;
align.vertical = 'top';
/**
* Attach the ssoAuthRequestHandle hook.
* https://github.com/Annoto/widget-api/blob/master/lib/config.d.ts#L159
*/
ux.ssoAuthRequestHandle = function() {
// In case user is not logged in and tries to submit content
// trigger user login
window.location.replace('https://example.com/login');
};
});

config is already setup by the Kaltura Annoto plugin, so we need only to override the required configuration, such as clientId, features, etc. DO NOT CHANGE THE PLAYER TYPE OR PLAYER ELEMENT CONFIG.

For the default widget configuration used by the plugin please refer to: https://github.com/Annoto/kaltura-plugin

Asynchronous Widget Bootstrap

Advanced topic

In some cases you might not have the required configuration for the Annoto Widget when annotoPluginSetup is triggered, or would want to postpone the bootstrap of the widget until some condition is met.

var delayDoneCallback;
var annotoConfig;
player.kBind('annotoPluginSetup', function (params) {
// Set params.await to the following function:
params.await = function (doneCb) {
delayDoneCallback = doneCb;
};
annotoConfig = params.config;
});
// do some async work and when ready call the delayDoneCallback:
setTimeout(function() {
// Modify the Annoto configuration asynchronously
annotoConfig.clientId = 'eyJhbGciOiJ...';
delayDoneCallback();
}, 200);

Until delayDoneCallback is called, the widget won't be bootstrapped and annotoPluginReady won't be triggered.