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.

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

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;
config.clientId = 'eyJhbGciOiJ...';
config.locale = 'en';
config.hooks.getPageUrl = function() {
return window.location.href;;
};
// https://annoto.github.io/widget-api/interfaces/config_hooks.IHooks.html#mediaDetails
config.hooks.mediaDetails = function(params) {
return {
...params?.details,
// Optionaly use your own video identifier
// https://annoto.github.io/widget-api/interfaces/config_media_details.IMediaDetails.html#id
// id: 'unique_video_identifier',
};
};
config.hooks.ssoAuthRequestHandle = function() {
// trigger user login
// https://annoto.github.io/widget-api/interfaces/config_hooks.IHooks.html#ssoAuthRequestHandle
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, getPageUrl hook, 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

The plugin exposes annotoPluginReady event that provides access to the API for implementing the SSO functionality.
player.kBind('annotoPluginReady', function (annotoApi) {
// token is the generated user authentication JWT token
annotoApi.auth(token);
});

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.
If doneCb is not called, the widget is not bootstrapped. This can be used to dynamically decide on which videos to load the annoto plugin.
Export as PDF
Copy link
On this page
Listen to Kaltura Player events
Modify Annoto configuration
Single Sign On
Asynchronous Widget Bootstrap