@dolby-optiview/ads-sdk-adapter-shaka
v1.6.1
Published
Shaka Player adapter for OptiView Ads SDK
Readme
@dolby-optiview/ads-sdk-adapter-shaka
Shaka Player PlayerAdapter for the OptiView Ads SDK. It connects a
shaka.Player and its <video> element to the SDK core, either as the
content player or as the ad player.
Installation
npm install @dolby-optiview/ads-sdk-core @dolby-optiview/ads-sdk-adapter-shaka shaka-playershaka-player 4.x or 5.x is a peer dependency. The adapter is typed against
the structural ShakaPlayerLike interface, so it does not import
shaka-player itself.
Usage
import shaka from 'shaka-player';
import { OptiViewAds } from '@dolby-optiview/ads-sdk-core';
import { ShakaAdapter } from '@dolby-optiview/ads-sdk-adapter-shaka';
shaka.polyfill.installAll();
const video = document.getElementById('video') as HTMLVideoElement;
const player = new shaka.Player(video);
const sdk = new OptiViewAds({
player: new ShakaAdapter(player, video),
container: document.getElementById('container')!,
createAdAdapter: (adContainer) => {
const adVideo = document.createElement('video');
adContainer.appendChild(adVideo);
// Create the ad player without a video element; the adapter attaches it.
return new ShakaAdapter(new shaka.Player(), adVideo);
},
});
await sdk.startSession({
manifestUrl: 'https://manifest.example.com/v1/your-org/channels/your-channel',
});
await player.load('https://example.com/live.m3u8');
video.play();Call sdk.destroy() before player.destroy() when tearing the player down;
the SDK destroys the ad player it created.
Documentation
- OptiView Ads SDK documentation
- Entry package:
@dolby-optiview/ads-sdk
