OptiView Ads SDK
    Preparing search index...

    Class THEOplayerAdapter

    The PlayerAdapter for THEOplayer, from the @dolby-optiview/ads-sdk-adapter-theoplayer package (peer dependency: theoplayer 9 or later).

    Unlike HLS.js and Shaka, THEOplayer manages its own <video> element internally. Pass the <div> container that was used to create the ChromelessPlayer; the SDK will locate the internal <video> via a DOM query when needed (e.g. for GAM).

    import { ChromelessPlayer } from 'theoplayer/chromeless';
    import { THEOplayerAdapter } from '@dolby-optiview/ads-sdk-adapter-theoplayer';

    // Content player
    const container = document.getElementById('player') as HTMLElement;
    const player = new ChromelessPlayer(container, { license: 'YOUR_LICENSE' });
    player.source = { sources: [{ src: 'https://example.com/stream.m3u8' }] };

    const adapter = new THEOplayerAdapter(player, container);

    // Ad adapter factory (SDK creates a container div and passes it)
    createAdAdapter: (adContainer) => {
    const adPlayer = new ChromelessPlayer(adContainer, { license: 'YOUR_LICENSE' });
    return new THEOplayerAdapter(adPlayer, adContainer);
    }

    Implements

    Index
    • get currentTime(): number

      Current playback time in seconds.

      Returns number

    • set currentTime(value: number): void

      Current playback time in seconds.

      Parameters

      • value: number

      Returns void

    • get duration(): number

      Content duration in seconds; may be Infinity for live streams.

      Returns number

    • get isLive(): boolean | null

      THEOplayer genuinely does report Infinity for a live source, so the duration test is correct HERE — unlike on hls.js, where it silently is not. Stated explicitly rather than left to the core's fallback so the difference between the two engines is recorded where someone comparing them will look.

      Returns boolean | null

    • get maxLiveSeekPosition(): number | null

      Latest live playback position the player can seek to without moving back to maintain its minimum live offset, in seconds. Return null when unknown or not live; the SDK then leaves the seek target unclamped. Use the player engine's seek limit rather than guessing an offset: HLS.js exposes liveSyncPosition, THEOplayer exposes latencyManager.currentLatency / minimumOffset, and Shaka exposes seekRange() / safeSeekEndOffset.

      Returns number | null

    • get muted(): boolean

      Settable so the SDK can sync mute state between content and ad players.

      Returns boolean

    • set muted(value: boolean): void

      Settable so the SDK can sync mute state between content and ad players.

      Parameters

      • value: boolean

      Returns void

    • get paused(): boolean

      Whether the player is paused.

      Returns boolean

    • get playbackRate(): number

      Playback rate, 1 being normal speed.

      Reads THEOplayer rather than remembering what was written: its latency manager adjusts this property itself to hold live latency, and the SDK needs to see that so it can stand down rather than fight it.

      Returns number

    • set playbackRate(value: number): void

      Playback rate (1 = normal). Used to correct drift while content continues behind an ad with continueContentDuringBreak. Report the engine's current rate, not just the last assigned value, so the SDK can detect changes made by the player's live-latency controller. If omitted, drift is reported but not corrected.

      Parameters

      • value: number

      Returns void

    • get programDateTime(): Date | null

      Program Date Time from the THEOplayer presentation timeline. Returns the wall-clock time of the current position for live HLS/DASH streams that carry an EXT-X-PROGRAM-DATE-TIME tag.

      Returns Date | null

    • get seekableEnd(): number | null

      The end of THEOplayer's own seekable range — NOT the <video> element's.

      The element reports Number.MAX_SAFE_INTEGER for a live stream, which is a statement that it does not know rather than a position. player.seekable carries the real window.

      Returns number | null

    • get sourceUrl(): string | null

      THEOplayer owns its element and exposes what it is playing as a source description, so read the first source's src rather than anything on the media element.

      Returns string | null

    • get videoElement(): HTMLVideoElement | null

      The underlying HTMLVideoElement created by THEOplayer. THEOplayer renders its <video> inside the container div passed to the constructor.

      Returns HTMLVideoElement | null

    • get volume(): number

      Volume in [0, 1]; settable so the SDK can sync it between content and ad players.

      Returns number

    • set volume(value: number): void

      Volume in [0, 1]; settable so the SDK can sync it between content and ad players.

      Parameters

      • value: number

      Returns void

    • Clean up resources when the SDK is destroyed.

      Returns void

    • Load a media source without playing; resolves when it is ready to play. Used to preload ads.

      Parameters

      • url: string

      Returns Promise<void>

    • Pause playback (called when an ad break starts).

      Returns void

    • Start or resume playback. THEOplayer's play() is synchronous; wraps in a resolved Promise to satisfy the PlayerAdapter interface.

      Returns Promise<void>

    • Let go of the <video> so the SDK can play an ad through it (shared-element insertion).

      Clearing source is THEOplayer's way of stopping: the player keeps its instance, its configuration and its container, and takes the element back on the next load(). With it still driving, two engines share one element and the ad does not survive the contention — measured on macOS Safari, where the break produced two adtimeupdate ticks in ten seconds of ad.

      Returns Promise<void>

    • Seek to a time in seconds. Needed for snapback during locked breaks without touching the video element.

      Parameters

      • time: number

      Returns void

    • Set the requested video quality, or restore the selection in force before the first set. Returns whether an override was applied or an outstanding override was restored.

      Assigning one Quality to targetQuality pins that rendition without clearing the buffer. Qualities THEOplayer marks unavailable or disabled are skipped because the engine would ignore them. A null request assigns the exact prior targetQuality, including undefined.

      Parameters

      • quality: "lowest" | null

      Returns boolean