OptiView Ads SDK
    Preparing search index...

    Class OptiViewAds

    Main entry point for integrating ad playback with your web video player.

    Create an instance with OptiViewAdsConfig, subscribe to events, and call startSession for each piece of content. Call endSession to stop a session or destroy to release the SDK.

    A default ad player is included: progressive MP4/WebM uses native video, and HLS uses HLS.js with native HLS on platforms without Media Source support. Supply createAdAdapter only to use a custom ad player.

    const sdk = new OptiViewAds({
    player: new HlsJsAdapter(hls, video),
    container,
    // The SDK provides the ad player.
    adPreload: 'auto', // optional: select a preload strategy for the device
    });

    Hierarchy

    • OptiViewAds
      • OptiViewAds
    Index
    • Clean up all resources. Call when the SDK is no longer needed.

      Returns void

    • Stop monetization: stops manifest polling, break scheduling, and resets the GAM session.

      Returns void

    • Whether a session is currently active.

      Returns boolean

    • Start monetization for a piece of content: begins manifest polling and (if configured) GAM session initialization. Ends any previously active session first.

      Parameters

      Returns Promise<void>

    • Replace the live-update layer of the asset parameters for future breaks. Highest of the three layers, per key; it replaces the previous update (IMA replaceAdTagParameters() semantics). Consumed by GAM pods (IMA adTagParameters) and by VAST assets (appended to the tag URL). No-op with a warning without an active session.

      Parameters

      • params: Record<string, string>

      Returns void

    • Report a click on the current ad and emit adclick with its interaction.clickThrough. Returns the destination URL, or null when no ad or click-through URL is available. The SDK does not open the URL; your application controls navigation.

      Returns string | null

    • Current playback-gated ad break status; for polling when an adbreakstatus event was missed.

      Returns AdBreakStatus

    • Current picture-in-picture status, visible media, window owner, and insertion mode. Use this snapshot to keep your player UI aligned with the SDK.

      Returns {
          insertion: "overlay" | "shared-element";
          pictureInPicture: boolean;
          showing: "ad" | "content";
          windowOwner: "ad" | "content" | null;
      }

      • insertion: "overlay" | "shared-element"

        overlay (own element) or shared-element (through the content element); content behaviour and windowOwner differ between them.

      • pictureInPicture: boolean
      • showing: "ad" | "content"
      • windowOwner: "ad" | "content" | null

        which element owns the PiP window — null when there is none (web only)

    • Whether an ad is currently playing.

      Returns boolean

    • Whether the content player is in picture-in-picture. The browser reports this directly; nothing to wire up.

      Returns boolean

    • get muted(): boolean

      Unified mute state: targets whichever player is audible — the ad player during a break, the content player otherwise — and bridges into IMA for a CSAI ad (IMA manages its own audio path).

      Returns boolean

      muteButton.onclick = () => { sdk.muted = !sdk.muted; };
      sdk.addEventListener('volumechange', (e) => {
      muteButton.textContent = e.muted ? 'Unmute' : 'Mute';
      });
    • set muted(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • Pause content playback. No-op during a content-locking ad break.

      Returns void

    • Resume content playback. No-op during a content-locking ad break.

      Returns Promise<void>

    • Seek the content stream (seconds). Blocked during breaks with controls.snapback; no-op without a session.

      Parameters

      • time: number

      Returns void

    • Skip the running ad break when the manifest's controls.skipOffset allows it. Returns true when applied (balanced adend + adbreakend), false when suppressed (no active break, no skip control, or before the offset). Suppression is diagnosed as DA-AD-SKIP-SUPPRESSED. Use getAdBreakStatus for a "Skip in Ns" affordance.

      Returns boolean

    • get volume(): number

      Unified volume (0-1). See muted for which player is the effective target.

      Returns number

    • set volume(value: number): void

      Parameters

      • value: number

      Returns void

    • Self-contained, redacted diagnostic report (no secrets or ad-tag-parameter values).

      Returns DiagnosticReport

    • Unsubscribe from the structured diagnostic stream.

      Parameters

      Returns void

    • Subscribe to the structured diagnostic stream (stable code, category, level, JSON context).

      Parameters

      Returns void

    • get version(): string

      The SDK version, readable without constructing an instance.

      Returns string