Web BO Adapter 5.8
This page contains deprecated documentation and is no longer actively maintained. A new version of this documentation is now available here.
This guide explains how to integrate DIVA RW with DIVA BO using DIVA BoAdapter into your web application. application.
Requirements​
Refer to DIVA Web SDK documentation.
Initialization​
Diva BO Adapter gives programmatic access to the standard providers and to common plugins used by the DIVA player SDK when connected to DIVA BO.
- React App
- No React
- No package manager
import React, { useEffect, useState } from "react";
// bo adapter sdk
import { DivaWebBoAdapter } from "@deltatre-vxp/diva-sdk/diva-web-bo-adapter";
// Import SDK style
import "@deltatre-vxp/diva-sdk/diva-web-sdk/index.min.css";
// bo settings link
const SETTINGS_URL = "https://example.com/settings.json";
// id of the video to be runned
const VIDEO_ID = "123456789890";
const config = {
videoId:VIDEO_ID,
libs: {
mux: 'https://cdnjs.cloudflare.com/ajax/libs/mux.js/6.2.0/mux.min.js',
shaka: 'https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.3.7/shaka-player.compiled.js',
hlsJs: 'https://cdn.jsdelivr.net/npm/hls.js@1.5.7',
googleIMA: 'https://imasdk.googleapis.com/js/sdkloader/ima3.js',
googleDAI: 'https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js',
googleCast: 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1',
threeJs: 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.148.0/three.min.js',
}
};
const entitlementConfiguration = {
entitlementUser: () => 'token',
entitlementPayloadMap: (type, payload) => {
// Modify the payload
return payload;
},
version: "1",
};
const mediaAnalyticsParam = {
viewerId: 'DivaWebUser',
userName: 'DivaWebUser',
playerVersion: '5.8.0',
cdnName: 'AKAMAI',
playerType: 'HTML5',
omLibs: {
omWeb: 'omweb-v1.js',
omSessionClient: 'omid-session-client-v1.js',
},
setPALNonce: (nonceRequest: NonceRequest) => {
nonceRequest.sessionId = 'xyz'
return Promise.resolve(nonceRequest);
},
};
export const App = () => (
<DivaWebBoAdapter
settingsUrl={SETTINGS_URL}
languageCode={"en-US"}
entitlementConfiguration={entitlementConfiguration}
mediaAnalyticsParam={mediaAnalyticsParam}
config={config}
/>
)
// bo adapter sdk
import { createDivaWebBoAdapter } from "@deltatre-vxp/diva-sdk/diva-web-bo-adapter";
// Import SDK style
import "@deltatre-vxp/diva-sdk/diva-web-sdk/index.min.css";
// bo settings link
const SETTINGS_URL = "https://example.com/settings.json";
// id of the video to be runned
const VIDEO_ID = "123456789890";
const config = {
videoId:VIDEO_ID,
libs: {
mux: 'https://cdnjs.cloudflare.com/ajax/libs/mux.js/6.2.0/mux.min.js',
shaka: 'https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.3.7/shaka-player.compiled.js',
hlsJs: 'https://cdn.jsdelivr.net/npm/hls.js@1.5.7',
googleIMA: 'https://imasdk.googleapis.com/js/sdkloader/ima3.js',
googleDAI: 'https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js',
googleCast: 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1',
threeJs: 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.148.0/three.min.js',
}
};
const el = document.getElementById("video-player-container");
(async () => {
try{
const divaBo = await createDivaWebBoAdapter({
el,
settingsUrl: SETTINGS_URL,
config
});
// to be run when it is required to cleanup diva after its usage
const onUnmount = () => {
divaBo.unmount();
}
} catch (e) {
// here it is possible to react to BoAdapterIssues
}
})();
{targetEnv}
:.min
(production),
<html>
<head>
<!-- ... -->
<script src="path/to/diva/webBOAdapter.reactBundled .js"></script>
<link rel="path/to/diva.bundle.min.css" />
</head>
<body>
<!-- ... -->
<div id="diva-container"></div>
<!-- ... -->
<script>
// bo settings link
const SETTINGS_URL = "https://example.com/settings.json";
// id of the video to be runned
const VIDEO_ID = "123456789890";
const config = {
videoId:VIDEO_ID,
libs: {
mux: 'https://cdnjs.cloudflare.com/ajax/libs/mux.js/6.2.0/mux.min.js',
shaka: 'https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.3.7/shaka-player.compiled.js',
hlsJs: 'https://cdn.jsdelivr.net/npm/hls.js@1.5.7',
googleIMA: 'https://imasdk.googleapis.com/js/sdkloader/ima3.js',
googleDAI: 'https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js',
googleCast: 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1',
threeJs: 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.148.0/three.min.js',
}
};
const el = document.getElementById("diva-container");
(async () => {
try{
const divaBo = await divaWebBoAdapter.createDivaWebBoAdapter({
el,
settingsUrl: SETTINGS_URL,
config,
});
// to be run when it is required to cleanup diva after its usage
const onUnmount = () => {
divaBo.unmount();
}
} catch (e) {
// here it is possible to react to BoAdapterIssues
}
})();
</script>
</body>
</html>
Properties​
Property | Type | Default | Description |
---|---|---|---|
Mandatory | |||
Property: settingsUrl | type:string | Default: NA | url to reach diva bo adapter settings for the specific project |
Property: config | type: | Default: NA | initialization data for DIVA BO adapter |
Property: el (vanilla js/react embedded) | type:HTML div element reference | Default: NA | HTML div element where diva should be started into |
Optional | |||
Property: mediaAnalyticsParam | type: | Default: undefined | properties useful to implement media analytics |
Property: entitlementConfiguration | type: | Default: undefined | properties useful to implement entitlement |
Middleware | |||
Property: videoMetadataMap | type:(videoMetadata: VideoMetadata) => Promise<VideoMetadata> | Default: undefined | asynchronous middleware for the app to interact and modify the videoData as soon as videoData is returned from the request (passthrough if not defined) |
Callbacks | |||
Property: onDivaBoAdapterError | type:(e: unknown) => void | Default: undefined | notify errors on bo adapter start (React) |
Typescript interfaces for Properties​
BoAdapterWebComponentProps and BoAdapterWebVanillaProps
Refer to DivaConfiguration in Diva Web SDK, taking in account the omits.
type BoAdapterWebComponentConfig = Omit<
DivaConfiguration,
'videoMetadataProvider' | 'dictionary' | 'entitlementProvider' | 'setting' | 'fairplayCertificatePath'
>;
interface BoAdapterWebComponentProps {
/**
* url to reach diva bo adapter settings for the specific project
*/
settingsUrl: string;
/**
* pushengine language
*/
languageCode: string;
/**
* dictionary language
*/
languageDictionary?: string;
/**
*
*/
onDivaBoAdapterError?: OnDivaBoAdapterError;
/**
* a middleware for the app to interact and modify the videoData as soon as videoData is returned from the request (passthrough if not defined)
*/
videoMetadataMap?: VideoMetadataMap;
mediaAnalyticsParam?: MediaAnalyticsProps;
entitlementConfiguration?: EntitlementConfiguration;
config: BoAdapterWebComponentConfig;
}
interface BoAdapterWebVanillaProps extends BoAdapterWebComponentProps {
el: HTMLElement;
}
Config​
BO Adapter config are the same as those in the DIVA Web SDK, excluding for videoMetadataProvider
, dictionary
, entitlementProvider
, setting
, fairplayCertificatePath
properties, because they are provided by BO adapter.
Refer to DivaConfiguration in Diva Web SDK, taking in account the omits.
Entitlement​
Typescript interfaces for Entitlement configuration​
BoEntitlementConfiguration
interface BoEntitlementConfiguration {
/**
* platform parameter used to request entitlement token
*/
entitlementPlatform?: string;
/**
*
*/
otherParameters?: Record<string, string>;
/**
* function that returns the user token
*/
entitlementUser?: () => string;
/**
* default to "HTML5", used in the entitlement "PlayerType" request parameter
*/
entitlementPlayerType?: string;
/**
* Entitlement service version. If the version is set, `Data` will be included in the request body
*/
version?: string;
/**
* Function type definition that can be used to modify the payload of an entitlement at runtime.
*
* @param {('token' | 'heartbeat')} entitlementType - The type of the entitlement.
* @param {any} payload - The original payload of the entitlement.
*
* @returns {Promise<any>} The Promise object represents the modified payload of the entitlement.
*/
entitlementPayloadMap: (
entitlementType: "token" | "heartbeat",
payload: any
) => Promise<any>;
}
Media Analytics​
Property | Type | Default | Description |
---|---|---|---|
Optional | |||
Property: viewerId | type:string | Default: "" | viewer id passed down to media analytics platforms |
Property: userName | type:string | Default: "" | user name passed down to media analytics platforms |
Property: playerVersion | type:string | Default: "" | player version parameter passed down to media analytics platforms |
Property: playerType | type:string | Default: "" | player type parameter passed down to media analytics platforms |
Property: cdnName | type:string | Default: "" | cdn name parameter passed down to media analytics platforms |
Property: omLibs | type:object | Default: undefined | It's an object of type:{omWeb: string; omSessionClient: string;} .It contains the libs urls for OpenMeasurement hosted by project. It's mandatory to make OM work. Download libs files |
Callbacks | |||
Property: mediaAnalyticsEventHandler | type:(event: MediaEvent) => void | Default: undefined | additional callback for notifying media analytics events |
Middlewares | |||
Property: customTag | type:(videoMetadata: VideoMetadataClean) => Record<string, string> | Default: undefined | custom tag generator |
Property: customDimensions | type:(videoMetadata: VideoMetadataClean) => string[] | Default: undefined | custom dimensions generator |
Property: customDeviceMetadata | type:() => ConvivaDeviceMetadata | Default: undefined | custom device metadata generator for Conviva |
Property: setPALNonce | type:(nonceRequest: NonceRequest) => Promise<NonceRequest> | Default: undefined | a middleware to modify the NonceRequest before requesting it to PAL. |