Yospace
*******
To get started with Yospace, download the Yospace ad management SDK
from the Yospace developer site
(https://developer.yospace.com/sdk-documentation/javascript/userguide/yosdk/latest/en/developer-resources.html).
The currently supported version is 3.9.0. Other similar versions may
also work, but compatibility is not guaranteed.
Import the Yospace SDK:
Import the Yospace plugin:
import { clpp } from "@castlabs/prestoplay";
import "@castlabs/prestoplay/cl.yospace";
Enable the Yospace plugin when calling "open()" with a Yospace Central
Session Manager (CSM) uniform resource identifier (URI). This
automatically starts a Yospace session. "source.type" must be
specified:
await player.open({
source: {
// Yospace CSM URI
url: 'https://csm...',
type: clpp.Type.HLS,
},
yospace: {
enabled: true,
streamType: clpp.yospace.StreamType.VOD
}
});
Set up listeners for Yospace-related events:
player.on(clpp.events.YOSPACE_SESSION_STARTED, (e) => {
// e.detail contains the YospaceAdManagement.Session object
});
player.on(clpp.events.YOSPACE_SESSION_ENDED, (e) => {
// e.detail contains the YospaceAdManagement.Session object
});
await player.open({
source: '',
});
Once the video starts playing, call "getSession()" on the plugin
instance to get the "YospaceAdManagement.Session":
const plugin = player.getPlugin(clpp.yospace.YospacePlugin.Id);
const session = plugin.getSession();