@dolby-optiview/ads-sdk-adapter-theoplayer
THEOplayer Web SDK PlayerAdapter for the OptiView Ads SDK. It connects a
ChromelessPlayer (or full Player) and its mount 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-theoplayer theoplayer
theoplayer 9.0.0 or newer is a peer dependency. The adapter is typed against
the structural THEOplayerLike interface, so it also works with a THEOplayer
build loaded from a script tag. A THEOplayer license is required.
Usage
import { ChromelessPlayer } from 'theoplayer';
import { OptiViewAds } from '@dolby-optiview/ads-sdk-core';
import { THEOplayerAdapter } from '@dolby-optiview/ads-sdk-adapter-theoplayer';
const config = { license: LICENSE, libraryLocation: LIB, mutedAutoplay: 'all' };
const playerDiv = document.getElementById('player') as HTMLElement;
const player = new ChromelessPlayer(playerDiv, config);
const sdk = new OptiViewAds({
player: new THEOplayerAdapter(player, playerDiv),
container: document.getElementById('container')!,
createAdAdapter: (adContainer) => {
const adPlayer = new ChromelessPlayer(adContainer, config);
return new THEOplayerAdapter(adPlayer, adContainer);
},
});
await sdk.startSession({
manifestUrl: 'https://manifest.example.com/v1/your-org/channels/your-channel',
});
player.source = { sources: [{ src: 'https://example.com/live.m3u8' }] };
player.play();
THEOlive sources
For a THEOlive source the adapter reads the ads manifest URL from the THEOlive
discovery response, so manifestUrl can be omitted. Opt in with
manifestUrlDiscovery: true (off by default) and create the SDK before you set
the source:
const sdk = new OptiViewAds({ player: new THEOplayerAdapter(player, playerDiv), manifestUrlDiscovery: true /* … */ });
player.source = { sources: [{ type: 'theolive', src: 'your-distribution-id' }] };
await sdk.startSession({});
startSession() waits up to 10 seconds for discovery and rejects when the
response has no ads manifest URL. An explicit manifestUrl always wins.
For React Native apps using react-native-theoplayer, use
@dolby-optiview/ads-sdk-react-native instead of this package.
Documentation
- OptiView Ads SDK documentation
- Entry package:
@dolby-optiview/ads-sdk