OptiView Ads SDK

Player-agnostic SDK for Server-Guided Ad Insertion (SGAI) on HLS live streams. The web SDK polls a break manifest from the OptiView Ads backend and inserts ad breaks at the specified times — without modifying the content stream.

@dolby-optiview/ads-sdk @dolby-optiview/ads-sdk-core @dolby-optiview/ads-sdk-adapter-hlsjs TypeScript

Roku SDK

A separate BrightScript/SceneGraph OptiViewAds component, distributed as a ZIP, inserts ads into clear live HLS with Program Date Time on Roku. Unlike the web overlay below, it uses one app-owned Video and a local stitched HLS URL (client-side stitching of GAM pods) or, when the manifest selects SSAI for TV, the Google DAI live stream; it never changes the source at ad boundaries. It is a separate implementation, not a fourth parity-complete core. See Roku for requirements, integration, timing behaviour and limitations.

Architecture (web)

┌─────────────────────────────────────────────────────────────┐ │ Your Application │ │ │ │ ┌──────────────────────────────────────────────────────┐ │ │ │ #container (SDK stage, position: relative) │ │ │ │ ┌──────────────────────┐ ┌──────────────────────┐ │ │ │ │ │ #playerContainer │ │ .dolby-ad-container │ │ │ │ │ │ (content video UI) │ │ (SDK-managed, hidden │ │ │ │ │ │ │ │ until break starts) │ │ │ │ │ └──────────────────────┘ └──────────────────────┘ │ │ │ └──────────────────────────────────────────────────────┘ │ │ ▲ │ │ │ createAdAdapter factory │ │ ┌────────────────────┐ │ PlayerAdapter interface │ │ │ @dolby-optiview/ads-sdk-core │──────┘ │ │ │ • Manifest poll │ ◄── ContentPlayer (PlayerAdapter) │ │ │ • Break schedule │ │ │ │ • Layout mgmt │ ──► @dolby-optiview/ads-sdk-adapter-hlsjs │ │ └────────────────────┘ (or your own adapter) │ └─────────────────────────────────────────────────────────────┘

Key concepts

  • Internal ad player — the SDK creates its own <video> element and plays ads through it. With @dolby-optiview/ads-sdk the ad player defaults to HLS.js (including iPhone on iOS 17.1+ via Managed Media Source), with a native <video> fallback only for MSE-less platforms such as older iOS (< 17.1)/tvOS, so createAdAdapter is optional; with bare @dolby-optiview/ads-sdk-core you supply a createAdAdapter factory.
  • Two-container DOM — container is the outer SDK stage (anchors the ad overlay and companions); playerContainer wraps your content player UI (scaled to a pip corner for L-shape formats).
  • PlayerAdapter — a thin interface wrapping any HLS-capable player. The SDK never imports player libraries directly.
  • Ad formats — single, double, lshape_ad, lshape_content, overlay. Each format has its own layout rules and content-pause behaviour.
  • Break manifest — a JSON document served by the OptiView Ads backend that schedules when and what ads to play.
  • Session — a per-channel monetization session. Start one per piece of content; end it on channel change or stop.
  • Diagnostics & AI — a structured, redactable diagnostic stream plus IDE-installable AI artifacts (onboarding + adapter skills, onboarding + troubleshooter agents, references) and an optional MCP server that can troubleshoot from a report and bootstrap a runnable demo (scaffold_quickstart), so your own editor's AI can help you get started, integrate, and debug. The MCP server is optional — the shipped *.md artifacts are sufficient on their own.
  • Native too — the same model ships as native Android & iOS/tvOS SDKs (Kotlin/Swift). This page documents the web API; see the platform pages for native getting-started and adapter guides.

Getting Started

The web API reference provides detailed types and method signatures, organized by topic. Start with SDK & Sessions and Configuration. Use Events for player UI notifications and Player Integration for adapter contracts. Break Manifests & Ad Formats, Manifest Customization, and Diagnostics cover manifest data, request hooks and macros, and troubleshooting. On the OptiViewAds class page, members are grouped into Lifecycle, Playback & UI, Events, and Diagnostics.

Fastest way — let your IDE's AI do it. Run npx dolby-ads-init-ai, then ask your editor's AI assistant to follow the Dolby onboarding agent: it explains the model in plain terms and can scaffold a runnable demo for you — no MCP server required. Prefer zero setup? Use the Get started card on the AI Assistance page. The manual steps below are the detailed path if you'd rather wire it up yourself.

Roku setup

The steps below are for web. Roku uses a separate SceneGraph component and an application-owned Video, not PlayerAdapter or a DOM ad overlay. Install the ZIP (Install / Distribution), declare googleima3 and roku_ads_lib in the channel manifest, bind videoNode/adUiNode, register listeners with CallFunc("addEventListener", eventType, m.top, "handler") (including operationresult, diagnostic and gatewayrequest), then call CallFunc("startSession", { contentUrl: ..., manifestUrl: ... }). Load only the playbackUrl supplied by the correlated ready result, never change sources at ad boundaries, and stop/detach playback before destroy. The Roku section has the full integration guide.

Step 1 — Install

npm install @dolby-optiview/ads-sdk hls.js

The @dolby-optiview/ads-sdk entry package defaults the ad player to HLS.js (with a native <video> fallback for MSE-less platforms such as Safari/iOS).

Older Chromium devices

The legacy compatibility target is Chromium 47+ (Tizen 3.x+, webOS 4.x+). webOS 3.x uses Chromium 38 and is not covered. Engine compatibility does not certify codecs, MSE, DRM, IMA, or every player version on those TVs.

The npm SDK is modern ESM. Transpile the complete consumer bundle, including player dependencies and workers, and use a classic-script loader on browsers without ES modules. With Vite, use @vitejs/plugin-legacy targeting Chrome 47; the repository demo provides npm run build:legacy -w @dolby-optiview/ads-sdk-demo. Serve that production output, not the Vite development server.

Keep the existing SDK integration; no loader entry point or SDK polyfill list is needed:

import { OptiViewAds } from '@dolby-optiview/ads-sdk';

const sdk = new OptiViewAds(config);
await sdk.startSession(sessionConfig);

The same automatic preparation applies when importing OptiViewAds from the core package for a custom ad player. Imports and construction remain synchronous, and construction makes no compatibility requests. Inside startSession(), the SDK loads only missing required Object/Promise helpers, URL constructors and abort support before starting analytics or manifest requests. Existing native APIs stay in place; a fully capable runtime takes the normal startup path without an extra compatibility wait. Resize observation uses the SDK's existing local fallback, not an unnecessary downloaded polyfill.

Concurrent instances share preparation. A rejected or stalled compatibility request rejects startSession() (the preparation bound is 15 seconds), and an ended, destroyed or replaced session cannot resume when a chunk arrives later. Promise, ES2015 collections and the platform's DOM/HTTP primitives are part of the Chromium 47 baseline, not replacements for unsupported older engines. The SDK cannot fix unrelated application or player code that runs before it.

Keep code splitting enabled. Inlining dynamic imports downloads all fallback code, even if it is not used. Host every emitted chunk and allow those same-origin scripts through the application's CSP. The SDK does not weaken CSP, TLS or CORS. Its bounded XHR fallback handles missing native request-signal support, including native Request rejecting a replacement signal, while preserving signed manifest bytes. Optional opaque preload requests are skipped on that transport.

Without ResizeObserver, the SDK checks container size every 250 ms and stops on teardown. THEOplayer buffered metadata replay does not require queueMicrotask. For legacy layouts, use explicit container dimensions rather than relying on CSS aspect-ratio. The default ad player uses hls.js for HLS when supported; createAdAdapter can instead select THEOplayer. Validate both content and ad players, rather than assuming the content player's support covers ads.

Step 2 — Add the HTML container

<!-- Include IMA SDK if using Google Ad Manager -->
<script src="https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js"></script>

<!-- Minimal: single container, SDK auto-wraps your content -->
<div id="container" style="position:relative;width:100%;aspect-ratio:16/9">
  <video id="video" controls muted playsinline></video>
  <!-- SDK auto-creates a playerContainer wrapper around the video and appends .dolby-ad-container here -->
</div>

If you need custom controls inside the container, provide an explicit playerContainer:

<div id="container" style="position:relative;width:100%;aspect-ratio:16/9">
  <div id="playerContainer" style="width:100%;height:100%">
    <video id="video" controls muted playsinline></video>
  </div>
</div>

Step 3 — Wire your content player

Create a PlayerAdapter for your content player. With HLS.js:

import Hls from 'hls.js';
import { OptiViewAds, HlsJsAdapter } from '@dolby-optiview/ads-sdk';

const video = document.getElementById('video') as HTMLVideoElement;
const hls = new Hls();
hls.attachMedia(video);

Other supported adapters: @dolby-optiview/ads-sdk-adapter-shaka (Shaka Player), @dolby-optiview/ads-sdk-adapter-theoplayer (THEOplayer), or NativeVideoAdapter (built into @dolby-optiview/ads-sdk for native HLS on Safari/iOS). For a custom player, implement the PlayerAdapter contract — see the dolby-adapter-integration skill.

Step 4 — Create the SDK instance

const sdk = new OptiViewAds({
  player: new HlsJsAdapter(hls, video),
  container: document.getElementById('container'),
  debug: true,
});

With @dolby-optiview/ads-sdk the ad player defaults to HLS.js (including iPhone on iOS 17.1+ via Managed Media Source) and falls back to a native <video> element only where no Media Source engine exists (older iOS < 17.1 / older tvOS). playerContainer is optional — when omitted the SDK automatically wraps the existing children of container.

Step 5 — Subscribe to events

sdk.addEventListener('adbreakbegin', (e) => console.log('Break started:', e.break.id));
sdk.addEventListener('adbreakend', (e) => console.log('Break ended:', e.break.id));

For deeper debugging, subscribe to the diagnostic stream:

sdk.onDiagnostic((e) => console.log(`[${e.level}] ${e.code}`));

Step 6 — Start a monetization session

await sdk.startSession({
  manifestUrl: 'https://manifest.example.com/v1/your-org/channels/your-channel',
});

Step 7 — Load and play content

hls.loadSource('https://example.com/stream.m3u8');
video.play();

Step 8 — Verify diagnostics

Watch the console for a healthy lifecycle:

  1. DA-SESSION-STARTED — the session is polling the break manifest.
  2. adbreakbegin — an ad break starts (content pauses, ad overlay shows).
  3. adbegin → quartiles → adend — ad creative plays.
  4. adbreakend — break ends, content resumes.

If something goes wrong, capture a full report with sdk.exportDiagnostics() and use the dolby-troubleshooter agent or the AI Assistance page.

Step 9 — Clean up

sdk.endSession(); // stop polling, keep the instance
// or
sdk.destroy(); // full teardown — removes DOM elements, releases resources

Custom ad player with @dolby-optiview/ads-sdk-core

Use the bare @dolby-optiview/ads-sdk-core package when you want to supply your own ad player (a different library, or a pre-configured HLS.js instance). Here createAdAdapter is required — the SDK creates a <div> container and passes it to your factory; create your media element(s) inside it and return a PlayerAdapter.

npm install @dolby-optiview/ads-sdk-core @dolby-optiview/ads-sdk-adapter-hlsjs hls.js
import Hls from 'hls.js';
import { OptiViewAds } from '@dolby-optiview/ads-sdk-core';
import { HlsJsAdapter } from '@dolby-optiview/ads-sdk-adapter-hlsjs';

const video = document.getElementById('video') as HTMLVideoElement;
const hls = new Hls();
hls.attachMedia(video);

const sdk = new OptiViewAds({
  player: new HlsJsAdapter(hls, video),
  container: document.getElementById('container'),
  createAdAdapter: (adContainer) => {
    const adVideo = document.createElement('video');
    adContainer.appendChild(adVideo);
    const adHls = new Hls();
    adHls.attachMedia(adVideo);
    return new HlsJsAdapter(adHls, adVideo);
  },
  debug: true,
});
Bare @dolby-optiview/ads-sdk-core throws if createAdAdapter is omitted (it has no default). Use @dolby-optiview/ads-sdk for the zero-config HLS.js ad player, or supply your own factory.

Reading the SDK version

Read the current SDK version from the static OptiViewAds.version accessor — no instance required. It is the same lockstep version across @dolby-optiview/ads-sdk-core and @dolby-optiview/ads-sdk (and matches the Android/iOS SDKs and the stitcher's GET /version).

import { OptiViewAds } from '@dolby-optiview/ads-sdk'; // or '@dolby-optiview/ads-sdk-core'

console.log(OptiViewAds.version); // e.g. "0.16.0"

Player Adapters

For the live startup adjustment (opt-in with liveStartPushback.enabled: true), adapters may expose targetDuration (the declared HLS EXT-X-TARGETDURATION in seconds), seekableStart, seekableEnd, liveEdge, playbackReady, and isLive. The five-target-duration distance is measured from liveEdge, the end of the newest published segment; it defaults to seekableEnd. Report it separately when the engine's seekable range stops short of the playlist end — AVFoundation ends seekableTimeRanges one hold-back (configuredTimeOffsetFromLive) before the edge, so AVPlayerAdapter adds that offset back. Safari's native HLS (NativeVideoAdapter) does the same without exposing the offset, so the adapter adds the HLS minimum hold-back of three target durations from liveStartPushback.targetDurationSeconds. Without that setting it falls back to seekableEnd. A larger HOLD-BACK starts further behind; a low-latency PART-HOLD-BACK below 3×TD would start closer. On Safari's native HLS the SDK seeks after the first frame. It cannot place the element earlier without the playlist window. The seekable bounds must refer to the same content timeline and range. Unknown TD/ranges return null; custom adapters need not implement these optional capabilities. Web can use the media element's seekable range. HLS.js and Media3 HLS supply TD; other hosts can use liveStartPushback.targetDurationSeconds. Do not substitute average segment length or an assumed live latency.

The SDK core (@dolby-optiview/ads-sdk-core) has zero dependencies on any video player library. All player interactions go through the PlayerAdapter interface — a small contract that any player can implement.

This means you can use the SDK with HLS.js today and migrate to Shaka or Video.js later by swapping the adapter, with no changes to your SDK integration code.

The web SDK also uses the optional videoElement reference when it is available. After media metadata arrives, the SDK reads the element's videoWidth and videoHeight to size its internal stage to the content aspect ratio. This keeps percentage-based ad layouts aligned with the painted picture for non-16:9 sources; before valid metadata, it falls back to 16:9. The controller listens for both metadata arrival and intrinsic media-size changes, so rendition and source switches are handled without player-specific code.

The optional wrappedPlayer reference is the player instance the adapter wraps: the object the app created and passed to the adapter, such as the Hls or shaka.Player instance, or the <video> element for an adapter that drives the element directly. Return that object itself, not a copy, an ID or a wrapper, and the same object for the adapter's whole lifetime. The SDK never calls it; it hands it to the Lens observability layer as a key, compared by reference, that lets every Lens integration on the same player report into one shared session. The bundled adapters expose it; a custom adapter that omits it reports in a session of its own.

React Native host-player bindings are documented separately in React Native support.

Your App └─ OptiViewAds (core) ├─ content PlayerAdapter ──► HlsJsAdapter ──► Hls.js instance └─ createAdAdapter ──► (SDK creates <div>) ──► HlsJsAdapter ──► Hls.js instance ──► ShakaAdapter ──► Shaka Player (future) ──► VideoJsAdapter ──► Video.js (future)

PlayerAdapter Interface

Any adapter must implement all properties and methods below. The interface is imported from @dolby-optiview/ads-sdk-core.

import type {
  PlayerAdapter,
  PlayerAdapterEvent,
  PlayerAdapterEventHandler,
} from '@dolby-optiview/ads-sdk-core';

// Events the adapter must support
type PlayerAdapterEvent = 'timeupdate' | 'ended' | 'error' | 'seeked' | 'volumechange';

interface PlayerAdapter {
  /** Current playback position in seconds. */
  readonly currentTime: number;

  /** Total duration in seconds (Infinity for live streams). */
  readonly duration: number;

  /** True when playback is paused. */
  readonly paused: boolean;

  /** Whether the player is muted. */
  muted: boolean;

  /** Volume level in the range [0, 1]. */
  volume: number;

  /** Current Program Date Time from the HLS manifest.
   *  Required for wallclock-timebase break matching on live streams.
   *  Return null if not available. */
  readonly programDateTime: Date | null;

  /** Pause playback. Called by SDK at break start. */
  pause(): void;

  /** Resume playback. Called by SDK at break end. */
  play(): Promise<void>;

  /** Seek to a position in seconds.
   *  The SDK seeks content to the viewer's target and parks paused content on its resume point. */
  seek(time: number): void;

  /** Load a media URL and resolve when ready to play (manifest parsed).
   *  Used for preloading ad content 5 seconds before break start. */
  load(url: string): Promise<void>;

  /** Optional: enable settings needed only while this adapter plays ads. */
  prepareForAdPlayback?(): void;

  /** Optional: the player instance this adapter wraps (e.g. Hls, shaka.Player,
   *  or the <video> element), the same object for the adapter's lifetime.
   *  Lens keys the shared observability session on it. */
  readonly wrappedPlayer?: object;

  /** Subscribe to a player event. */
  on(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler): void;

  /** Unsubscribe from a player event. */
  off(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler): void;

  /** Release all resources. Called when SDK is destroyed. */
  destroy(): void;

  /** Best-effort quality constraint used while content continues behind a DAR break.
   *  Pass `null` to restore the exact selection in force before the first set. */
  setVideoQuality?(quality: 'lowest' | null): boolean;

  // ── optional ──────────────────────────────────────────────────────────────

  /** Stop driving the `<video>` without tearing the player down, so the SDK can
   *  play an ad through that same element (shared-element insertion). Resolve only
   *  once the element is genuinely free: an asynchronous teardown that lands after
   *  this resolves will reset the ad engine's MediaSource and the ad never starts.
   *  The SDK hands the element back at break end by calling `load()` again on this
   *  same adapter, so this must NOT destroy the player. Omit it if your engine is
   *  happy to share the element (hls.js is). */
  releaseMediaElement?(): void | Promise<void>;

  /** Whether the content is LIVE, as the engine itself understands it.
   *  Return null when unsure — the SDK falls back to the duration test.
   *  Skip these three live members entirely unless you support live DVR. */
  readonly isLive?: boolean | null;

  /** The furthest position a seek will actually STICK on live content — the
   *  engine pulls back anything closer to the live edge. Return null when
   *  unsure (safe: the SDK then does not clamp); never guess. */
  readonly maxLiveSeekPosition?: number | null;

  /** Where the media currently ENDS, per the ENGINE — only needed when the
   *  <video> element's own seekable range is unreliable (THEOplayer reports
   *  an unbounded sentinel on live). Return null / omit when unsure. */
  readonly seekableEnd?: number | null;

  /** Release the media you hold without destroying the adapter — called on the
   *  AD adapter at break end. May return a promise; when it does the SDK awaits
   *  it before resuming content. */
  unload?(): void | Promise<void>;

  /** Tear down and rebuild the media pipeline (MediaSource / source buffers)
   *  for the CURRENT source, positioned at `startTime` seconds — called on the
   *  CONTENT adapter at break end when `adBreakContentRecovery` resolves to
   *  `recreate` (VIZIO SmartCast). Resolve once metadata for the rebuilt
   *  pipeline is available; reject on failure — the SDK then falls back to
   *  seek + play. Omit when the engine has no such operation. */
  recreateMediaPipeline?(options: { startTime: number }): Promise<void>;
}
Member Notes
programDateTime Critical for live streams with timebase: "wallclock". Track the current EXT-X-PROGRAM-DATE-TIME tag from the HLS manifest. Return null if the stream has no PDT.
load(url, options?) Must resolve only when the player has parsed the manifest and buffered enough to play immediately. Reject on fatal errors. This enables seamless preloading. For an ad whose manifest asset declares a recognised mimeType, options.mimeType carries it (lower-cased, without parameters, e.g. video/mp4 or application/x-mpegurl): use it as the source type instead of guessing from the URL. preload(url, options?) receives the same options. Adapters that ignore the argument keep working.
prepareForAdPlayback() (optional) Called once on the adapter returned by createAdAdapter, immediately before its first load(). Use it for player settings needed only during ad playback; the SDK does not call it on the content adapter.
seek(time) Set the playback position directly. Used by the SDK to snap back to a break start when controls.snapback: true and a seek is detected.
on / off The SDK listens to 'timeupdate' for break timing, 'ended' to know when an ad asset finishes, 'error' for recovery, 'seeked' for snapback enforcement, and 'volumechange' for mute/volume sync.
releaseMediaElement() (optional) Only called on the shared-element path, where the ad plays through the content player's own <video> — that is how an ad reaches a picture-in-picture window or an OS-native fullscreen, which a DOM overlay cannot. Implement it if your engine will not share the element: Shaka (detach()) and THEOplayer (clearing source) both need it, and without it the two engines fight over the MediaSource and the ad aborts or stalls on its first segment. Finish before you resolve — if your teardown is asynchronous, wait for it. THEOplayer's lands after source = null returns, and it landed on top of the ad engine's freshly-attached MediaSource: the ad manifest was fetched and not one segment was ever requested. Do not tear the player down — the SDK calls load() on the same adapter to give the element back. The SDK also calls this method on the ad adapter your createAdAdapter(container, video) returned for the content element, just before content is reloaded: stop the ad engine there but leave its media on the element, because an element without a resource closes Safari's PiP window.
unload() (optional, ad adapters) The break-end mirror of preload(): in single-decoder preload mode the SDK calls it on the ad adapter when a break ends, before resuming content (in recreate content-recovery mode it is called regardless of preload mode — the ad media must be released before the content pipeline is rebuilt). Release the media you hold (detach your MediaSource / clear the element source) without destroying the adapter — on single-decoder TVs a still-attached ad MediaSource keeps the only hardware decoder and the content resume dies with MEDIA_ERR_DECODE. May return a promise; when it does, the SDK awaits it before resuming. The next break's load() must work like a first load. The default @dolby-optiview/ads-sdk ad player implements it; parallel-preload platforms are never asked.
recreateMediaPipeline(options) (optional, content adapters) Called on the content adapter at break end when adBreakContentRecovery resolves to 'recreate' — on VIZIO SmartCast, content cannot resume in the MediaSource an ad interrupted, so the SDK rebuilds the pipeline at the resume position instead of seeking inside it. Tear down and rebuild the engine's media pipeline for the CURRENT source, seeded at options.startTime seconds; resolve once metadata for the rebuilt pipeline is available and reject on failure — a rejection or a 10 s timeout falls back to seek + play with DA-CONTENT-PIPELINE-RECREATE-FAILED. Do not destroy the adapter and do not call play() — the SDK plays afterwards. The official hls.js, Shaka and THEOplayer adapters implement it; adapters that omit it simply resume in place. An adapter that wraps another adapter must forward it (and unload) — otherwise DA-CONTENT-PIPELINE-RECREATE-FAILED with reason unsupported-adapter is emitted and content resumes in place.
setVideoQuality(quality) (optional) Best-effort quality constraint for continueContentDuringBreak. setVideoQuality('lowest') returns whether an override was applied; setVideoQuality(null) restores the exact prior selection. Official HLS.js, Shaka and THEOplayer adapters implement it. If absent or false, content continues at its current quality and the SDK emits DA-CONTINUE-PLAYOUT-QUALITY-UNAVAILABLE.
isLive (optional) Whether the content is live, per the ENGINE — duration === Infinity is not reliable everywhere (hls.js reports a finite duration for live by default). Gates live-only behaviour such as continued content playout during a break. Return null when unsure; the SDK then falls back to the duration test.
maxLiveSeekPosition (optional) The furthest position a seek will actually stick on live content: every engine enforces a minimum live offset (holdback) and silently pulls back seeks closer to the edge. The SDK clamps its post-break resume and catch-up seeks to this position so they land where intended. Return null when unsure or on VOD — the SDK then does not clamp; never guess a holdback.
seekableEnd (optional) Where the media currently ends, per the ENGINE. Only needed when the <video> element's seekable range is unreliable (THEOplayer reports Number.MAX_SAFE_INTEGER on live). Used for resume reachability and live-edge distance. Omit or return null when the element is trustworthy.
externalPlaybackState (optional) The content player's external (AirPlay) playback state: 'connecting', 'active' or 'inactive'; undefined when the adapter cannot detect it. Changes arrive as externalplaybackchange events (payload { state, target }, target 'airplay' or 'unknown') and the SDK records each one as DA-EXTERNAL-PLAYBACK-CHANGED. See External playback (AirPlay).
setExternalPlaybackAllowed(allowed) (optional) Allow or block external video playback of the content player.

HLS.js Adapter

The official HLS.js adapter is available as a separate package.

Install

npm install @dolby-optiview/ads-sdk-adapter-hlsjs hls.js

Requirements

  • One Hls instance for content. The ad HLS instance is created inside createAdAdapter.
  • One <video> element for content. The ad <video> is created by your factory inside the SDK-provided container.
  • HLS streams must contain EXT-X-PROGRAM-DATE-TIME tags for wallclock-timebase channels.

Full setup example

import Hls from 'hls.js';
import { OptiViewAds } from '@dolby-optiview/ads-sdk-core';
import { HlsJsAdapter } from '@dolby-optiview/ads-sdk-adapter-hlsjs';

const video = document.getElementById('video') as HTMLVideoElement;

const hls = new Hls();
hls.attachMedia(video);

const sdk = new OptiViewAds({
  player: new HlsJsAdapter(hls, video),
  container: document.getElementById('container'),
  createAdAdapter: (adContainer) => {
    const adVideo = document.createElement('video');
    adContainer.appendChild(adVideo);
    const adHls = new Hls();
    adHls.attachMedia(adVideo);
    return new HlsJsAdapter(adHls, adVideo);
  },
  gam: {}, // presence enables GAM; the identity comes from the manifest
});

sdk.addEventListener('adbreakbegin', (e) => {
  console.log('Ad break', e.break.id, 'started —', e.break.duration, 's');
});
sdk.addEventListener('adbreakend', () => {
  console.log('Content resuming');
});

await sdk.startSession({
  manifestUrl: 'https://manifest.example.com/v1/your-org/channels/your-channel',
});

hls.loadSource('https://example.com/live.m3u8');
video.play();

Seek & seeked event

The HLS.js adapter implements seek(time) by setting video.currentTime and forwards the native seeked video event, which the SDK uses to detect viewer seeks that cross unwatched breaks.

On desktop and mobile web, VOD snapback also protects unplayed mediatime-scheduled client-side breaks: a seek that crosses one starts that break at once, while content lands paused on the viewer's target and resumes there after the ad. Nothing is seeked back. Prefer sdk.seek(time) so the break starts before the player moves. Direct player seeks are detected through seeked, with scheduler jumps greater than two seconds as a fallback. HLS.js, Shaka, THEOplayer and native video use the same policy. TV browsers (including Tizen, webOS, Vizio/SmartCast and RN TV-web shells) are excluded. Custom adapters must forward seeked and content position samples, and expose videoElement where they have one: the SDK uses its frame callbacks to cut VOD and live breaks just before their marker.

PDT (Program Date Time)

The HLS.js adapter automatically tracks EXT-X-PROGRAM-DATE-TIME from the manifest and exposes it via programDateTime. This is used by the SDK to match wallclock-timebase breaks against the live stream position.

If your stream does not include EXT-X-PROGRAM-DATE-TIME tags, wallclock breaks cannot be matched. Ensure your origin adds these tags to HLS manifests.

Cleanup

// When the player is torn down:
sdk.destroy(); // also destroys the internal ad player
hls.destroy();

Shaka Player Adapter

The official Shaka Player adapter is available as a separate package. It supports HLS and DASH streams and extracts programDateTime from Shaka's presentation timeline for live streams.

Install

npm install @dolby-optiview/ads-sdk-adapter-shaka shaka-player

Requirements

  • Shaka Player 4.x or 5.x
  • Call shaka.polyfill.installAll() once before creating any shaka.Player instance

Full setup example

import shaka from 'shaka-player';
import { OptiViewAds } from '@dolby-optiview/ads-sdk-core';
import { ShakaAdapter } from '@dolby-optiview/ads-sdk-adapter-shaka';

// 1. Install Shaka polyfills (once per page)
shaka.polyfill.installAll();

// 2. Content player
const video = document.getElementById('video') as HTMLVideoElement;
const player = new shaka.Player(video);

// 3. SDK — pass Player WITHOUT video to avoid eager MediaSource init on the ad element
//    playerContainer is optional; SDK auto-wraps when omitted
const sdk = new OptiViewAds({
  player: new ShakaAdapter(player, video),
  container: document.getElementById('container'),
  createAdAdapter: (adContainer) => {
    const adVideo = document.createElement('video');
    adContainer.appendChild(adVideo);
    return new ShakaAdapter(new shaka.Player(), adVideo);
  },
});

// 5. Start session and load stream
await sdk.startSession({
  manifestUrl: 'https://manifest.example.com/v1/your-org/channels/your-channel',
});
await player.load('https://example.com/live.m3u8');
video.play();

PDT (Program Date Time)

For live HLS streams with EXT-X-PROGRAM-DATE-TIME, the Shaka adapter derives the wall-clock position from Shaka's PresentationTimeline.getInitialProgramDateTime() (the manifest's PDT anchor) combined with video.currentTime. This is used to match wallclock-timebase breaks.

PDT is only reported when the manifest actually carries EXT-X-PROGRAM-DATE-TIME. It returns null for VOD content and for live streams without one — Shaka's synthesized presentation start trails wallclock by the live delay and is deliberately not used, so the SDK falls back to its wallclock clock exactly as with the other adapters.

In-stream timed metadata (ID3 / emsg)

The Shaka adapter forwards in-stream markers to the SDK as timedmetadata cues — used to relay ad-tracking metadata to IMA during SSAI, and to match Anvato in-stream break signaling when ptsSource: 'anvatoCue' is configured (see Configuration).

No Shaka configuration is required. Shaka extracts in-band ID3 from MPEG-TS segments out of the box; you do not need to change streaming/mediaSource settings or register an emsg scheme.

The adapter subscribes to three Shaka events:

Shaka event When it fires Why the adapter uses it
metadataadded at parse/append time, as soon as a segment buffers delivers cues ahead of the playhead — required for Anvato break cues (see below)
metadata when the playhead enters the marker's region covers markers that were already buffered before the adapter attached
emsg when the playhead enters a DASH emsg box DASH/CMAF event messages, e.g. the Anvato scheme urn:anvato:es1:052016

Emsg cues keep their raw payload bytes, so Anvato signaling also works when the marker is a full ID3 GEOB tag wrapped in the standardized ID3-in-emsg carriage (https://aomedia.org/emsg/ID3 / Apple's https://developer.apple.com/streaming/emsg-id3) — the core unwraps the tag itself; the adapter just forwards the bytes.

The adapter emits parsed and presented for each marker. The SDK forwards raw ID3 bytes at parse time, so IMA schedules them by media time, and forwards frames-only markers at presentation time.

Two behaviours are specific to Shaka and handled inside the adapter:

  • GEOB frames are decoded by the adapter, not by Shaka. shaka.util.Id3Utils has no GEOB decoder, so Shaka reports such frames with an empty description, a null MIME type and the whole undecoded frame body as data. The adapter parses that body itself so the cue carries the real description (Anvatos), mimeType (application/json) and payload (type=cue&pts=…). Players that already decode GEOB are passed through untouched.
  • Anvato cues must be seen before their media time. An Anvato cue's media time is the break start, so a playhead-time-only subscription would learn it too late to arm and preload the break. Subscribing to metadataadded gives the adapter the same parse-time delivery HLS.js has.

DASH emsg cues also carry ptsOffset, read from the carrying segment reference's timestampOffset in Shaka's manifest model, so an Anvato cue is placed at its own pts rather than at its segment start (see Implementing a Custom Adapter → DASH emsg timing).

Shaka exposes no parse-time event for DASH emsg (only a playhead-entry one), so Anvato signaling carried over DASH emsg resolves its cue at the break start rather than ahead of it. Anvato over HLS ID3 — how NFL Channel / NFL Network signal — is unaffected. Tracked as PLAYG-351.

Picture-in-picture on Safari

Safari cannot move a picture-in-picture window to a second <video>, so a break that starts in PiP plays the ad through Shaka's own element: the adapter detaches Shaka for the ad and re-attaches it with load() when the break ends. Keep the SDK's default ad engine for that element (omit createAdAdapter, or return defaultAdAdapter(container, sharedVideo) when the second argument is set). At break end the SDK first tells that ad engine to stand down without emptying the element, then reloads content through Shaka, so the window stays open and content resumes where it left off.

Structural typing — no hard import on shaka-player

The ShakaAdapter constructor accepts any object that satisfies the ShakaPlayerLike interface exported from the package. The real shaka.Player satisfies this interface, but you can also pass a compatible mock in tests without importing the full Shaka library.

Cleanup

// When the player is torn down:
sdk.destroy(); // also destroys the internal ad player
await player.destroy();

THEOplayer Adapter

The official THEOplayer adapter is available as a separate package. Unlike HLS.js and Shaka, THEOplayer manages its own internal <video> element — you pass it a <div> container and it renders into that.

Install

npm install @dolby-optiview/ads-sdk-adapter-theoplayer theoplayer

Requirements

  • THEOplayer v9 or later (peer dependency)
  • A valid THEOplayer license key (passed in the player configuration)
  • Set libraryLocation to serve THEOplayer's worker/WASM files — use a CDN or copy from node_modules/theoplayer/

Key difference — no raw <video> element

THEOplayer creates and manages its own <video> element inside the container div. The adapter exposes it via the videoElement getter (container.querySelector('video')) for GAM integration.

Full setup example

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

const LICENSE = 'YOUR_THEOPLAYER_LICENSE';
const LIB = 'https://cdn.jsdelivr.net/npm/theoplayer@11.4.0/';

// 1. Content player — THEOplayer mounts into a <div>
const playerDiv = document.getElementById('player') as HTMLElement;
const player = new ChromelessPlayer(playerDiv, {
  license: LICENSE,
  libraryLocation: LIB,
  allowMixedContent: true,
  mutedAutoplay: 'all',
});
// 2. SDK — playerContainer is optional; SDK auto-wraps when omitted
const sdk = new OptiViewAds({
  player: new THEOplayerAdapter(player, playerDiv),
  container: document.getElementById('container'),
  createAdAdapter: (adContainer, sharedVideo) => {
    // Shared-element breaks (Safari picture-in-picture, OS-native fullscreen) hand over the
    // content <video>; a ChromelessPlayer cannot adopt an existing element, so let the SDK's
    // own engine play there.
    if (sharedVideo) return defaultAdAdapter(adContainer, sharedVideo);
    const adPlayer = new ChromelessPlayer(adContainer, {
      license: LICENSE,
      libraryLocation: LIB,
      allowMixedContent: true,
      mutedAutoplay: 'all',
    });
    return new THEOplayerAdapter(adPlayer, adContainer);
  },
});

// 3. Start session and load stream
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();

defaultAdAdapter is exported by @dolby-optiview/ads-sdk.

THEOlive sources

For a THEOlive source the adapter reads the ads manifest URL from the THEOlive discovery response, so startSession() can omit manifestUrl. Turn it on 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({});

The adapter only reads the response; it never changes it. See Ads manifest from THEOlive discovery for the waiting, rejection and restart rules.

Picture-in-picture on Safari

Safari does not let the SDK move a picture-in-picture window to a second <video>, so a break that starts in PiP plays the ad through the content player's own element and hands it back to THEOplayer afterwards. Two things are required for the window to survive the break:

  • createAdAdapter must honour the sharedVideo argument as shown above. A ChromelessPlayer created for the handed-over element fails inside THEOplayer's IMA module (AdError 1101) and the break never starts.
  • A THEOplayer build that keeps the media element's resource attached across a source change while the element is in PiP. THEOplayer Web SDK 11.12.1 and earlier empty the element on every source change, and WebKit closes the window the moment an element has no media resource — the SDK cannot prevent that from outside the player. A player-side change is in progress with the THEOplayer team.

Expect one blank frame when content resumes: the browser resets the decoder when THEOplayer attaches the content MediaSource over the ad's. Setting preload: 'auto' (or 'metadata') on the content player shortens the gap.

Autoplay configuration

The ad player's play() is triggered by the SDK's break scheduler — always outside a user gesture. Set mutedAutoplay: 'all' in the ChromelessPlayer config for both the content and ad player instances. This tells THEOplayer to permit autoplay regardless of browser policy.

Omitting mutedAutoplay: 'all' will cause the ad player to silently refuse to play on browsers with strict autoplay policies (Chrome, Safari, most Smart TV WebViews).

PDT (Program Date Time)

The THEOplayer adapter reads player.currentProgramDateTime directly — THEOplayer exposes the wall-clock position as a Date on that property for live HLS/DASH streams. No custom manifest parsing is needed.

DASH emsg timing

On DASH, the adapter reads each MPD through THEOplayer's response interceptor (player.network) and sets ptsOffset on emsg cues, so an Anvato break starts at its signaled pts rather than at the start of the segment that carries the cue. A THEOplayerLike without network keeps the segment-start timing. The Android THEOplayer adapter does the same through player.getNetwork().

Cleanup

sdk.destroy(); // also destroys the internal ad player
player.destroy();

Native / Safari & iOS (NativeVideoAdapter)

@dolby-optiview/ads-sdk ships a NativeVideoAdapter backed by a plain HTMLVideoElement. The default ad player (a RoutingAdAdapter) chooses its playback technology from the ad creative, not from Hls.isSupported() alone — so it uses NativeVideoAdapter in two cases:

  • a progressive STATIC creative (MP4/WebM/…) — routed to native <video> even on MSE browsers where HLS.js is available, because HLS.js can only parse HLS playlists (feeding it an MP4 fails with manifestParsingError);
  • any creative on platforms without a Media Source engine (Hls.isSupported() === false), notably iPhone/iPod on iOS < 17.1 and older iOS/tvOS WebViews, which play HLS natively via video.src.

An HLS playlist creative (.m3u8 / application/vnd.apple.mpegurl) goes through the HlsJsAdapter when HLS.js is supported. The technology is decided at load() time from the URL extension, with a Content-Type HEAD probe for extensionless URLs (e.g. GAM pod manifests, which stay on HLS.js); anything that can't be classified defaults to HLS.js.

iOS 17.1+ uses HLS.js for HLS creatives. Apple's Managed Media Source (MMS) is available on iPhone from iOS 17.1, so Hls.isSupported() returns true and HLS playlist creatives play through the HlsJsAdapter (full ABR, quality/track selection, precise buffering); progressive MP4 creatives still use NativeVideoAdapter. On older iOS and other MSE-less runtimes everything falls back to NativeVideoAdapter.

// Inside @dolby-optiview/ads-sdk's default ad adapter, per creative at load() time:
// The Content-Type probe is bounded at 5s; a host that never answers falls back to 'hls'.
const tech = selectAdTech(url); // 'native' | 'hls' (extension, then Content-Type)
if (tech === 'hls' && Hls.isSupported()) {
  // → HlsJsAdapter (MSE) for HLS playlists
} else {
  // → NativeVideoAdapter (progressive MP4/WebM, or native HLS fallback)
}

You normally never construct it directly — use @dolby-optiview/ads-sdk and it is selected for you. Import it explicitly only if you build a custom factory:

import { NativeVideoAdapter } from '@dolby-optiview/ads-sdk';

Demo content player (PLAYG-36). The same NativeVideoAdapter also backs the demo's "Native HLS" content player option. The demo auto-selects it for the content <video> whenever Hls.isSupported() is false (the MSE-less tail: iPhone Safari < 17.1, older iOS/tvOS WebViews) so content still plays via video.src; on MSE/MMS-capable runtimes hls.js stays the default. You can also force it via the ?player=native URL param to exercise the native path on an MSE-capable browser such as macOS Safari.

PDT (Program Date Time)

Wallclock break matching is supported on native HLS: NativeVideoAdapter derives programDateTime from WebKit's non-standard HTMLVideoElement.getStartDate() (the presentation origin's wallclock) plus currentTime, mirroring how the HLS.js adapter computes it. It returns null only on engines without getStartDate() or when the date is invalid — in which case wallclock matching is unavailable for that stream.

iPhone / iPod: adaptive & shared-element insertion

On iPhone/iPod, adInsertion: 'auto' (the default) resolves based on Managed Media Source availability:

  • iOS 17.1+ (MMS present) → adaptive. Playback runs through HLS.js/MMS, so the SDK uses the full overlay compositor (all break formats) while the content video is inline, and falls back to a single fullscreen shared-element ad only while the content video is in OS-native fullscreen (where DOM overlays cannot render). The mode is re-evaluated per break from the content video's webkitDisplayingFullscreen state / webkitbeginfullscreen/webkitendfullscreen events.
  • iOS < 17.1 (no MMS) → shared-element. The ad plays through the content <video> rather than a separate ad element; advanced formats are downgraded to a single fullscreen ad and lshape_content is skipped.

See SDK Configuration → Ad insertion behaviour.

AirPlay note: The SDK-owned ad element always has disableRemotePlayback=true, so ads are never AirPlayed. To AirPlay your content on Safari with MMS, append an HLS <source> element to your own content <video>; see External playback (AirPlay).

External playback (AirPlay)

The SDK needs to know when the content video is rendered on an AirPlay receiver (client-side ads rendered on the device are not seen there), and to hold the video on the device when it must. Content adapters report and gate the content player's external playback through two optional PlayerAdapter members: externalPlaybackState plus the externalplaybackchange event, and setExternalPlaybackAllowed(allowed). The SDK keeps its own players off AirPlay: a second player allowed to AirPlay takes the TV on play() and AVFoundation then pauses the content player, so the ad <video> has disableRemotePlayback and the iOS warm-up and pause-ad players set allowsExternalPlayback = false. The iOS ad player does too, with one exception: while a blocked AirPlay request waits during a break, the ad player takes the receiver, so iOS does not fall back to an audio-only route that stalls the ad; at the break end the SSB switch takes the receiver over (see Break Manifest → Server-side beaconing stream). The SDK only observes: each change is recorded as one DA-EXTERNAL-PLAYBACK-CHANGED diagnostic (state, target) and sessions that never see an AirPlay route behave as before.

The SSB switch (see Break Manifest → Playing the SSB stream over AirPlay) reloads the adapter's previous source when AirPlay stops, so a content adapter must report sourceUrl (PlayerAdapter.sourceUrl; the built-in adapters report it); without it the switch is refused with DA-SSB-SWITCH-FAILED (no-restore-source) and AirPlay stays on the device.

connecting is a hint: the route moved to an AirPlay output, but video may or may not follow (screen mirroring and audio-only targets look the same). active is authoritative: the receiver renders the video. inactive follows either. On iOS, a closed gate while the route stays on AirPlay reads connecting. The THEOplayer iOS adapter reports a connected route as connecting until the backing AVPlayer reports isExternalPlaybackActive; a player that reports the route as active directly, without a connecting step (THEOplayer when its backing player cannot be reached), is treated as a request as well. The gate holds the video only: closing it while the route is on AirPlay leaves the audio on the receiver until the viewer ends the route.

Adapter Signal Gate
NativeVideoAdapter, HLS.js, Shaka Remote Playback API (video.remote), with the WebKit AirPlay signal as fallback video.disableRemotePlayback
THEOplayer (web) player.cast.airplay (a drop is held like the element helper does; the element's wireless signal ends the hold), else the element signals above. THEOplayer web ends its AirPlay session on a source change while connected (see below) video.disableRemotePlayback on the resolved element
AVPlayerAdapter (iOS/tvOS) AVAudioSession route change (connecting) and AVPlayer.isExternalPlaybackActive (active) AVPlayer.allowsExternalPlayback
THEOplayerAdapter (iOS/tvOS) player.cast.airPlay state for the route and the backing AVPlayer.isExternalPlaybackActive for active (iOS only; tvOS never reports) THEOplayer.allowsExternalPlayback
ExoPlayerAdapter (Android) Not supported; never reports No-op

When the manifest carries a server-side beaconing (ssb) stream, the SDK closes this gate for the session and blocks AirPlay during and just before ad breaks (see Break Manifest → Server-side beaconing stream).

The SDK also closes the gate on the separate ad adapter it creates through createAdAdapter, once, right after prepareForAdPlayback. On Safari, an AirPlay-eligible ad element that starts playing ends the content player's route. Custom ad adapters should implement setExternalPlaybackAllowed (or set disableRemotePlayback on the <video> they create). defaultAdAdapter already sets disableRemotePlayback on its own element.

On Safari (verified on macOS Safari 27) the closed gate only removes the AirPlay affordances: remote.prompt() is refused and the native controls hide their AirPlay button, but a player UI that calls webkitShowPlaybackTargetPicker() still starts AirPlay, and closing the gate does not end a route that is already active. A request the guard blocks during a break therefore shows the paused content video on the TV until the break ends and the SSB switch runs; the switch itself still works because Safari re-establishes the route on the source change.

Web adapters expose the same behaviour through @dolby-optiview/ads-sdk-core/external-playback (observeExternalPlayback, setExternalPlaybackAllowed), which custom web adapters can reuse. On Safari the helper treats webkitCurrentPlaybackTargetIsWireless as the authoritative active signal (Safari's Remote Playback state can fall back to connecting while the receiver keeps playing) and holds a disconnect for 500 ms before reporting inactive, extending to 5 s once Safari starts reconnecting: a source change while AirPlaying drops and re-establishes the route by itself, and that must not read as AirPlay ending.

THEOplayer web applies the same hold to cast.airplay. Note a THEOplayer limitation (verified with THEOplayer 11.4.0 on macOS Safari 27): when the source changes while cast.airplay is connected, THEOplayer ends the AirPlay session and does not load the new source until it is set again. The SSB switch therefore cannot reach the receiver on this host: the switch's own source change ends the route, the SDK restores the content (DA-DELIVERY-MODE-RESOLVED with cause=external-playback-ended) and AirPlay has to be started again by the viewer. Until THEOplayer supports source changes during AirPlay, prefer a manifest without ssb for THEOplayer web on Safari, or accept that the viewer loses AirPlay when the switch runs.

Implementing a Custom Adapter

To use the SDK with Video.js, AVPlayer (iOS), or any other HLS-capable player, implement the PlayerAdapter interface.

TypeScript skeleton

import type {
  PlayerAdapter,
  PlayerAdapterEvent,
  PlayerAdapterEventHandler,
} from '@dolby-optiview/ads-sdk-core';

export class MyPlayerAdapter implements PlayerAdapter {
  private player: MyPlayer; // ← your player instance
  private video: HTMLVideoElement;
  private listeners = new Map<PlayerAdapterEvent, Set<PlayerAdapterEventHandler>>();
  private _programDateTime: Date | null = null;

  constructor(player: MyPlayer, videoElement: HTMLVideoElement) {
    this.player = player;
    this.video = videoElement;
    this.setupListeners();
  }

  // ── Required properties ──────────────────

  get currentTime() {
    return this.video.currentTime;
  }
  get duration() {
    return this.video.duration;
  }
  get paused() {
    return this.video.paused;
  }
  get muted() {
    return this.video.muted;
  }
  set muted(v) {
    this.video.muted = v;
  }
  get volume() {
    return this.video.volume;
  }
  set volume(v) {
    this.video.volume = v;
  }

  get programDateTime(): Date | null {
    // Track EXT-X-PROGRAM-DATE-TIME from your player's manifest events
    return this._programDateTime;
  }

  // ── Required methods ─────────────────────

  pause(): void {
    this.video.pause();
  }

  async play(): Promise<void> {
    await this.video.play();
  }

  seek(time: number): void {
    this.video.currentTime = time; // adapt to your player's seek API if needed
  }

  /** Load URL — resolve when manifest is parsed and player is ready to play. */
  async load(url: string): Promise<void> {
    return new Promise((resolve, reject) => {
      this.player.once('manifestparsed', resolve); // adapt to your player's event
      this.player.once('error', reject);
      this.player.load(url);
    });
  }

  on(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler): void {
    if (!this.listeners.has(event)) this.listeners.set(event, new Set());
    this.listeners.get(event)!.add(handler);
  }

  off(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler): void {
    this.listeners.get(event)?.delete(handler);
  }

  destroy(): void {
    this.listeners.clear();
    // Remove any event listeners added in setupListeners()
  }

  // ── Internal helpers ─────────────────────

  private emit(event: PlayerAdapterEvent, data?: unknown): void {
    this.listeners.get(event)?.forEach((h) => h(data));
  }

  private setupListeners(): void {
    // Forward native video events to SDK listeners
    this.video.addEventListener('timeupdate', () => this.emit('timeupdate'));
    this.video.addEventListener('ended', () => this.emit('ended'));
    this.video.addEventListener('error', () => this.emit('error'));
    this.video.addEventListener('seeked', () => this.emit('seeked'));
    this.video.addEventListener('volumechange', () => this.emit('volumechange'));

    // Track PDT from your player's manifest events
    this.player.on('fragmentchanged', (frag) => {
      if (frag.programDateTime) this._programDateTime = new Date(frag.programDateTime);
    });
  }
}
Key implementation notes:
• load(url) must resolve only when the player is ready to start playback immediately — not just when the request is sent.
• programDateTime must reflect the current stream position, not just the start of the manifest.
• The SDK passes a <div> container to createAdAdapter. Create your own <video> inside it — never share the content player instance or its video element.

DASH emsg timing (ptsOffset)

A DASH emsg whose presentation_time_delta is 0 is reported by players at the start of the segment that carries it, not at the PTS its payload names. Anvato DASH signals breaks this way (type=cue&pts=…). If your player exposes the stream manifest, set ptsOffset on each emsg cue: the player time minus the stream's PTS clock, in seconds, which for DASH is Period@start − presentationTimeOffset / timescale. The core then schedules the break at pts + ptsOffset, reading the payload pts as seconds or, when only that lands in the cue's segment, as milliseconds (NFL Channel signals milliseconds). It ignores an offset that lands more than 0.1s before or 15s after the cue's startTime (DA-ANVATO-CUE-OFFSET-REJECTED). Without ptsOffset, an Anvato emsg cue keeps its segment-start time and the core reports DA-ANVATO-CUE-SEGMENT-ANCHORED once.

Validate your adapter

@dolby-optiview/ads-sdk-adapter-test-kit provides a shared conformance suite so you can prove your adapter satisfies the contract the SDK relies on (event forwarding, state mirroring, seek, destroy cleanup, and optional capabilities). The official HLS.js and Shaka adapters run the same kit.

# not on npmjs: install the tarball from the artefact host (see Install → Web)
npm install -D <artefact host>/web/<channel>/<version>/dolby-ads-adapter-test-kit-<version>.tgz
// MyPlayerAdapter.conformance.test.ts
import { runAdapterConformance } from '@dolby-optiview/ads-sdk-adapter-test-kit';
import { MyPlayerAdapter } from './MyPlayerAdapter';

runAdapterConformance('MyPlayerAdapter', {
  // Construct your adapter around the kit-provided <video> element.
  createAdapter: (video) => new MyPlayerAdapter(createMyPlayer(), video),
  // Declare which optional members you implement so the matching checks run.
  capabilities: { videoElement: true, preload: false, parallelBuffering: false },
});

The kit registers its own describe/it blocks, so just call runAdapterConformance(...) at the top level of a test file. By default it makes the underlying source emit each event by dispatching a native Event on the video element; pass a custom emit(video, event) if your player surfaces events differently.

Android (Kotlin)

During Android ad breaks, host audio changes update the ad's viewer mute and volume. Double-box content remains silent when ad audio is selected and restores the latest viewer choice when the break ends. One bounded focus reclaim handles a host audio change; unrelated permanent focus loss still pauses the ad. Both direct and VAST ads report DA-AD-STALLED when expected playback stops progressing for three seconds.

For scrubber markers, call sdk.getScheduledBreaks() or subscribe to OptiViewAdsEventType.SCHEDULEDBREAKSCHANGE and read ScheduledBreaksChangeEvent.breaks. The copied list includes viewer-playable pre/mid/post breaks, manifest durations, content start seconds (null for post-rolls, wallclock, and unresolved PTS), ISO wallclock dates, and a played flag set after break-begin. It excludes pause ads, bookmark-skipped pre-rolls and overlap skips; earlier bookmark mid-rolls remain. Equal snapshots emit nothing; session end clears the list.

Break status ends with COMPLETE → IDLE → adbreakend. Subscribe to completion rather than polling for it: the getter is idle after cleanup. Cuts/errors also complete an active break; skipped breaks and session teardown do not. See Ad break status for terminal fields and UI handling. See Start VOD from a bookmark for Media3 and THEOplayer startup positioning on Android and Android TV.

With LiveStartPushbackConfig(enabled = true), initial live playback starts five target durations behind the reported edge when metadata and the DVR window allow it. It is off by default for every ptsSource, including PtsSource.ANVATO_CUE. Use liveStartPushback = LiveStartPushbackConfig(enabled = true, targetDurationSeconds = 10.0) with the stream's actual TD on hosts without declared metadata; Media3 HLS supplies it automatically. Startup request and landing diagnostics include offsets in seconds and TD multiples.

With ptsSource = PtsSource.ANVATO_CUE on DASH, the THEOplayer adapter sets TimedMetadataCue.ptsOffset from the stream's own Anvato beacons (type=beacon&pts=…), as the iOS SDK does on HLS, so an Anvato break starts at the cue's signaled pts instead of where the packager placed its emsg. The Media3 adapter does not supply it yet: its live position is relative to the moving live window, so an Anvato DASH break there can still start up to one segment early (DA-ANVATO-CUE-SEGMENT-ANCHORED).

With ptsSource = PtsSource.ANVATO_CUE, a live break that resumes at its end resumes on the stream's matched type=cue_end (DA-RESUME-CUE-END) instead of the cue plus the advertised duration, so content returns after the slate, not 0.2 s inside it. A cue_end matched only after the hand-back moves content forward once when it is more than 1 s ahead, never back (DA-RESUME-CUE-END-LATE). Paused content is parked exactly on the resume point before the ad ends (DA-RESUME-PREPARED), so the hand-back only plays. Parking on cue + duration once the stream past it is downloaded also makes a paused THEOplayer hand the cue_end over, and content is then parked on it.

When a live break ends before its scheduled end (the ads ran out and no slate is configured), its resume point is not published yet. Content then resumes at the player's live edge instead of waiting for the stream to reach the break end (DA-RESUME-TARGET-CLAMPED with bound: end).

The OptiView Ads SDK ships a native Android / Android TV SDK in Kotlin. It implements the same Server-Guided Ad Insertion model as the web SDK — manifest polling, break scheduling on the programDateTime timebase, the ad-event lifecycle, GAM/DAI pod serving, and the redactable diagnostics stream — built on Media3 / ExoPlayer.

Targeting uses platform android, OS android, and the Android release reported by the device. Variant, delivery, and asset-URI targeting share the same profile.

Like the web SDK, the core is player-agnostic: it drives your content player only through the PlayerAdapter interface, so you can use the bundled Media3 adapter or implement your own.

The break-cut countdown starts on actual ad playback, not media loading or STATE_READY. The full effective duration plus adBreakCutSafetyMarginSec is then available. Buffering does not restart it; startup has an independent fail-open timeout. React Native Android uses the same renderer and timing.

Getting Started

Requirements

  • Android minSdk 21 (Android TV supported), compileSdk 34
  • Media3 / ExoPlayer 1.4.x
  • For Google Ad Manager pod serving: the IMA SDK (com.google.ads.interactivemedia.v3:interactivemedia)

Installation

Stable releases use the public THEOplayer Maven repository. Add it to settings.gradle.kts, retaining Google and Maven Central for third-party libraries:

dependencyResolutionManagement {
    repositories {
        maven { url = uri("https://maven.theoplayer.com/releases") }
        google()
        mavenCentral()
    }
}

For a beta or other tagged prerelease, also add maven { url = uri("https://maven.theoplayer.com/snapshots") } and pin the exact version, such as 1.0.0-beta.1. Keep /releases for stable dependencies; do not use snapshotsOnly(), because prerelease versions retain their original suffix. Develop/custom builds still use the artifact-host flow in Install / Distribution. The app also needs JDK 17 and android.useAndroidX=true.

// build.gradle.kts (app module) — published coordinates
dependencies {
    implementation("com.dolby.optiview:ads-sdk-runtime:<version>")  // ExoPlayerAdapter + OverlayAdRenderer + GAM/IMA
    // ads-sdk-runtime re-exports the core + sdk layers transitively.

    implementation("androidx.media3:media3-exoplayer:1.4.1")
    implementation("androidx.media3:media3-ui:1.4.1")
}

Player-free external provider parameters

When an application needs provider parameters before playback, use OptiViewAdsExternalVendors rather than creating a player-backed session:

val vendors = OptiViewAdsExternalVendors(
    OptiViewAdsExternalVendorsConfig(manifestUrl = manifestUrl)
)
vendors.start()
val parameters = vendors.getExternalVendorConfiguration("mediakind")?.assetParameters.orEmpty()
// Pass parameters to the external provider before playback starts.
vendors.stop()
vendors.destroy()

Quick start

import androidx.media3.common.MediaItem
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.ui.PlayerView
import com.dolby.optiview.ads.runtime.ExoPlayerAdapter
import com.dolby.optiview.ads.runtime.OverlayAdRenderer
import com.dolby.optiview.ads.sdk.CoroutineSchedulerTicker
import com.dolby.optiview.ads.sdk.OptiViewAds
import com.dolby.optiview.ads.sdk.OptiViewAdsConfig
import com.dolby.optiview.ads.sdk.OptiViewAdsEventType
import com.dolby.optiview.ads.sdk.HttpManifestSource
import com.dolby.optiview.ads.sdk.SessionConfig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch

val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

// 1. Content player — you own the ExoPlayer and attach it to your PlayerView.
val contentPlayer = ExoPlayer.Builder(context).build()
playerView.player = contentPlayer
val contentAdapter = ExoPlayerAdapter(contentPlayer)

// 2. Runtime seams: overlay ad renderer + HTTP manifest source + coroutine ticker.
//    `overlayContainer` is a FrameLayout stacked above your PlayerView; a `single`
//    break covers all of it, letterbox bars included.
val renderer       = OverlayAdRenderer(context, overlayContainer, contentAdapter)
val manifestSource = HttpManifestSource(scope)
val ticker         = CoroutineSchedulerTicker(scope)

// 3. Create the SDK.
val sdk = OptiViewAds(
    config = OptiViewAdsConfig(player = contentAdapter, debug = true),
    renderer = renderer,
    manifestSource = manifestSource,
    ticker = ticker,
    scope = scope,
)

// 4. Listen to events. Status completion is followed by idle, then adbreakend.
sdk.addEventListener(OptiViewAdsEventType.ADBREAKBEGIN) { e -> Log.d("Ads", "Break started: ${e.breakId}") }
sdk.addEventListener(OptiViewAdsEventType.ADBREAKEND)   { e -> Log.d("Ads", "Break ended: ${e.breakId}") }
sdk.addEventListener(OptiViewAdsEventType.ADBREAKSTATUS) { e ->
    val status = (e as AdBreakStatusEvent).status
    if (status.phase == AdBreakPhase.COMPLETE || status.phase == AdBreakPhase.IDLE) {
        Log.d("Ads", "Hide break UI")
    }
}
sdk.addEventListener(OptiViewAdsEventType.ADCHANNELCHANGE) { e ->
    Log.d("Ads", "Ad configuration changed: reason=${e.reason.value}, eventId=${e.eventId}, channel=${e.previousChannelId} -> ${e.channelId} (${e.previousDeliveryMode} -> ${e.deliveryMode})")
}

// 5. Load your content stream and start a monetization session.
contentPlayer.setMediaItem(MediaItem.fromUri("https://example.com/live.m3u8"))
contentPlayer.prepare()
contentPlayer.playWhenReady = true

scope.launch {
    sdk.startSession(SessionConfig(manifestUrl = "https://manifest.example.com/v1/your-org/channels/your-channel"))
}

During an active ad break, the event is emitted after that break finishes and the latest polled manifest is applied.

For live wallclock channel events, reason is event-boundary and eventId identifies the event now in effect, or is null when playback leaves an event. Previously played breaks stay played, and a break already in progress finishes before the new event configuration is applied.

Every published Android SDK version uses the same embedded manifest trust list: ads-prod-2026-08, ads-staging-2026-08, and ads-dev-2026-08. HttpManifestSource(scope) accepts an optional ManifestFetcher for transport integration, but its public constructor cannot accept custom trusted keys. The repository test key is available only to unit/conformance tests through an internal testability seam; CI does not select Android keys by branch or version.

All SDK calls run on the player's application thread — typically the main thread, per ExoPlayer's threading model. startSession is a suspend function: call it from a coroutine. Call sdk.destroy() (then release your ExoPlayer) when tearing down.

Ad formats & overlay rendering

Native ad creatives default to AdScaling.FIT (aspect-fit/contain), matching the web renderer's primary ad surfaces. Pass adScaling = AdScaling.FILL to opt into aspect-fill cropping. Companion/backdrop artwork remains cover-scaled independently, and fullscreen ad surfaces follow the visible content picture rectangle when the adapter reports intrinsic video dimensions.

OverlayAdRenderer renders every break format. For the overlay format it positions/sizes the ad surface from the manifest position/size/opacity and does not pause the content player (the ad plays on top of playing content); all other formats render full-surface and pause content. Overlay assets with mediaType: "image" are rendered in a ImageView (held for the asset's duration, falling back to the break duration), are preloaded for an instant transition, and on load failure dispatch aderror and are ignored — identical to the web and iOS runtimes. See Ad Formats.

Animated GIF and WebP companions, backdrops, image ads and pause images play on API 28 and above: the file is decoded off the main thread at the size the picture needs, drawn so that the content hole and the punch-through backing stay correct on every frame, and stopped at break end, on picture-in-picture and at teardown. Below API 28 the first frame is shown and DA-IMAGE-ANIMATION-UNSUPPORTED is reported once per image. Animated creatives are cached as raw bytes (at most 8 files and 16 MB) and refused above 8 MB.

A declared asset mimeType is used: an HLS or progressive type is set on the ExoPlayer MediaItem (a DASH type is not, as the runtime ships no DASH module), a still image type (image/png, image/jpeg, image/svg+xml) is decoded as a still without checking the file for frames, and image/gif or image/webp takes the animated path without checking the file either (below API 28 it shows the first frame and reports DA-IMAGE-ANIMATION-UNSUPPORTED). See Declared media type.

SGAI GAM and VAST controls share the ad video's visibility and disappear when its presentation ends, including after errors or a forced break cutoff. No application-side IMA view cleanup is required. Stitched SSAI controls remain separate from the SDK's ad video surface.

Reading the SDK version

Read the current SDK version from the static OptiViewAds.version accessor — no instance required. It is the same lockstep version as the web and iOS SDKs and the stitcher's GET /version.

import com.dolby.optiview.ads.sdk.OptiViewAds

Log.d("Ads", OptiViewAds.version) // e.g. "0.16.0"

Google Ad Manager (pod serving)

Supply a GamConfig to the renderer and to OptiViewAdsConfig. Its presence is the opt-in — the stream identity comes from the break manifest's vendorConfiguration. GAM vendor breaks are served via Google IMA DAI.

import com.dolby.optiview.ads.sdk.GamConfig

val gam = GamConfig()
val renderer = OverlayAdRenderer(context, overlayContainer, contentAdapter, gamConfig = gam)

val sdk = OptiViewAds(
    config = OptiViewAdsConfig(player = contentAdapter, gam = gam),
    renderer = renderer,
    manifestSource = manifestSource,
    ticker = ticker,
    scope = scope,
)

scope.launch {
    sdk.startSession(SessionConfig(manifestUrl = "https://manifest.example.com/v1/your-org/channels/your-channel"))
}
GAM assets are skipped, with DA-GAM-CONFIG-MISSING, if the break manifest carries no usable gam entry in vendorConfiguration. That is a backend/provisioning fix — the identity is deliberately not configurable here.

Break transitions (transition)

How the picture changes at the edges of a break. The ad surface is held back until the ad has actually rendered its first frame, then cuts in — the surface is shown, and at the end it is cut away in the same turn content resumes. Nothing fades: a fade over the content from the break start on shows the stream's own break under it, and with the ad's first frame already rendered there is nothing left for a fade to hide. The durationMs still times the two-box layout reflow (content box glide). Nothing is shown while the surface is still blank, which is what removes the black flash at a fullscreen (single) break.

OptiViewAdsConfig(
    player = contentAdapter,
    transition = TransitionConfig(),                              // first-frame hold + 300ms layout glide (default)
    // transition = TransitionConfig(type = TransitionType.NONE), // no hold, no layout animation (legacy snap)
    // transition = TransitionConfig(durationMs = 500),           // slower layout glide
)
Field Type Default Meaning
type FADE / NONE FADE FADE holds the surface until the first frame and glides the layout; NONE is the legacy snap (surface shown and content paused at once, no layout animation). The content/ad switch is a cut either way.
durationMs Long 300 The layout glide. Ignored for NONE.
The choice also decides the ad surface type: a SurfaceView's video is composited in its own punch-through layer, so View.alpha cannot hold it transparent while the first frame is awaited. FADE therefore renders ads into a TextureView, and NONE keeps the SurfaceView. Choose NONE if your ad creatives are DRM-protected: a TextureView cannot present secure output. It also costs somewhat more memory and power. The CONTENT surface is never touched — this applies only to the SDK's own ad view.

An ad that renders no frame at all — an audio-only creative, or a decoder that never answers — is revealed anyway once the ad-start deadline passes, so it can never play invisibly. Every reveal emits DA-AD-SURFACE-REVEALED with reason (first-frame vs reveal-timeout) and waitedMs, the wait that would otherwise have been a black gap.

For a format that covers content (single, lshape_ad), immediate pre-rolls and breaks whose first asset is VAST pause content immediately at break begin, including re-pausing late content PLAYING events. An immediate pre-roll with no adStartDelay also holds content from session wiring until the break takes over (DA-PREROLL-CONTENT-HELD), so a slow ad does not consume the opening content. Static mid-rolls and delayed pre-rolls retain the deferred pause: content keeps playing under the transparent ad surface until the ad starts. Content audio is muted from the start of the break (and restored at the end, preserving a viewer's own mute), because two pictures may overlap while the ad is still invisible but two soundtracks may not. Under adPreload = single-decoder the pause stays immediate: that mode exists to avoid holding two decoders, which is exactly what playing content through the ad's load would do. Either way the content resume at break end is unchanged.

Existing Adapter — ExoPlayerAdapter

The runtime ships ExoPlayerAdapter, a Media3/ExoPlayer implementation of PlayerAdapter. It wraps an ExoPlayer instance you create and own (attached to your own PlayerView); the SDK drives the content player only through this adapter, keeping the brain player-agnostic.

import com.dolby.optiview.ads.runtime.ExoPlayerAdapter

val contentPlayer = ExoPlayer.Builder(context).build()
val contentAdapter = ExoPlayerAdapter(contentPlayer)
// → pass as OptiViewAdsConfig.player (and to OverlayAdRenderer).
Concern Behaviour
Threading All calls must run on the player's application thread (typically the main thread). A single Player.Listener fans Media3 callbacks out to the adapter's event handlers.
programDateTime Derived from the live window's windowStartTimeMs plus the current position. Returns null for VOD / streams without a wallclock anchor, in which case wallclock-timebase breaks cannot be matched.
seek / seeked Ordinary seek(time) calls player.seekTo; seeked fires on a seek position discontinuity. sdk.seek(time) uses seekExact(time) with Media3 SeekParameters.EXACT, preserving the player's normal seek parameters afterwards. A SDK or player UI/Android TV remote seek that crosses an unwatched snapback break starts the last crossed one at once (no earlier fallback if it is already played or unplayable); content lands paused on the requested target under the ad and resumes there, with no seek back. Double Box, L-Shape Content and Overlay are ignored by snapback. Fullscreen PiP fallbacks at break start count as Single. THEOplayer forwards its seek completion through the same policy.
load setMediaItem + prepare — kicks off preparation and returns immediately; readiness is signalled via playing / waiting / ended events.

THEOplayer Adapter — THEOplayerAdapter

The ads-sdk-adapter-theoplayer artifact wraps a com.theoplayer.android.api.player.Player. THEOplayer is compileOnly in the adapter, so the host app provides its own com.theoplayer.theoplayer-sdk-android:core dependency.

// app/build.gradle.kts
implementation("com.dolby.optiview:ads-sdk-adapter-theoplayer:<version>")
implementation("com.theoplayer.theoplayer-sdk-android:core:<version>")
import com.dolby.optiview.ads.adapter.theoplayer.THEOplayerAdapter
import com.theoplayer.android.api.player.Player

val contentAdapter = THEOplayerAdapter(player)

For a THEOlive source the adapter reads the ads manifest URL from the THEOlive discovery response, so the session config can omit it. Turn it on with manifestUrlDiscovery = true (off by default) and create the SDK before you set the source:

val sdk = OptiViewAds(OptiViewAdsConfig(player = contentAdapter, manifestUrlDiscovery = true /* … */))
player.source = SourceDescription.Builder(TheoLiveSource("your-distribution-id")).build()
sdk.startSession(SessionConfig()) // manifestUrl = null: uses the discovered URL

See Ads manifest from THEOlive discovery for the waiting, rejection and restart rules.

PlayerAdapter Interface

Any content player is integrated by implementing PlayerAdapter from com.dolby.optiview.ads.core. Unlike the web adapter (whose load/play return Promises), the Kotlin load/play are synchronous — they kick off preparation/playback and return immediately; readiness and completion are signalled via PlayerAdapterEvents.

package com.dolby.optiview.ads.core

/** Event types a PlayerAdapter must forward. */
enum class PlayerAdapterEvent(val value: String) {
    TIMEUPDATE("timeupdate"),
    ENDED("ended"),
    ERROR("error"),
    SEEKED("seeked"),
    VOLUMECHANGE("volumechange"),
    WAITING("waiting"),
    PLAYING("playing"),
}

/** Handler payload carries adapter-specific detail (e.g. a media error). */
typealias PlayerAdapterEventHandler = (event: Any?) -> Unit

interface PlayerAdapter {
    /** Current playback time in seconds. */
    val currentTime: Double

    /** Total content duration in seconds; Double.POSITIVE_INFINITY for live. */
    val duration: Double

    /** Whether the player is currently paused. */
    val paused: Boolean

    /** Muted state. Settable so the SDK can sync content↔ad mute. */
    var muted: Boolean

    /** Volume in [0, 1]. Settable so the SDK can sync content↔ad volume. */
    var volume: Double

    /** Program Date Time (EXT-X-PROGRAM-DATE-TIME) as epoch milliseconds,
     *  for wallclock-timebase break matching. Null when unavailable. */
    val programDateTime: Long?

    /** Pause playback (called when an ad break starts). */
    fun pause()

    /** Resume playback (called when an ad break ends). Returns immediately. */
    fun play()

    /** Seek to time seconds (used for snapback during locked breaks). */
    fun seek(time: Double)
    fun seekExact(time: Double) // SDK-owned post-break resume positioning

    /** Load a media source without committing to immediate playback. */
    fun load(url: String)

    /** Optional: warm caches WITHOUT engaging a decoder (single-decoder preload). */
    fun preload(url: String) {}

    /** Optional capability hint: can this adapter buffer a second source in
     *  parallel without decoder contention? Null is treated as true. */
    val supportsParallelBuffering: Boolean?
        get() = null

    /** Optional: the player instance this adapter wraps (e.g. the ExoPlayer),
     *  the same object for the adapter's lifetime. Lens keys the shared
     *  observability session on it. */
    val wrappedPlayer: Any?
        get() = null

    /** Subscribe to a player event. */
    fun on(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler)

    /** Unsubscribe a previously registered handler. */
    fun off(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler)

    /** Clean up resources (called when the SDK is destroyed). */
    fun destroy()
}
Member Notes
programDateTime Epoch milliseconds (Long?), not a Date — keeps the brain dependency-free. Critical for live streams with timebase: "wallclock"; return null if the stream has no PDT.
load(url) Kicks off preparation and returns immediately. Signal readiness via the playing/waiting events rather than blocking.
seek(time) Used by the SDK to snap back to a break start when controls.snapback is set and an unexpected seek is detected.
on / off The SDK listens to timeupdate for break timing, ended for asset completion, error for recovery, seeked for snapback, and volumechange / waiting / playing for state sync.
preload / supportsParallelBuffering Optional. Override preload only if your player supports a detached cache warm; leave the defaults otherwise.
wrappedPlayer Optional. Return the player object the app created and passed to your adapter, never a copy, an ID or a wrapper. The SDK never calls it; Lens compares it by reference to share one session with other Lens integrations on that player.

Implementing a Custom Adapter

To use the SDK with a different player, implement PlayerAdapter and forward your player's callbacks to the SDK event handlers.

import com.dolby.optiview.ads.core.PlayerAdapter
import com.dolby.optiview.ads.core.PlayerAdapterEvent
import com.dolby.optiview.ads.core.PlayerAdapterEventHandler

class MyPlayerAdapter(private val player: MyPlayer) : PlayerAdapter {

    private val handlers = mutableMapOf<PlayerAdapterEvent, MutableSet<PlayerAdapterEventHandler>>()

    init {
        // Forward your player's callbacks to the SDK.
        player.onPositionChanged { dispatch(PlayerAdapterEvent.TIMEUPDATE) }
        player.onEnded          { dispatch(PlayerAdapterEvent.ENDED) }
        player.onError          { err -> dispatch(PlayerAdapterEvent.ERROR, err) }
        player.onSeeked         { dispatch(PlayerAdapterEvent.SEEKED) }
        player.onVolumeChanged  { dispatch(PlayerAdapterEvent.VOLUMECHANGE) }
    }

    // ── Required properties ──────────────────
    override val currentTime: Double get() = player.positionMs / 1000.0
    override val duration: Double get() = if (player.isLive) Double.POSITIVE_INFINITY else player.durationMs / 1000.0
    override val paused: Boolean get() = !player.isPlaying

    override var muted: Boolean
        get() = player.volume == 0f
        set(value) { player.volume = if (value) 0f else 1f }

    override var volume: Double
        get() = player.volume.toDouble()
        set(value) { player.volume = value.coerceIn(0.0, 1.0).toFloat() }

    override val programDateTime: Long?
        get() = player.currentProgramDateEpochMs   // null for VOD / no PDT

    // ── Required methods ─────────────────────
    override fun pause() = player.pause()
    override fun play()  = player.play()
    override fun seek(time: Double) { player.seekTo((time * 1000).toLong()) }
    override fun load(url: String)  { player.setSource(url); player.prepare() }

    override fun on(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler) {
        handlers.getOrPut(event) { mutableSetOf() }.add(handler)
    }

    override fun off(event: PlayerAdapterEvent, handler: PlayerAdapterEventHandler) {
        handlers[event]?.remove(handler)
    }

    override fun destroy() {
        handlers.clear()
        // Remove any listeners registered on `player`.
    }

    private fun dispatch(event: PlayerAdapterEvent, payload: Any? = null) {
        handlers[event]?.toList()?.forEach { it(payload) }
    }
}
Key implementation notes:
• load(url) and play() return immediately — signal readiness through playing/waiting events, never block.
• programDateTime must reflect the current stream position (epoch ms), not just the start of the manifest.
• Never share the content player instance with the ad renderer — the SDK owns its own ad player surface.

Validate your adapter

Add the conformance kit to the test source set:

testImplementation("com.dolby.optiview:ads-sdk-adapter-test-kit:<version>")

Extend PlayerAdapterConformanceTest and override createAdapter():

import com.dolby.optiview.ads.core.PlayerAdapter
import com.dolby.optiview.ads.testkit.PlayerAdapterConformanceTest

class MyPlayerAdapterTest : PlayerAdapterConformanceTest() {
    override fun createAdapter(): PlayerAdapter = MyPlayerAdapter(player)
}

iOS / tvOS (Swift)

For scrubber markers, call sdk.getScheduledBreaks() or subscribe to .scheduledbreakschange and read .scheduledBreaksChange(breaks:timestamp:). The value snapshot includes viewer-playable pre/mid/post breaks, manifest durations, content start seconds (nil for post-rolls, wallclock, and unresolved PTS), ISO wallclock dates, and a played flag set after break-begin. It excludes pause ads, bookmark-skipped pre-rolls and overlap skips; earlier bookmark mid-rolls remain. Equal snapshots emit nothing; session end clears the array.

Break status ends with .complete → .idle → adbreakend. Subscribe to completion rather than polling for it: the getter is idle after cleanup. Cuts/errors also complete an active break; skipped breaks and session teardown do not. See Ad break status for terminal fields and UI handling. With LiveStartPushbackConfig(enabled: true), initial live playback starts five target durations behind the reported edge when metadata and the DVR window allow it. It is off by default for every ptsSource, including .anvatoCue. Supply the actual stream TD for AVPlayer/THEOplayer through liveStartPushback: LiveStartPushbackConfig(enabled: true, targetDurationSeconds: 10). No TD is guessed. Startup request and landing diagnostics include offsets in seconds and TD multiples.

With ptsSource: .anvatoCue, a live break resumes on the break end the stream signals (Anvato type=cue_end) as soon as it is known, instead of cue + duration. AVPlayer can move its timeline while content is held, and the stream's marker stays correct. Late markers only ever move content forward. See DA-RESUME-CUE-END in Diagnostics and the iOS README for the details. When the stream carries Anvato beacons, the resume point is placed on the stream's own clock and re-mapped onto currentTime on every beacon until the hand-back, so a timeline shift during the break no longer moves the landing (DA-RESUME-PTS-MAP, DA-RESUME-PTS-LANDED).

The OptiView Ads SDK ships a native iOS / tvOS SDK in Swift. It implements the same Server-Guided Ad Insertion model as the web SDK — manifest polling, break scheduling on the programDateTime timebase, the ad-event lifecycle, GAM/DAI pod serving, and the redactable diagnostics stream — built on AVFoundation / AVPlayer.

Targeting reports platform ios or tvos according to the build target. The OS is ios for iPhone, ipados for iPad, and tvos for Apple TV; version bounds use the system version. An iOS app running on Mac reports macos without an OS version.

Like the web SDK, the core is player-agnostic: it drives your content player only through the PlayerAdapter protocol, so you can use the bundled AVPlayer adapter or implement your own. A single import OptiViewAdsRuntime re-exports the core + SDK layers.

The break-cut countdown starts on actual ad playback, not loading or AVPlayerItem readiness. The full effective duration plus adBreakCutSafetyMarginSec is then available. Buffering does not restart it; startup has an independent fail-open timeout. React Native iOS/tvOS forwards its configured margin to this same renderer.

VOD bookmark startup

See Start VOD from a bookmark for AVPlayer and THEOplayer startup ordering on iOS/tvOS.

Getting Started

Requirements

  • iOS / tvOS 15+ (the runtime depends on the Google IMA SDK, which requires 15+)
  • AVFoundation / AVPlayer
  • For Google Ad Manager pod serving: GoogleInteractiveMediaAds — Google ships it as two platform-specific SPM packages exporting the same module (…-google-interactive-media-ads-ios for iOS, …-google-interactive-media-ads-tvos for tvOS); add the one(s) matching your app's platforms

Installation

The xcframeworks are published per release; take each url and checksum from that release's manifest.json — see Install / Distribution.

// Package.swift — Swift Package Manager
dependencies: [
    .package(url: "https://github.com/googleads/swift-package-manager-google-interactive-media-ads-ios", from: "3.18.4"),
    .package(url: "https://github.com/googleads/swift-package-manager-google-interactive-media-ads-tvos", from: "4.2.0"),
],
targets: [
    .binaryTarget(name: "OptiViewAdsCore",
        url: "<release base URL>/OptiViewAdsCore.xcframework.zip",
        checksum: "<see manifest.json>"),
    .binaryTarget(name: "OptiViewAdsSDK",
        url: "<release base URL>/OptiViewAdsSDK.xcframework.zip",
        checksum: "<see manifest.json>"),
    .binaryTarget(name: "OptiViewAdsRuntime",
        url: "<release base URL>/OptiViewAdsRuntime.xcframework.zip",
        checksum: "<see manifest.json>"),
    .target(name: "MyApp", dependencies: [
        "OptiViewAdsRuntime", "OptiViewAdsSDK", "OptiViewAdsCore",
        .product(name: "GoogleInteractiveMediaAds", package: "swift-package-manager-google-interactive-media-ads-ios",
                 condition: .when(platforms: [.iOS])),
        .product(name: "GoogleInteractiveMediaAdsTvOS", package: "swift-package-manager-google-interactive-media-ads-tvos",
                 condition: .when(platforms: [.tvOS])),
    ]),
]
# Podfile — CocoaPods
source 'https://github.com/THEOplayer/cocoapods-specs.git'
source 'https://github.com/Dolby-OptiView/cocoapods-specs.git'  # the Lens SDK pods
source 'https://cdn.cocoapods.org/'

pod 'OptiViewAdsRuntime', '<version>'

Player-free external provider parameters

When an application needs provider parameters before playback, use OptiViewAdsExternalVendors rather than creating a player-backed session:

let vendors = try OptiViewAdsExternalVendors(
    config: OptiViewAdsExternalVendorsConfig(manifestUrl: manifestUrl)
)
try await vendors.start()
let parameters = vendors.getExternalVendorConfiguration("mediakind")?.assetParameters ?? [:]
// Pass parameters to the external provider before playback starts.
vendors.stop()
vendors.destroy()

Quick start

import AVFoundation
import OptiViewAdsRuntime   // re-exports OptiViewAdsCore + OptiViewAdsSDK

// 1. Content player — you own the AVPlayer and render it (AVPlayerLayer / AVPlayerViewController).
let contentPlayer = AVPlayer()
playerLayer.player = contentPlayer
let contentAdapter = AVPlayerAdapter(player: contentPlayer)

// 2. Runtime seams: overlay ad renderer + Foundation manifest source + dispatch ticker.
//    `overlayContainer` is a UIView stacked above your content surface; a `single`
//    break covers all of it, letterbox bars included.
let renderer = OverlayAdRenderer(overlayContainer: overlayContainer, contentPlayer: contentAdapter)

// 3. Create the SDK.
let sdk = OptiViewAds(
    config: OptiViewAdsConfig(player: contentAdapter, debug: true),
    renderer: renderer,
    manifestSource: URLSessionManifestSource(),
    ticker: DispatchSchedulerTicker()
)

// 4. Listen to events (addEventListener returns a token for removeEventListener).
sdk.addEventListener(.adbreakbegin) { event in print("Break started:", event.breakId ?? "") }
sdk.addEventListener(.adbreakend)   { event in print("Break ended:", event.breakId ?? "") }
sdk.addEventListener(.adbreakstatus) { event in
    guard case let .adBreakStatus(status, _) = event else { return }
    if status.phase == .complete || status.phase == .idle { print("Hide break UI") }
}
sdk.addEventListener(.adchannelchange) { event in
    guard case let .adChannelChange(_, _, eventId, reason, _, _, _, _) = event else { return }
    print("Ad configuration changed:", reason, eventId ?? "")
}

// 5. Load your content stream and start a monetization session.
if let url = URL(string: "https://example.com/live.m3u8") {
    contentPlayer.replaceCurrentItem(with: AVPlayerItem(url: url))
    contentPlayer.play()
}

Task {
    do {
        try await sdk.startSession(SessionConfig(manifestUrl: "https://manifest.example.com/v1/your-org/channels/your-channel"))
    } catch {
        print("startSession failed:", error)
    }
}

For live wallclock channel events, reason is .eventBoundary and eventId identifies the event now in effect, or is nil when playback leaves an event. Previously played breaks stay played, and a break already in progress finishes before the new event configuration is applied.

Every published iOS/tvOS SDK version uses the same embedded manifest trust list: ads-prod-2026-08, ads-staging-2026-08, and ads-dev-2026-08. URLSessionManifestSource(session:) accepts an optional URLSession for transport integration, but its public initializer cannot accept custom trusted keys. The repository test key is available only to unit/conformance tests through an internal testability seam; neither DEBUG builds nor CI change the Apple key list.

startSession is async throws — call it from a Task. UIKit/AVPlayer work is marshalled to the main actor, so construct the SDK and renderer on the main thread. Call sdk.destroy() when tearing down.

Ad formats & overlay rendering

Native ad creatives default to .fit (aspect-fit/contain), matching the web renderer's primary ad surfaces. Pass adScaling: .fill to opt into aspect-fill cropping. Companion/backdrop artwork remains cover-scaled independently, and fullscreen ad surfaces follow stageRect when the content picture geometry is available.

OverlayAdRenderer renders every break format. For the overlay format it positions/sizes the ad surface from the manifest position/size/opacity and does not pause the content player (the ad plays on top of playing content); all other formats render full-surface and pause content. Overlay assets with mediaType: "image" are rendered in a UIImageView (held for the asset's duration, falling back to the break duration), are preloaded for an instant transition, and on load failure dispatch aderror and are ignored — identical to the web and Android runtimes. See Ad Formats.

Animated GIF and WebP companions, backdrops, image ads and pause images play on iOS and tvOS. Frames are decoded on a background queue and a display link only presents the newest frame that is due, so the main thread never decodes; ImageIO's own animation call is not used because it decodes WebP on the main queue. An animation whose canvas is above about 1080p keeps its first frame (DA-IMAGE-ANIMATION-UNSUPPORTED, canvas-too-large). Animated creatives are cached as raw bytes (at most 8 files and 16 MB) and refused above 8 MB.

A declared asset mimeType is used: on iOS/tvOS 17 and later an HLS or progressive type is passed to AVPlayer (AVURLAssetOverrideMIMETypeKey), so the URL extension and the server's content type no longer decide; earlier versions have no API for this and keep reading the URL. An image mimeType is the decoder's type hint, a still type (image/png, image/jpeg, image/svg+xml) keeps its first frame, and image/gif or image/webp is held to the 8 MB animation limit without its header being checked. See Declared media type.

Reading the SDK version

Read the current SDK version from the static OptiViewAds.version property — no instance required. It is the same lockstep version as the web and Android SDKs and the stitcher's GET /version.

print(OptiViewAds.version) // e.g. "0.16.0"

Google Ad Manager (pod serving)

Supply a GamConfig to the renderer and to OptiViewAdsConfig. Its presence is the opt-in — the stream identity comes from the break manifest's vendorConfiguration. GAM vendor breaks are served via Google IMA DAI.

let gam = GamConfig()
let renderer = OverlayAdRenderer(overlayContainer: overlayContainer, contentPlayer: contentAdapter, gamConfig: gam)

let sdk = OptiViewAds(
    config: OptiViewAdsConfig(player: contentAdapter, gam: gam),
    renderer: renderer,
    manifestSource: URLSessionManifestSource(),
    ticker: DispatchSchedulerTicker()
)

Task {
    try await sdk.startSession(SessionConfig(manifestUrl: "https://manifest.example.com/v1/your-org/channels/your-channel"))
}
GAM assets are skipped, with DA-GAM-CONFIG-MISSING, if the break manifest carries no usable gam entry in vendorConfiguration. That is a backend/provisioning fix — the identity is deliberately not configurable here.

Break transitions (transition)

How the picture changes at the edges of a break — the same option (and defaults) as on Android. The ad surface is held back until the ad has actually rendered its first frame (AVPlayerLayer.isReadyForDisplay), then cuts in — shown, and at the end it is cut away as content resumes. Nothing fades: a fade over the content from the break start on shows the stream's own break under it, and with the first-frame warm-up there is nothing left for a fade to hide. The durationMs still times the two-box layout reflow. Nothing is shown while the surface is still blank, which is what removes the black flash at a fullscreen (single) break.

OptiViewAdsConfig(
    player: contentAdapter,
    transition: TransitionConfig()                          // first-frame hold + 300ms layout glide (default)
    // transition: TransitionConfig(type: .none)            // no hold, no layout animation (legacy snap)
    // transition: TransitionConfig(durationMs: 500)        // slower layout glide
)
Field Type Default Meaning
type .fade / .none .fade .fade holds the surface until the first frame and glides the layout; .none is the legacy snap. The content/ad switch is a cut either way.
durationMs Int 300 The layout glide. Ignored for .none.

An ad that renders no frame at all — an audio-only creative, or a decoder that never answers — is revealed anyway once the ad-start deadline passes, so it can never play invisibly. Every reveal emits DA-AD-SURFACE-REVEALED with reason (first-frame vs reveal-timeout) and waitedMs, the wait that would otherwise have been a black gap.

For a format that covers content (single, lshape_ad), immediate pre-rolls and breaks whose first asset is VAST pause content immediately at break begin. An immediate pre-roll with no adStartDelay also holds content from session wiring until the break takes over, re-pausing content playing events and emitting DA-PREROLL-CONTENT-HELD, so a slow ad does not consume the opening content. Static mid-rolls and delayed pre-rolls retain the deferred pause: content keeps playing under the transparent ad surface until the ad starts. Content audio is muted from the start of the break (and restored at the end, preserving a viewer's own mute), because two pictures may overlap while the ad is still invisible but two soundtracks may not.

Unlike Android there is no surface-type trade-off: an AVPlayerLayer alpha-blends natively, so fade costs nothing extra and works with DRM-protected creatives. And the renderer always warms ad media on its own layerless player, so the static mid-roll deferred content pause applies regardless of adPreload.

Picture-in-picture

The SDK owns picture-in-picture because the break format depends on it: while the window is open every break plays as single and the ad plays through the content player, since the window presents that player's surface and nothing else. Drive it with OptiViewAds.setPictureInPicture(_:); viewer-driven transitions (dismissing the window from the system UI) are detected and adopted automatically.

How the window is driven depends on the content adapter:

  • AVPlayerAdapter — the SDK discovers the AVPlayerLayer presenting your content and runs its own AVPictureInPictureController against it. Nothing to configure beyond the platform requirements below.
  • THEOplayer (or any adapter conforming to PictureInPictureCapable) — the window is driven through the player's own PiP facility (presentationMode), never an external controller: THEOplayer replaces its internal player/layer on a source change, which is exactly what happens when the ad borrows the content player, and an external controller's window dies at that moment. For the window to survive the ad hand-over you must construct the player with source-change retention — the SDK cannot set this after construction:
let pipConfig = PiPConfiguration(retainPresentationModeOnSourceChange: true)
let theoplayer = THEOplayer(configuration: THEOplayerConfiguration(pip: pipConfig, /* … */))

If you implement PictureInPictureCapable on your own adapter, note the change-handler contract: onPictureInPictureChange(_:) must also invoke the handler once with the current state at install time. The player outlives SDK sessions, so a window opened between sessions would otherwise go unreported and the next session would run breaks as if the window were closed. (The SDK also re-reads the state ~1s after every request it issues and diagnoses the outcome — DA-PIP-TRANSFER-FAILED when the player quietly refused.)

The renderer also reconciles the current PiP state at break setup and when ad media becomes ready, so a deferred adoption does not require a second enter notification. DA-PIP-ADOPTION-STATE explains deferred or already-applied decisions. On return from a shared-player VOD ad, the SDK marks the content reload as its own resume operation before resetting the source, preventing that backward jump from replaying the break.

Platform requirements, both silent when missing: the audio session must be in the .playback category (the SDK sets this when it drives the window), and the HOST app's Info.plist must declare UIBackgroundModes: audio — a capability an add-on framework cannot add for you. Without either, iOS ignores the start request with no error anywhere.

Existing Adapter — AVPlayerAdapter

The runtime ships AVPlayerAdapter, an AVFoundation implementation of PlayerAdapter. It wraps an AVPlayer you create and own (rendered in your own layer / AVPlayerViewController); the SDK drives the content player only through this adapter, keeping the brain player-agnostic.

import OptiViewAdsRuntime

let contentPlayer = AVPlayer()
let contentAdapter = AVPlayerAdapter(player: contentPlayer)
// → pass as OptiViewAdsConfig.player (and to OverlayAdRenderer).
Concern Behaviour
Events KVO on timeControlStatus / volume / isMuted / item status, a periodic time observer, and item end notifications are fanned out to the adapter's event handlers.
programDateTime Derived from AVPlayerItem.currentDate() as epoch milliseconds. Returns nil for VOD / streams without PDT, in which case wallclock-timebase breaks cannot be matched.
seek / seeked seek(_:) calls player.seek(to:toleranceBefore:toleranceAfter:) with zero tolerances and fires seeked on completion. SDK seeks are planned before the player moves. AVPlayerViewController and Siri Remote scrubbing use scheduler position jumps greater than two seconds, not direct seek notifications; THEOplayer also forwards its direct seek completion. After VOD seek-over, content-pausing Single and L-Shape Ad return to the viewer's target, including the renderer failure path; Double Box, L-Shape Content and Overlay play on without a seek. Fullscreen PiP fallbacks at break start count as Single.
load replaceCurrentItem — kicks off loading and returns immediately; readiness is signalled via playing / waiting / ended events.

AVPlayerAdapter and THEOplayerAdapter also adopt the optional ExternalPlaybackCapable protocol (OptiViewAdsCore): externalPlaybackState ("connecting", "active" or "inactive") and setExternalPlaybackAllowed(_:), with each change delivered as an externalplaybackchange event (ExternalPlaybackChange) and recorded as DA-EXTERNAL-PLAYBACK-CHANGED. For AVPlayerAdapter, connecting comes from the audio route gaining an AirPlay output (a hint: screen mirroring looks the same) and active from isExternalPlaybackActive; the gate writes allowsExternalPlayback, which moves the video only — the AVAudioSession route (and so the audio) stays on the receiver until the viewer disconnects it. THEOplayerAdapter reads the route from player.cast.airPlay and reports active only when the backing player's isExternalPlaybackActive is true (else connecting), falling back to route-based active when the backing player is not reachable (e.g. DVR, queuing or THEOlive players); it gates through allowsExternalPlayback; the THEOplayer tvOS SDK has no cast.airPlay, so on tvOS it never reports (state stays "inactive") and only the gate works. The SDK's own warm-up and pause-ad players always set allowsExternalPlayback = false; the ad player does too, except while a blocked AirPlay request is pending during a break, when it takes the receiver (and is reset when the break ends).

THEOplayer Adapter — THEOplayerAdapter

The OptiViewAdsAdapterTHEOplayer product wraps the native THEOplayer player. With SwiftPM, add the OptiViewAdsAdapterTHEOplayer and OptiViewAdsCore xcframeworks as binary targets, plus theoplayer-sdk-apple from 11.15.0. The binary target does not declare THEOplayer, so add theoplayer-sdk-apple yourself and make the app target depend on its THEOplayerSDK and THEOplayerTHEOliveIntegration products. The OptiViewAdsAdapterTHEOplayer CocoaPod pulls THEOplayerSDK-core and THEOplayer-Integration-THEOlive (~> 11.15).

// Package.swift — THEOplayer binary target and app-target dependencies
dependencies: [
    .package(url: "https://github.com/THEOplayer/theoplayer-sdk-apple", from: "11.15.0"),
],
targets: [
    .binaryTarget(name: "OptiViewAdsCore",
        url: "<release base URL>/OptiViewAdsCore.xcframework.zip",
        checksum: "<see manifest.json>"),
    .binaryTarget(name: "OptiViewAdsAdapterTHEOplayer",
        url: "<release base URL>/OptiViewAdsAdapterTHEOplayer.xcframework.zip",
        checksum: "<see manifest.json>"),
    .target(name: "MyApp", dependencies: [
        "OptiViewAdsAdapterTHEOplayer", "OptiViewAdsCore",
        .product(name: "THEOplayerSDK", package: "theoplayer-sdk-apple"),
        .product(name: "THEOplayerTHEOliveIntegration", package: "theoplayer-sdk-apple"),
    ]),
]
import OptiViewAdsAdapterTHEOplayer

let contentAdapter = THEOplayerAdapter(player: theoplayer)
# Podfile — THEOplayer adapter
pod 'OptiViewAdsAdapterTHEOplayer', '<version>'

SessionConfig.manifestUrl is optional when OptiViewAdsConfig.manifestUrlDiscovery is true and THEOplayer plays a THEOlive source: startSession then uses the ads.adsManifestUrl from the THEOlive discovery response (THEOplayer 11.15.0+). THEOplayer adds the THEOlive integration automatically when THEOplayerTHEOliveIntegration is linked (unless autoIntegrations is false), so set a custom discovery URL on the configuration before building the player: builder.setTHEOliveConfiguration(THEOliveConfiguration(externalSessionId: nil, discoveryUrl: url)). Without the THEOlive integration the discovered URL stays pending and startSession throws after the discovery wait. An explicit manifestUrl always wins.

PlayerAdapter Protocol

Any content player is integrated by conforming to PlayerAdapter from OptiViewAdsCore. Subscriptions are tracked by an opaque PlayerEventToken (Swift closures are not identity-comparable), so on(_:_:) returns a token you pass to off(_:).

/// Event types a PlayerAdapter forwards.
public enum PlayerAdapterEvent: String {
    case timeupdate, ended, error, seeked, volumechange, waiting, playing
}

/// Handler payload carries adapter-specific detail (e.g. a media error).
public typealias PlayerAdapterEventHandler = (Any?) -> Void

/// Opaque token so a specific handler can later be removed via `off(_:)`.
public final class PlayerEventToken { public init() {} }

public protocol PlayerAdapter: AnyObject {
    /// Current playback time in seconds.
    var currentTime: Double { get }

    /// Total content duration in seconds; `.infinity` for live.
    var duration: Double { get }

    /// Whether the player is currently paused.
    var paused: Bool { get }

    /// Muted state. Settable so the SDK can sync content↔ad mute.
    var muted: Bool { get set }

    /// Volume in [0, 1]. Settable so the SDK can sync content↔ad volume.
    var volume: Double { get set }

    /// Program Date Time (EXT-X-PROGRAM-DATE-TIME) as epoch milliseconds,
    /// for wallclock-timebase break matching. Nil when unavailable.
    var programDateTime: Int64? { get }

    func pause()                  // called when an ad break starts
    func play()                   // called when an ad break ends
    func seek(_ time: Double)     // used for snapback during locked breaks
    func load(_ url: String)      // load without committing to immediate playback

    /// Optional: warm caches without engaging a decoder (single-decoder preload).
    func preload(_ url: String)

    /// Optional capability hint: can this adapter buffer a second source in
    /// parallel without decoder contention? Nil is treated as true.
    var supportsParallelBuffering: Bool? { get }

    /// Subscribe to a player event; returns a token for `off(_:)`.
    @discardableResult
    func on(_ event: PlayerAdapterEvent, _ handler: @escaping PlayerAdapterEventHandler) -> PlayerEventToken

    /// Unsubscribe a previously registered handler by its token.
    func off(_ token: PlayerEventToken)

    /// Clean up resources (called when the SDK is destroyed).
    func destroy()
}

// `preload` and `supportsParallelBuffering` have default implementations.
public extension PlayerAdapter {
    func preload(_ url: String) {}
    var supportsParallelBuffering: Bool? { nil }
}
Member Notes
programDateTime Epoch milliseconds (Int64?), not a Date — keeps the brain dependency-free. Critical for live streams with timebase: "wallclock"; return nil if the stream has no PDT.
load(_:) Kicks off loading and returns immediately. Signal readiness via the playing/waiting events rather than blocking.
seek(_:) Used by the SDK to snap back to a break start when controls.snapback is set and an unexpected seek is detected.
on / off The SDK listens to timeupdate for break timing, ended for asset completion, error for recovery, seeked for snapback, and volumechange / waiting / playing for state sync. Keep the returned token to unsubscribe.
preload / supportsParallelBuffering Optional with default implementations. Override preload only if your player supports a detached cache warm.

Implementing a Custom Adapter

To use the SDK with a different player, conform to PlayerAdapter and forward your player's callbacks to the SDK event handlers.

import OptiViewAdsCore

final class MyPlayerAdapter: PlayerAdapter {

    private let player: MyPlayer
    private var handlers: [PlayerAdapterEvent: [ObjectIdentifier: PlayerAdapterEventHandler]] = [:]

    init(player: MyPlayer) {
        self.player = player
        // Forward your player's callbacks to the SDK.
        player.onPositionChanged = { [weak self] in self?.dispatch(.timeupdate) }
        player.onEnded           = { [weak self] in self?.dispatch(.ended) }
        player.onError           = { [weak self] err in self?.dispatch(.error, err) }
        player.onSeeked          = { [weak self] in self?.dispatch(.seeked) }
        player.onVolumeChanged   = { [weak self] in self?.dispatch(.volumechange) }
    }

    // ── Required properties ──────────────────
    var currentTime: Double { player.positionSeconds }
    var duration: Double { player.isLive ? .infinity : player.durationSeconds }
    var paused: Bool { !player.isPlaying }

    var muted: Bool {
        get { player.volume == 0 }
        set { player.volume = newValue ? 0 : 1 }
    }

    var volume: Double {
        get { Double(player.volume) }
        set { player.volume = Float(max(0, min(1, newValue))) }
    }

    var programDateTime: Int64? { player.currentProgramDateEpochMs }   // nil for VOD / no PDT

    // ── Required methods ─────────────────────
    func pause() { player.pause() }
    func play()  { player.play() }
    func seek(_ time: Double) { player.seek(toSeconds: time) }
    func load(_ url: String)  { if let u = URL(string: url) { player.setSource(u) } }

    @discardableResult
    func on(_ event: PlayerAdapterEvent, _ handler: @escaping PlayerAdapterEventHandler) -> PlayerEventToken {
        let token = PlayerEventToken()
        handlers[event, default: [:]][ObjectIdentifier(token)] = handler
        return token
    }

    func off(_ token: PlayerEventToken) {
        let key = ObjectIdentifier(token)
        for event in handlers.keys { handlers[event]?.removeValue(forKey: key) }
    }

    func destroy() {
        handlers.removeAll()
        // Remove any observers registered on `player`.
    }

    private func dispatch(_ event: PlayerAdapterEvent, _ payload: Any? = nil) {
        handlers[event]?.values.forEach { $0(payload) }
    }
}
Key implementation notes:
• load(_:) and play() return immediately — signal readiness through playing/waiting events, never block.
• programDateTime must reflect the current stream position (epoch ms), not just the start of the manifest.
• Never share the content player instance with the ad renderer — the SDK owns its own ad player surface.

Validate your adapter

With SwiftPM, declare the OptiViewAdsAdapterTestKit and OptiViewAdsCore binary targets and depend on both from the test target only. Use the OptiViewAdsAdapterTestKit URL and checksum from the release manifest.json.

targets: [
    .binaryTarget(name: "OptiViewAdsCore",
        url: "<release base URL>/OptiViewAdsCore.xcframework.zip",
        checksum: "<see manifest.json>"),
    .binaryTarget(name: "OptiViewAdsAdapterTestKit",
        url: "<release base URL>/OptiViewAdsAdapterTestKit.xcframework.zip",
        checksum: "<see manifest.json>"),
    .testTarget(name: "MyPlayerAdapterTests", dependencies: [
        "OptiViewAdsAdapterTestKit", "OptiViewAdsCore",
    ]),
]
import OptiViewAdsAdapterTestKit
import OptiViewAdsCore

final class MyPlayerAdapterTests: PlayerAdapterConformanceTestCase {
    override func makeAdapter() -> PlayerAdapter {
        MyPlayerAdapter(player: makePlayer())
    }
}

Override triggerVolumeChange(_:) -> Bool when the player can synthesize a volume-change event headlessly.

SDK Configuration

Initial live distance (all platforms)

liveStartPushback applies once per session/channel at initial content playback. It is opt-in: it runs only with enabled: true. When enabled is not set or is false, it is off for every ptsSource, including 'anvatoCue':

enabled Live start adjustment
not set (default) off
false off
true on

If the player would start less than five target durations behind its reported live edge, the SDK places the start at liveEdge - 5 * targetDuration. Where the player supports it, the player itself starts there before the first frame:

  • hls.js: live-sync count
  • Shaka: presentation delay
  • THEOplayer: liveOffset
  • AVPlayer: configuredTimeOffsetFromLive
  • ExoPlayer: a seek before the first frame

Otherwise the SDK seeks once, backward only. At 3×TD it rewinds 2×TD; at 4×TD it rewinds 1×TD; at or beyond 5×TD it does nothing. Later play events and ad-break resumes do not repeat it. VOD is unchanged. A short DVR window limits the target to the earliest available position.

Option Default Meaning
enabled not set (off) Only true opts in; not set or false keeps the player's original startup position.
minimumDistanceTargetDurations 5 Total minimum distance, not an additional rewind. Must be finite and positive.
targetDurationSeconds absent Declared HLS EXT-X-TARGETDURATION fallback when the adapter cannot provide it.

Web and React Native constructor example: liveStartPushback: { enabled: true, targetDurationSeconds: 10 }. Kotlin: liveStartPushback = LiveStartPushbackConfig(enabled = true, targetDurationSeconds = 10.0). Swift: liveStartPushback: LiveStartPushbackConfig(enabled: true, targetDurationSeconds: 10). Use the actual stream value, not the example value, and recreate the SDK configuration when switching to content with a different fallback TD. Valid adapter metadata takes precedence. HLS.js and Media3 HLS provide declared TD automatically; THEOplayer, AVPlayer, native Web HLS and Shaka require the fallback where declared TD is unavailable. Missing metadata is a diagnosed no-op, never a guessed rewind. Existing custom adapters remain compatible.

Safari's native HLS (NativeVideoAdapter) hides the live edge behind a three-target-duration hold-back. The adapter adds that hold-back back using targetDurationSeconds, so set the fallback there. The element cannot be positioned before its first frame, so one frame shows at Safari's own start before the SDK seeks back. A playlist with a larger HOLD-BACK starts further behind, never closer. See Player Adapters.

When on, this changes live startup latency and may cause a brief seek/rebuffer where the player cannot start at the distance itself. It is not a continuous latency controller and does not guarantee exact post-break positioning. Use DA-LIVE-START-PUSHBACK and DA-LIVE-START-PUSHBACK-LANDED to compare requested and measured offsets in seconds and TD multiples. Every live start diagnostic carries enabledBy, which is always config; when the adjustment is off, live playback reports DA-LIVE-START-PUSHBACK-SKIPPED once with reason disabled.

Configuration is split into two levels: SDK-level (fixed for the app lifetime) and session-level (per channel / content piece).

Ad startup: Android and iOS/tvOS use a 10-second video ad-start deadline, including React Native, matching the web GAM pod budget. Other web ads retain their 5-second budget. These internal defaults require no configuration change; the separate 15-second break-start backstop and playback cutoff remain unchanged.

This topic is documented for every SDK. Use the Web / Android / iOS switcher at the top of the sidebar to choose your platform. The config shape is intentionally parallel across platforms (OptiViewAdsConfig + SessionConfig + GamConfig), minus the web-only DOM fields.

Web

OptiViewAdsConfig constructor

Property Type Required Description
player PlayerAdapter ✅ Adapter wrapping your content video player.
container HTMLElement ✅ Outer SDK stage element. The SDK appends its ad overlay and companion elements here. Must have position: relative (SDK sets it automatically if unset).
playerContainer HTMLElement ❌ Wrapper around your content video UI. The SDK animates this to a pip corner for L-shape formats. Optional — when omitted the SDK automatically wraps the existing children of container in a new <div>.
createAdAdapter (container: HTMLElement, video?: HTMLVideoElement) => PlayerAdapter ❌* Factory for the ad player. Receives a <div> container; create your media element(s) inside it and return a PlayerAdapter wrapping them. A second argument, video, is passed on the shared-element path — an EXISTING element (the content player's own <video>) the ad must play through so it reaches a picture-in-picture window or an OS-native fullscreen. Honour it by wrapping that element instead of creating one; a factory that ignores it is detected (the returned adapter reports a different videoElement) and the SDK falls back to asking the content player to load the ad itself. *Required with @dolby-optiview/ads-sdk-core; optional with @dolby-optiview/ads-sdk, which defaults to an HLS.js ad player (native <video> fallback).
adPreload 'parallel' | 'single-decoder' | 'none' | 'auto' ❌ Ad preload strategy. Default 'auto' picks parallel or single-decoder via User-Agent inspection — every Samsung (Tizen) / LG (webOS) / VIZIO (SmartCast) TV resolves to 'single-decoder' (a second attached MediaSource wedges those panels' only hardware decoder, PLAYG-319); everywhere else it resolves to 'parallel', and it never selects 'none'. 'parallel' buffers the next ad into the (attached) ad player while content plays. 'single-decoder' warms the HTTP cache + does a detached manifest/fragment prefetch (no second MediaSource) for single-decoder TVs. 'none' disables all pre-break activity — the cold-start baseline / opt-out. DA-PRELOAD-MODE-RESOLVED reports the resolved mode per session.
adBreakContentRecovery 'recreate' | 'none' | 'auto' ❌ How content is recovered when an ad break ends. Default 'auto' resolves to 'recreate' on VIZIO SmartCast (User-Agent match) and 'none' everywhere else; an explicit value always wins. 'recreate' releases the ad media, rebuilds the content player's media pipeline seeded at the resume position (via the adapter's recreateMediaPipeline), then plays — needed on VIZIO SmartCast, where content cannot resume in the MediaSource an ad interrupted. 'none' resumes in place (seek + play). DA-CONTENT-RECOVERY-MODE-RESOLVED reports the resolved mode per session; a failed or timed-out rebuild falls back to seek + play with DA-CONTENT-PIPELINE-RECREATE-FAILED. Web only: the Android, iOS and React Native bridges accept and ignore it.
adInsertion 'overlay' | 'shared-element' | 'adaptive' | 'auto' ❌ Ad insertion strategy. Default 'auto' keeps the overlay compositor everywhere except iPhone/iPod, where it switches to 'shared-element': a single fullscreen ad played through the content <video> so iOS native fullscreen is preserved. The SDK also falls back to shared-element for the duration of a break when the content player is in picture-in-picture and the browser will not hand the window to the ad element (WebKit) — a DOM overlay cannot draw into a window the browser renders itself. In shared-element mode advanced formats (double, lshape_ad, overlay) are downgraded to a single fullscreen ad and lshape_content is skipped. 'adaptive' is the iPhone/iOS 17.1+ (Managed Media Source) mode: overlay while inline, shared-element while in OS-native fullscreen. Force 'overlay' to disable, or 'shared-element' to opt in everywhere.
chaining { enabled?: boolean; maxGapSeconds?: number } ❌ Consecutive-break chaining. Default { enabled: true, maxGapSeconds: 2 }. When two breaks are separated by a gap ≤ maxGapSeconds, they play as one continuous sequence — the overlay is held across the gap (content is not resumed) and the next break's first ad is buffered or preloaded while the last ad plays (see Consecutive-break chaining below) — so there is no flash or spinner between back-to-back breaks. Set enabled: false (or maxGapSeconds: 0) to always tear down between breaks.
tuneIn { enabled?: boolean; minBreakDurationSeconds?: number } ❌ Tune-in (join-in-progress) handling. Default { enabled: true, minBreakDurationSeconds: 5 }. When a viewer joins while a break is already in progress, the break is presented for its remaining duration instead of being skipped — unless less than minBreakDurationSeconds remains, in which case it is not monetised. The remaining duration also drives the GAM pod request. Set enabled: false to always skip in-progress breaks.
continueContentDuringBreak boolean ❌ Opt-in content-continuous single DAR playout. Requires explicit session adInsertionType: 'replacement'; it is independent of live/VOD, Anvato and timebase. Optional PlayerAdapter.setVideoQuality constrains bandwidth when supported; otherwise playout continues with DA-CONTINUE-PLAYOUT-QUALITY-UNAVAILABLE.
manifestUrlDiscovery boolean ❌ Opt-in, default false. Lets startSession() omit manifestUrl and use the ads manifest URL the player adapter discovers (THEOplayer with a THEOlive source on Web, Android and iOS). Off: startSession() requires manifestUrl and adapters do not observe discovery. See Ads manifest from THEOlive discovery.
externalPlayback { blockBeforeBreakSec?: number } ❌ AirPlay guard, active only when the manifest carries a server-side beaconing (ssb) stream and the content adapter can gate external playback. blockBeforeBreakSec (default 5) is how many seconds before a scheduled break AirPlay may not start; 0 blocks only during a break. A blocked request is retried when the break ends (DA-EXTERNAL-PLAYBACK-BLOCKED, DA-EXTERNAL-PLAYBACK-ALLOWED). See Break Manifest → Server-side beaconing stream.
pdtGraceSeconds number ❌ How long to wait for the stream's EXT-X-PROGRAM-DATE-TIME on a wallclock-timebase session before concluding the stream carries none. Default 5. A session is normally started before the content player has loaded its source, so the first ticks see no PDT even on a stream that has it; those ticks make no scheduling decision rather than matching breaks against the system clock, which runs ahead of the live playhead by the stream's latency and would fire a break early. This is a backstop, not a fixed delay: the SDK stops waiting as soon as content has been playing for ~1s and still exposes no PDT (direct evidence about the stream — DA-PDT-MISSING is emitted once and the clock takes over immediately, so a join-in-progress break is never delayed below the tune-in minimum), and this window only governs a player that never starts. Set 0 for the immediate clock fallback. No effect on pts manifests.
adBreakCutSafetyMarginSec number ❌ Safety margin (seconds) added to the effective break duration. The hard-cut countdown starts at first actual ad playback, not loading or a resolved play() promise. Default 2; 0 allows exactly the effective duration from playback start. Buffering recovery and later ads do not restart it. A separate 15-second startup watchdog and existing load/start budgets prevent an ad that never starts from holding content.
doubleBoxAudio 'ad' | 'content' ❌ Which side gets audio during a double-format break (content and ad boxes side-by-side). Default 'ad' — the ad is audible, content is muted for the break. 'content' keeps content's audio and mutes the ad instead. The unified sdk.muted/sdk.volume control the focused side only; the latest viewer mute and volume carry into content at break end. The non-focused side stays silent during the break. See Unified audio API.
gam GamConfig ❌ Google Ad Manager configuration. Required for GAM pod serving (and for mode: 'ssai').
mode 'sgai' | 'ssai' ❌ Ad-insertion architecture. Default: resolved from the break manifest's delivery rules on the first fetch (falling back to 'sgai' — see Delivery steering on the Break Manifest page). Setting it explicitly overrides manifest steering (DA-DELIVERY-MODE-OVERRIDDEN). Explicit 'ssai' plays a pre-stitched stream from the stitcher on the content player (see SSAI mode below).
maxBitrate number ❌ SSAI only — caps rendition bitrate via the master max_bitrate query param (bits/sec). The stitcher drops variants whose BANDWIDTH exceeds it (fail-open keeps the lowest if none qualify).
autoplay boolean ❌ SSAI only — when true the SDK plays the stitched stream after loading it during startSession. Default false.
interceptManifestResponse (manifest: BreakManifest, ctx: { url: string }) => BreakManifest | Promise<BreakManifest> ❌ SGAI only. Hook to inspect/modify the parsed, validated break manifest before it is scheduled — called on the initial fetch and on every poll, with the typed BreakManifest (never raw JSON). Return the manifest to use (modified or unchanged); the result is used directly, without re-validation. May be async. If it throws, the SDK emits DA-MANIFEST-INTERCEPT-FAILED and falls back to the unmodified manifest. See Manifest interception.
interceptManifestRequest (request: ManifestRequest, ctx: { url: string }) => ManifestRequest | ManifestMockResponse | void | Promise<…> ❌ SGAI only. Hook to inspect/modify the manifest HTTP request before it is fetched — called on the initial fetch and on every poll. Return a ManifestRequest ({ url; headers? }) to redirect/add headers, a ManifestMockResponse ({ body }, raw JSON parsed + validated normally) to short-circuit the network, or nothing to fetch unchanged. May be async. If it throws, the SDK emits DA-MANIFEST-REQUEST-INTERCEPT-FAILED and falls back to the network fetch. See Manifest interception.
breakWarnings { seconds?: number[] } ❌ Pre-break warning thresholds in seconds. Default { seconds: [] } (disabled). Each positive, finite value fires one adbreakstatus event with phase: 'upcoming' when the break is within that many seconds of starting, and again whenever the next (smaller) threshold is crossed. Duplicates and non-finite values are ignored and the list is sorted ascending. Useful for countdown UI.
ptsSource 'mediaTime' | 'anvatoCue' ❌ How a PTS-timebase break's start is resolved. Default 'mediaTime', which interprets start directly as player media time. Set 'anvatoCue' for Anvato in-stream break signaling (NFL Channel / NFL Network style); the SDK tracks Anvato timed-metadata cues from the content player — HLS ID3 GEOB frames with description Anvatos (MIME application/json), DASH emsg events with scheme urn:anvato:es1:052016, and DASH emsg events in the standardized ID3-in-emsg carriage (https://aomedia.org/emsg/ID3 or https://developer.apple.com/streaming/emsg-id3) whose payload is a complete ID3 tag with the same Anvato GEOB frame (the SDK unwraps it) — the Anvato payload is a query string type=cue&pts=<seconds>. A timebase: "pts" break is then scheduled at the media time of the observed cue whose pts matches the break's start (±5 ms); a break whose cue has not been observed yet stays pending (DA-ANVATO-CUE-PENDING, then DA-ANVATO-CUE-MATCHED once resolved). Cue-scheduled breaks are one-shot: once completed they are never re-armed by a backward playhead step (a DVR seek-back, or a live window re-anchoring on players that report window-relative positions). On DASH, an emsg cue is reported at the start of the segment that carries it; the THEOplayer web and Shaka adapters read the stream manifest, and the THEOplayer Android adapter the stream's Anvato beacons, so the break starts at the cue's own pts instead (see Player Adapters → ptsOffset). The stream's type=cue_end is matched to the active break (DA-ANVATO-CUE-END-MATCHED); on iOS/tvOS, web and Android it becomes the live resume point when the break resumes at its end. When the stream also carries Anvato type=beacon tags, iOS/tvOS and web place that resume point on the stream's own clock (DA-RESUME-PTS-MAP, DA-RESUME-PTS-CORRECTED, DA-RESUME-PTS-LANDED); otherwise, and on Android, at the cue_end's own position (DA-RESUME-CUE-END). SGAI only; no effect on wallclock-timebase manifests, which resume on the stream's Program Date Time instead: the resume is anchored on the manifest start and lands on start + duration on that clock whatever the pause and the ad's first frame took (DA-BREAK-CUT-LATE, DA-RESUME-PDT-MAP, DA-RESUME-PDT-CORRECTED, DA-RESUME-PDT-LANDED).
diagnostics { bufferSize?: number } ❌ Structured diagnostics options. bufferSize (default 200) caps the in-memory ring buffer that backs exportDiagnostics(); older records are evicted first. See Diagnostics.
debug boolean ❌ Enable verbose SDK logging to the console. Default: false.

Ad preload behaviour (adPreload)

Controls how the next ad is prepared before a break starts.

Mode Behaviour Use when
parallel Buffers the next ad into the (attached) ad player while content keeps playing — lowest gap at break start. Requires two simultaneous MediaSources. Desktop, Android, and other parallel-capable platforms.
single-decoder Warms the HTTP cache and does a detached manifest/fragment prefetch without attaching a second MediaSource, deferring decode to break start. Any Samsung (Tizen), LG (webOS), or VIZIO SmartCast TV — including current models.
none No pre-break activity of any kind — no cache warm, no prefetch, no VAST pre-request. Full network + decode cost lands at break start. Cold-start measurement baseline, or when pre-break network activity is undesirable.
auto (default) Resolves at runtime via User-Agent inspection: Samsung/LG/VIZIO TVs → single-decoder, everything else → parallel. Never resolves to none. You ship one build across mixed devices.
The auto heuristic flags every Tizen (Samsung), webOS (LG), and VIZIO SmartCast TV, regardless of version. This is deliberately broad: a 2024 Tizen 8 flagship panel was measured deadlocking on a second attached MediaSource — content decode never starts, the screen stays black and no ad-break events fire (PLAYG-319) — so TV firmware version is not a reliable signal for decoder capacity. Anything outside those known single-decoder brands (desktop, mobile, and other TV platforms) is treated as parallel-capable.
Forcing adPreload: 'parallel' on a Samsung, LG, or VIZIO TV is still honoured (explicit config always wins over the heuristic), but is not recommended: on the panel above it reproducibly wedges playback for the whole session. Prefer 'auto', and use the DA-BREAK-TRANSITION diagnostic to measure what preload mode actually costs you at break start.
Measured on that same panel (Samsung QN86D, Tizen 8) with an HLS ad creative: single-decoder starts the break in ~1.1s vs ~7.1s cold (none) — the warm path removes essentially all network cost, and the remaining ~1s is decoder startup that no client-side preload can remove on a single-decoder pipeline. On CTV, serve streaming (HLS) ad creatives: a progressive MP4 plays through the native <video> pipeline where only HTTP cache warming applies (see DA-PRELOAD-PATH's creative field).

In single-decoder mode, content paused for a full-screen ad stays paused until the ad media is released. Live pre-positioning and muted catch-up behind the ad are disabled on this path; the existing release grace precedes the content resume seek and play. The default native ad adapter resets its owned media pipeline rather than only removing src. Parallel-mode alignment is unchanged.

Content recovery after a break (adBreakContentRecovery)

Controls how the content player is brought back when an ad break ends. This is a web-only option: the Android, iOS and React Native bridges accept it and ignore it, because their native players resume in place without the rebuild.

Mode Behaviour Use when
recreate Releases the ad media, rebuilds the content player's media pipeline seeded at the resume position (via the adapter's recreateMediaPipeline), then plays. VIZIO SmartCast TVs — see below.
none Resumes in place: seek to the resume position, then play. Everywhere else — the long-standing default.
auto (default) Resolves at runtime via User-Agent inspection: VIZIO/SmartCast → recreate, everything else → none. An explicit value always wins. You ship one build across mixed devices.
On VIZIO SmartCast the content player cannot resume in the MediaSource an ad interrupted — the same class of failure as the single-decoder release: the pipeline has to be rebuilt at the resume position rather than seeked inside. The rebuild re-buffers content (measured ~1s) instead of resuming from the existing buffer. An adapter that does not implement recreateMediaPipeline simply resumes in place; a rebuild that fails or exceeds its 10s budget falls back to seek + play (DA-CONTENT-PIPELINE-RECREATE-FAILED). DA-CONTENT-PIPELINE-RECREATED reports a successful rebuild with the resume position and duration.

Ad insertion behaviour (adInsertion)

Controls how the ad is composited relative to the content player.

Mode Behaviour
overlay Ad plays in a separate <video> layered over the content player. Supports all break formats. Safe on desktop, Android, iPad, and Smart TVs.
shared-element Ad plays through the content player's own <video> element so iOS native fullscreen is preserved. Only a single fullscreen ad is shown — advanced formats (double, lshape_ad, overlay) are downgraded to a single fullscreen ad and lshape_content is skipped. GAM/IMA DAI binds to the content element in this mode.
adaptive iPhone/iPod on iOS 17.1+ (Managed Media Source). Playback runs through HLS.js/MMS, so the SDK uses the full overlay compositor (all formats) while the content video is inline and falls back to shared-element (single fullscreen ad) only while the content video is in OS-native fullscreen. Re-evaluated per break from the content video's fullscreen state.
auto (default) On iPhone/iPod resolves to adaptive when Managed Media Source is available (iOS 17.1+), else shared-element (legacy, native HLS). Every other platform resolves to overlay.
DOM overlays cannot render over the OS-native fullscreen video player on iPhone/iPod. On iOS 17.1+ (adaptive) the SDK shows rich overlay formats while inline and degrades to a single shared-element ad only in fullscreen; on older iOS it uses shared-element throughout. iPad is intentionally excluded — iPadOS supports element-level fullscreen and MSE, so it stays on overlay.
AirPlay: The SDK-owned ad element always has disableRemotePlayback=true (ads are not AirPlayed). To keep AirPlay on your content player with Managed Media Source, append an HLS <source> element to your own content <video>. Adapters report the content player's AirPlay state; see Player Adapters → External playback (AirPlay).

Web shared-element content return

After a shared-element ad, restoring content has at most two attempts, each with a five-second deadline covering load, live-edge recovery and play. A timeout or repeated rejection reports DA-SHARED-ELEMENT-RESTORE-FAILED with its phase and reason. Starting another break, ending the session or destroying the SDK cancels old recovery work so late SDK continuations cannot restart the wrong content. These limits do not cancel an adapter's own in-flight work.

The existing five-second progress watchdog still reports DA-CONTENT-RESUME-STALLED when an applicable completed restore does not advance. It does not monitor later viewer pauses indefinitely. A post-roll triggered by content ending restores the ended source but does not resume it.

Consecutive-break chaining (chaining)

Some channels schedule two (or more) breaks back to back — for example two breaks with different ad targeting parameters separated by a ~1s gap. Without chaining, each break ends independently: content briefly resumes, the layout animates back to fullscreen, then the next break re-pauses content and re-applies its layout — a visible flash, often followed by a spinner while the next ad loads.

With chaining enabled (the default), breaks whose gap is ≤ maxGapSeconds are played as one continuous ad sequence:

  • The ad overlay is held across the gap — content is never resumed and the layout is not torn down (no flash).
  • On web, while the last ad of a break plays, the SDK's default ad player buffers the next break's first ad behind it in the same MediaSource (static HLS ads, adPreload resolved to parallel, hls.js 1.6 or later), so the switch shows no black frame (DA-BREAK-TRANSITION path: queued). Inside a multi-ad break the next ad is buffered the same way while the current one plays. A next ad that is not buffered in time loads at the switch (path: cold). In every other case — progressive MP4, native HLS, Smart TVs (single-decoder), adPreload: 'none', or a custom createAdAdapter player — the next break's first (static) asset is preloaded (HTTP cache warm + a detached prefetch) and loads at the switch (path: cold). Neither path attaches a second MediaSource.
  • Each break still emits its own adbreakbegin / adbreakend events and resolves its own targeting, so analytics and per-break ad requests are unchanged.
  • A break that is published in the manifest while the chain plays joins the chain as soon as a manifest poll delivers it, and a change to the next break (start, duration, creative) published during the chain is applied before it plays. Breaks are picked up during a chain only when the manifest has a polling object; a manifest without one is fetched once.
Option Default Description
enabled true Whether chaining is active. false restores per-break teardown (content resume + layout reset between breaks).
maxGapSeconds 2 Maximum gap between one break's end and the next break's start for them to chain. 0 effectively disables chaining.
Chaining holds the overlay across the gap, so on a live stream the content stays paused for the gap plus both breaks and falls further behind the live edge. Chaining is not applied in shared-element (iPhone) mode, where breaks always hard-end.
const sdk = new OptiViewAds({
  // ...
  chaining: { enabled: true, maxGapSeconds: 2 },
});

Tune-in / join-in-progress (tuneIn)

Live viewers rarely join exactly at a break boundary — they often tune in while an ad break is already playing. By default the SDK detects this and presents the break for the time that remains, rather than skipping it entirely (the legacy behaviour, which left the join-in-progress window unmonetised).

With tune-in enabled (the default), when the SDK first observes a break that has already started:

  • If at least minBreakDurationSeconds of the break remain, the break is triggered for its remaining duration. The adbreakbegin event carries a tuneIn: { elapsedSec, remainingSec } payload, and the break-cut countdown allows that remaining duration plus the safety margin from actual ad playback. Startup does not consume the remainder; content may return after the original boundary.
  • For GAM pod serving, the pod request is built for the remaining duration, so the ad server returns a pod that fits the time left.
  • If less than minBreakDurationSeconds remain, the break is not triggered (no partial sliver of an ad is shown, and it is not monetised).
Option Default Description
enabled true Whether in-progress breaks are joined. false restores the legacy behaviour of skipping any break first observed past its start.
minBreakDurationSeconds 5 Minimum remaining duration for an in-progress break to be presented. Below this, the break is skipped.
Tune-in only applies to a stream-clock live/PTS/wallclock break the SDK first observes after its start time (e.g. a fresh join or a seek into a break). A break the SDK has already triggered on time is unaffected and always plays its full duration. VOD does not late join on a first sample already past the start: declared ad duration is not a content-time window. A VOD start crossed between playback updates still plays during fast-forward or sparse updates, even with tune-in disabled. See session seek behavior for late-crossing content positioning.
const sdk = new OptiViewAds({
  // ...
  tuneIn: { enabled: true, minBreakDurationSeconds: 5 },
});

SSAI mode (mode: 'ssai')

By default the SDK runs SGAI (client-scheduled) insertion, unless the break manifest's delivery rules steer the session to ssai (see Delivery steering on the Break Manifest page — manifest-steered ssai uses the gam vendor configuration's assetKey and needs no stitcherUrl). Set mode: 'ssai' explicitly to switch to the stitcher-based server-side ad insertion: the SDK plays a single pre-stitched stream from the @dolby-optiview/ads-sdk-stitcher service on the content player. It does not poll a break manifest, schedule breaks, or run an ad-player overlay. Instead it:

  1. creates the IMA DAI stream (for a stream_id),
  2. builds the stitcher master URL and loads it into the content player,
  3. forwards in-stream timedmetadata cues to IMA for ad tracking, and
  4. re-emits the usual ad-event stream (adbreakbegin / adbegin / quartiles / adend / adbreakend).
const sdk = new OptiViewAds({
  mode: 'ssai',
  player: new HlsJsAdapter(hls, video), // must expose videoElement (IMA binds to it)
  gam: {},
  ssai: { networkCode: '23285652104' }, // SSAI only: no break manifest to read it from
  maxBitrate: 2000000, // optional — caps rendition bitrate (max_bitrate on the master URL)
  autoplay: true, // optional — SDK plays the stitched stream after load
});

// The SDK loads the stitched master itself — do not load a content URL.
await sdk.startSession({
  stitcherUrl: 'https://stitch.example.com/ssai/v1/your-org/your-channel/master.m3u8',
  customAssetKey: 'asset-key',
});
mode: 'ssai' requires a gam object and ssai.networkCode (SSAI has no break manifest to read the identity from); startSession requires stitcherUrl and customAssetKey. The content adapter must expose videoElement (HLS.js, Shaka, and native-video qualify). Startup failures emit DA-SSAI-SESSION-FAILED; in-stream IMA errors emit DA-SSAI-IMA-ERROR. See the SSAI Stitcher page for the full topology.

Manifest interception (interceptManifestRequest / interceptManifestResponse)

Two optional SGAI hooks bracket the manifest fetch:

  • interceptManifestRequest runs before the network call (initial fetch + every poll). Return a ManifestRequest to redirect the URL or add headers, a ManifestMockResponse to short-circuit the network with a raw body (parsed + validated normally), or nothing to fetch unchanged. A throw is non-fatal (DA-MANIFEST-REQUEST-INTERCEPT-FAILED, falls back to the network fetch). Primarily a testing aid (mock/redirect without a proxy).
  • interceptManifestResponse runs after fetch + validation, handing you the parsed, validated BreakManifest so you can transform it — inject a pre-roll, drop a break, rewrite an asset URL — before it is scheduled. The return value is used as-is; a throw is non-fatal (DA-MANIFEST-INTERCEPT-FAILED, falls back to the unmodified manifest).

Full guarantees, code examples, and the Android/iOS equivalents are documented under Manifest interception on the Break Manifest page.

SessionConfig startSession()

Property Type Required Description
manifestUrl string ✅* SGAI only. Full break-manifest URL. The SDK fetches and polls exactly this URL — it never composes, rewrites or appends to it. *Replaced by stitcherUrl when mode: 'ssai'. May be omitted when manifestUrlDiscovery is on and the player adapter discovers the ads manifest URL itself (THEOplayer with a THEOlive source on Web, Android and iOS) — see Ads manifest from THEOlive discovery.
stitcherUrl string ✅* SSAI only, and required there instead of manifestUrl: the full stitcher master-playlist URL (…/ssai/v1/{orgId}/{channelId}/master.m3u8). Used verbatim, with stream_id/max_bitrate appended.
assetParameters Record<string, string> ❌ Ad parameters for this session's assets (targeting, custom params). Merged on top of each asset's own assetParameters from the break manifest, per key. updateAssetParameters() overrides both.

Roku-specific transport policy: the native Roku SDK sends dai-emsgv=0 when creating an IMA session and replacing its ad-tag parameters. This is an SDK-owned compatibility value; caller-provided values for that key cannot select an unsupported metadata version. Other targeting parameters remain escaped and preserved, and the caller's parameter map is not mutated. Web, Android and iOS parameter handling is unchanged. Manifest-steered SSAI (Google DAI full service) does not send dai-emsgv; its ad tag parameters are passed as given.

Roku start config additions: mode ("sgai" or "ssai", overrides the manifest's delivery rules), raf ({ contentId, contentGenre, kidsContent, contentLength } for RAF ad measurement in SSAI; also updateRafMetadata) and streamActivityMonitorId (passed to the DAI stream request). Invalid values fail the start with invalid-delivery-mode, invalid-raf-metadata or invalid-stream-activity-monitor-id.

GamConfig optional

Property Type Required Description
streamActivityMonitorId string ❌ Stream Activity Monitor id, for debugging in Google's SAM tool.
The GAM stream identity (networkCode, customAssetKey) is not configured on the client. It comes from the break manifest's root vendorConfiguration, so the SDK and the backend can never disagree about which GAM asset the pods belong to. An empty gam object is what enables GAM; if the manifest carries no usable gam entry the SDK emits DA-GAM-CONFIG-MISSING and skips GAM assets.
| streamActivityMonitorId | string | ❌ | Debug session ID for Google's Stream Activity Monitor tool. |

Example

const sdk = new OptiViewAds({
  player: new HlsJsAdapter(hls, video),
  container: document.getElementById('container'),
  playerContainer: document.getElementById('playerContainer'),
  createAdAdapter: (adContainer) => {
    const adVideo = document.createElement('video');
    adContainer.appendChild(adVideo);
    const adHls = new Hls();
    adHls.attachMedia(adVideo);
    return new HlsJsAdapter(adHls, adVideo);
  },
  gam: {
    streamActivityMonitorId: 'my-debug-session',
  },
  debug: false,
});

Simplified setup with @dolby-optiview/ads-sdk

Import OptiViewAds from @dolby-optiview/ads-sdk to drop the createAdAdapter boilerplate — the ad player defaults to HLS.js (with a native <video> fallback). Use adPreload: 'auto' to enable single-decoder preloading on Smart TVs.

import { OptiViewAds, HlsJsAdapter } from '@dolby-optiview/ads-sdk';

const sdk = new OptiViewAds({
  player: new HlsJsAdapter(hls, video),
  container: document.getElementById('container'),
  // createAdAdapter omitted -> default HLS.js ad player (native fallback)
  adPreload: 'auto',
});

Android (Kotlin)

OptiViewAdsConfig (com.dolby.optiview.ads.sdk) carries the org-level options. The web-only DOM fields (container, playerContainer, createAdAdapter) do not exist on Android — the ad surface is owned by the OverlayAdRenderer you pass to the OptiViewAds constructor (its overlayContainer FrameLayout is the Android equivalent of container).

Property Type Default Description
player PlayerAdapter — (required) Adapter wrapping your content player (e.g. ExoPlayerAdapter).
interceptManifestResponse (suspend (BreakManifest, ManifestInterceptContext) -> BreakManifest)? null SGAI only. Inspect/modify the parsed BreakManifest before scheduling (initial fetch + every poll); may suspend. On throw emits DA-MANIFEST-INTERCEPT-FAILED and uses the unmodified manifest. Forwarded to the injected ManifestSource (default HttpManifestSource applies it).
interceptManifestRequest (suspend (ManifestRequest, ManifestRequestContext) -> ManifestRequestResult?)? null SGAI only. Inspect/modify the manifest request before fetch (initial fetch + every poll); may suspend. Return a ManifestRequest (redirect/headers), a ManifestMockResponse (raw body, parsed + validated), or null. On throw emits DA-MANIFEST-REQUEST-INTERCEPT-FAILED and falls back to the network fetch. Forwarded to the injected ManifestSource (default HttpManifestSource applies it).
adPreload AdPreloadMode PARALLEL PARALLEL / SINGLE_DECODER / AUTO. On Android (no browser UA) AUTO resolves to PARALLEL.
adInsertion AdInsertionMode AUTO OVERLAY / SHARED_ELEMENT / ADAPTIVE / AUTO. On Android AUTO resolves to OVERLAY.
chaining ChainingConfig ChainingConfig(enabled = true, maxGapSeconds = 2.0) Consecutive-break chaining (same semantics as web).
tuneIn TuneInConfig TuneInConfig(enabled = true, minBreakDurationSeconds = 5.0) Tune-in / join-in-progress handling (same semantics as web).
continueContentDuringBreak Boolean false Opt-in content-continuous single DAR playout. Requires explicit SessionConfig.adInsertionType = AdInsertionType.REPLACEMENT; independent of live/VOD, Anvato and timebase. Optional PlayerAdapter.setVideoQuality constrains bandwidth when supported; otherwise playout continues with a warning. ExoPlayerAdapter and THEOplayerAdapter implement it.
manifestUrlDiscovery Boolean false Opt-in. Lets startSession omit SessionConfig.manifestUrl and use the ads manifest URL THEOplayerAdapter discovers for a THEOlive source.
externalPlayback ExternalPlaybackConfig ExternalPlaybackConfig(blockBeforeBreakSec = 5.0) AirPlay guard (same semantics as web): active only for manifests with an ssb stream when the adapter reports externalPlaybackState.
pdtGraceSeconds Double 5.0 Backstop window for the stream's EXT-X-PROGRAM-DATE-TIME to appear on a wallclock session before falling back to the system clock with DA-PDT-MISSING (same semantics as web). Ticks before then make no scheduling decision; once content is playing with still no PDT the fallback happens immediately. 0.0 = immediate fallback.
adBreakCutSafetyMarginSec Double 2.0 Seconds added to a break's effective duration to form the hard cut-off back to content, regardless of ad media length (counted from first actual ad playback, like Web). Set 0.0 to allow exactly the effective playback duration.
diagnostics DiagnosticsConfig DiagnosticsConfig(bufferSize = 200) Diagnostic ring-buffer size backing exportDiagnostics().
debug Boolean false Verbose logging via println.
gam GamConfig? null Google Ad Manager pod-serving config.

SessionConfig(manifestUrl, assetParameters = emptyMap()) and GamConfig(streamActivityMonitorId? = null) mirror the web shapes.

import com.dolby.optiview.ads.sdk.*

val sdk = OptiViewAds(
    config = OptiViewAdsConfig(
        player = ExoPlayerAdapter(contentPlayer),
        adPreload = AdPreloadMode.PARALLEL,
        chaining = ChainingConfig(enabled = true, maxGapSeconds = 2.0),
        tuneIn = TuneInConfig(enabled = true, minBreakDurationSeconds = 5.0),
        continueContentDuringBreak = true,
        diagnostics = DiagnosticsConfig(bufferSize = 200),
        gam = GamConfig(
            streamActivityMonitorId = "my-debug-session",
        ),
        debug = false,
    ),
    renderer = OverlayAdRenderer(context, overlayContainer, contentAdapter, gamConfig = gam),
    manifestSource = HttpManifestSource(scope),
    ticker = CoroutineSchedulerTicker(scope),
)

iOS / tvOS (Swift)

OptiViewAdsConfig (OptiViewAdsSDK, re-exported by OptiViewAdsRuntime) carries the org-level options. As on Android, the web-only DOM fields are omitted — the ad surface is owned by the OverlayAdRenderer (its overlayContainer UIView). continueContentDuringBreak is not supported on iOS/tvOS yet; Apple integrations retain pause/resume behavior.

Property Type Default Description
player PlayerAdapter — (required) Adapter wrapping your content player (e.g. AVPlayerAdapter).
interceptManifestResponse ManifestResponseInterceptor? nil SGAI only. Inspect/modify the parsed BreakManifest before scheduling (initial fetch + every poll); may be async/throwing. On throw emits DA-MANIFEST-INTERCEPT-FAILED and uses the unmodified manifest. Forwarded to the injected ManifestSource (default URLSessionManifestSource applies it).
interceptManifestRequest ManifestRequestInterceptor? nil SGAI only. Inspect/modify the manifest request before fetch (initial fetch + every poll); may be async/throwing. Return .request (redirect/headers), .mock (raw body, parsed + validated), or nil. On throw emits DA-MANIFEST-REQUEST-INTERCEPT-FAILED and falls back to the network fetch. Forwarded to the injected ManifestSource (default URLSessionManifestSource applies it).
adPreload AdPreloadMode .parallel .parallel / .singleDecoder / .auto. .auto resolves to .parallel on Apple platforms.
adInsertion AdInsertionMode .auto .overlay / .sharedElement / .adaptive / .auto. .auto resolves to .overlay on tvOS / non-iPhone.
chaining ChainingConfig ChainingConfig(enabled: true, maxGapSeconds: 2.0) Consecutive-break chaining.
tuneIn TuneInConfig TuneInConfig(enabled: true, minBreakDurationSeconds: 5.0) Tune-in / join-in-progress handling (same semantics as web).
pdtGraceSeconds Double 5.0 Backstop window for the stream's EXT-X-PROGRAM-DATE-TIME to appear on a wallclock session before falling back to the system clock with DA-PDT-MISSING (same semantics as web). Ticks before then make no scheduling decision; once content is playing with still no PDT the fallback happens immediately. 0 = immediate fallback.
adBreakCutSafetyMarginSec Double 2.0 Seconds added to a break's effective duration to form the hard cut-off back to content, regardless of ad media length (counted from first actual ad playback, like Web). Set 0.0 to allow exactly the effective playback duration.
diagnostics DiagnosticsConfig DiagnosticsConfig(bufferSize: 200) Diagnostic ring-buffer size.
debug Bool false Verbose logging via print.
externalPlayback ExternalPlaybackConfig ExternalPlaybackConfig(blockBeforeBreakSec: 5) AirPlay guard (same semantics as web): active only for manifests with an ssb stream when the adapter conforms to ExternalPlaybackCapable.
gam GamConfig? nil Google Ad Manager pod-serving config.

SessionConfig(manifestUrl:assetParameters:) and GamConfig(streamActivityMonitorId:) mirror the web shapes.

import OptiViewAdsRuntime

let gam = GamConfig(
    streamActivityMonitorId: "my-debug-session"
)

let sdk = OptiViewAds(
    config: OptiViewAdsConfig(
        player: AVPlayerAdapter(player: contentPlayer),
        adPreload: .parallel,
        chaining: ChainingConfig(enabled: true, maxGapSeconds: 2.0),
        tuneIn: TuneInConfig(enabled: true, minBreakDurationSeconds: 5.0),
        continueContentDuringBreak: true,
        diagnostics: DiagnosticsConfig(bufferSize: 200),
        debug: false,
        gam: gam
    ),
    renderer: OverlayAdRenderer(overlayContainer: overlayContainer, contentPlayer: contentAdapter, gamConfig: gam),
    manifestSource: URLSessionManifestSource(),
    ticker: DispatchSchedulerTicker()
)

Session Management

A session represents the monetization lifecycle for one piece of content. Call startSession() before loading a stream and endSession() when done.

Scheduled ad breaks

sdk.getScheduledBreaks() returns a copy of this viewer's playable pre-rolls, timeline mid-rolls and post-rolls, or [] without a session. React Native returns a Promise. Targeting and format selection match break playback. Pause ads, unsupported event breaks, unplayable breaks, bookmark-skipped pre-rolls and overlap-skipped IDs are excluded. Earlier bookmark mid-rolls remain unplayed. Overlap exclusions last until a channel switch or session end, including manifest refreshes.

Each ScheduledBreak contains:

Field Meaning
id Manifest break ID.
position pre, mid or post, in that order; mid-rolls sort by start.
startSec Content seconds: zero for pre-roll, null for post-roll, wallclock or unresolved PTS.
startDate ISO wallclock start for live breaks; otherwise null.
durationSec Full manifest duration, not remaining duration.
played True just after adbreakbegin is emitted; stays true after rewind.

Channel switches clear played and excluded IDs, even when the next channel reuses an ID. Manifest refreshes and event boundaries keep this history.

Subscribe to scheduledbreakschange for changed snapshots, including an empty list on session end. Equal snapshots do not emit. Live wallclock dates are not scrubber seconds; map them against the host timeline before drawing markers. The demo's marker bar shows only resolved content-time positions.

External provider parameters

Use getExternalVendorConfiguration() to read every external provider entry in manifest order, or getExternalVendorConfiguration('mediakind') to read one exact, case-sensitive provider. The returned assetParameters include current macro values; call the getter immediately before passing them to the external system. externalvendorconfigurationchange fires for each provider added, removed, or changed in an adopted manifest, including the first manifest. Macro value changes alone do not fire the event. For example, provider names such as mediakind and vizbee are matched exactly.

To read these parameters before playback, use OptiViewAdsExternalVendors with the manifest URL, call start(), then read the provider configuration and pass it to the external system. This reader does not require a player. Call stop() to clear its current templates, or destroy() when it is no longer needed.

Use the Web / Android / iOS switcher at the top of the sidebar for the three core SDKs (Promise on web, suspend on Android, async throws on iOS). The Roku component has the distinct app-owned Video and draining lifecycle below; it is not exposed by this switcher.

Roku lifecycle

Use CallFunc on the OptiViewAds SceneGraph node, not the Promise/suspend APIs. Bind the app's videoNode before startSession({ contentUrl, manifestUrl }) and register an operationresult listener first (CallFunc("addEventListener", m.ads.events.operationresult, m.top, "OnAdsOperation")). The call returns an operation ID; the matching ready result (operation: "startSession") supplies generation, playbackUrl and deliveryMode. The application loads that URL on its Video. Readiness is not evidence that an ad has played. Ordinary ad transitions never change this source or require a second Video.

ready waits for the first break manifest, which pins the delivery mode from its tv-targeted (or default) delivery rule. With sgai the URL is the local proxy; with ssai it is a Google DAI full-service live stream for the manifest's gam ssai[0].assetKey; SSAI ready adds ssaiStream (assetKey, networkCode and the Google DAI streamId for the stream activity monitor). An optional start config mode: "sgai" | "ssai" overrides the manifest; raf and streamActivityMonitorId configure the SSAI stream. If the first manifest fails, the session continues as SGAI. An ads-channel switch that changes the mode or the DAI stream emits playbackreloadrequired (delivery-mode-changed / ssai-stream-changed): detach, endSession and start a new session. reloadAfterSeek is unsupported in SSAI.

isSessionActive returns whether monetization is starting/active, not whether the Video is playing. getSessionInfo returns generation, active, destroyed and, when a session exists, state, playbackEpoch, recoveryRequired, reloadRequired, resumePending and resumeFailed, plus bookmark/channelId and deliveryMode/deliveryModeSource when available. These getters, getAdBreakStatus and getCapabilities return snapshots directly; lifecycle/parameter operations report through operationresult events.

Interception/macro gateways use gatewayrequest events plus CallFunc("resolveGateway", { requestId, generation, status, value }); match the request correlation and do not reuse replies across sessions. Enable requestInterceptor, responseInterceptor and/or macroResolver in the config as needed. Parameter changes use updateAssetParameters (replace live layer) and updateAssetParameterMacros ({ set: { "$NAMEquot;: value }, remove: ["$NAMEquot;] }, keyed by the full token). Updates require an active session. Latest applicable parameter/channel changes govern future preparation; a committed/active occurrence is not rewritten mid-playback.

getAdBreakStatus reports the ledger/UI snapshot. Native Video.positionInfo UTC (epoch: 1) is validated against published source-PDT content spans with coherent generation/clip samples. A generation-scoped, externally verified playerClockAnchor remains the fallback; neither device time nor an arbitrary verified flag establishes source authority. Countdown progress follows actual playback, not time spent paused or stalled. Initial tune-in plays content without waiting for GAM, and the initial zero-to-live-edge transition is not a viewer rewind. Late/unready opportunities emit adbreakskipped, not synthetic playback. The media worker enables coordinated deferred resume; numeric alignmentToleranceSeconds is 0.002–0.250 seconds, default 0.250.

Roku viewer DVR request: reloadAfterSeek

The application may explicitly accept a new URL only for this viewer-requested DVR operation, backward or forward, on the same Video. The SDK does not stop, detach, replace content or seek on the application's behalf.

Preferred optional startup strategy: caller intent
  1. Capture the requested target in the old generation's Video-relative coordinates from the UI and retain that generation. Stop/detach the same Video and wait until it is no longer playing, paused or buffering. Do not issue an old Video.seek; no playbackreloadrequired event is needed.

  2. Call the optional strategy explicitly:

    operationId = sdk.CallFunc("reloadAfterSeek", {
        position: requestedOldRelativePosition
        generation: oldGeneration
        resumeStrategy: "startup"
    })

    The SDK validates the target using coherent native content-clock evidence and the current published source mapping; a caller-supplied verified flag cannot bypass it. Up to 128 verified content-clip spans retain old relative-position mappings across an ad: old position → historical published PDT → current source mapping. History resets by generation and refuses ambiguous, stale, evicted or ad-contained points. Optional sourcePdt only checks consistency within the unchanged 250 ms guard; it never supplies clock authority. The new generation preserves configuration, parameters and macros while fencing old workers, prepared pods and tracking. Fresh GAM warmup precedes publication. Only the new first publication is trimmed at whole content segments, preserving media/ad limits, PDT and immutable old snapshots.

  3. Match the operation ID through reloading and ready. ready.resume contains strategy: "startup", sourcePdt, verified: true, generation, contentPlayStart, contentPlayStartTimebase: "roku-hls-pdt-2004", windowOffset, requiresNativeClock: true and timelineRevision. contentPlayStart is a native Roku HLS-PDT-2004 Double: the target's published PDT minus 1072915200 seconds. It is not Unix UTC, an old relative target or windowOffset (the separate relative offset in the new window). Use the supplied value unchanged, including when published PDT differs from the source bookmark. For the correlated ready result:

    content = CreateObject("roSGNode", "ContentNode")
    content.url = result.playbackUrl
    content.streamFormat = "hls"
    content.playStart = result.resume.contentPlayStart
    video.seekMode = "accurate"
    video.content = content
    video.control = "play"

    Set both playStart and seekMode before attach/play on the same Video. No Video.seek or resume-ready is needed. A source-PDT window offset used as playStart was ignored in the first device experiment and went live; the HLS-PDT-2004 coordinate above was subsequently verified.

  4. Wait for resumed. ready.resume.verified validates the command, not its execution: tracking stays fenced until actual coherent new-generation native UTC/progression confirms the preserved source bookmark within the unchanged one-second tolerance. Never report success merely because play started.

Backward-compatible default seek strategy

Omitting resumeStrategy (or using "seek") retains the existing sequence below. It is not silently upgraded to startup. Short native Video.seek commands can be ignored or stall on the tested Ultra; this legacy path is not certified as repeatable. Prefer the explicit startup strategy above for caller intent.

  1. Save the verified source bookmark from the playbackreloadrequired event (also exposed in status), then stop/detach playback and wait until the bound Video is no longer playing, paused or buffering.
  2. Call CallFunc("reloadAfterSeek", { position, generation, sourcePdt }). position is the old Video-relative target; generation is an optional stale-call guard and sourcePdt an optional consistency check. The SDK validates the target against its source clock and published window; the caller cannot supply a verified flag to bypass validation.
  3. Correlate one operation ID through reloading and ready. The new generation preserves session configuration, runtime parameters and macros, but fences old workers, gateways, prepared pods and tracking. Load ready.playbackUrl on the same Video and play. At this point resume preserves sourcePdt and requires a new-generation clock; it is not yet a relative seek target.
  4. Wait for resume-ready with resume.verified: true and resume.requiresNativeClock: false, then apply video.seek = result.resume.requestedPlayerPosition. This is derived from validated new-generation clock/mapping evidence, not UTC seconds or a raw DVR-window offset.
  5. Wait for resumed, which confirms the requested relative position and source bookmark together before tracking is re-enabled. The expected application seek does not cause another reload.

For either strategy, named failures include source-clock-unavailable, stale-generation, same-video-required, playback-detach-required, source-pdt-mismatch, ambiguous-native-history, published-mapping-unavailable and seek-outside-published-window. Startup also refuses unsupported conditions with startup-target-inside-ad, startup-target-not-in-source, startup-unsupported-alignment or startup-window-too-short. Do not repair a failure by inventing UTC, widening the guard or clamping to live. HLS with history is not automatically rejected; supported live viewing remains available.

error and cancelled are terminal operation outcomes. Match operation ID and generation, stop/detach before retrying, and discard stale callbacks. A resume confirmation timeout fences tracking, clears pending resume and leaves the session inactive/error without touching the app's Video. The app explicitly ends/restarts if the viewer chooses return to live; it must not treat ready as proof of landing or silently convert a failed DVR request to a live seek. Fresh GAM preparation uses a bounded startup window. A preparation-failed skip with diagnostic reason gam-metadata-unproven retains content rather than fabricating an ad; successful content resume is not proof of successful refill or replay.

Roku shutdown and acceptance limits

Call endSession explicitly. If playback is still attached, the operation reports draining / playback-detach-required; the proxy stays available for published playback. The app must stop/detach before destroy, which otherwise refuses, or before replacement. Worker retirement and retries are bounded and diagnosed; an unconfirmed retirement does not authorize reuse. Never remove the component while the Video still uses its URL. Abandonment reports aderror/diagnostics, not fabricated adend or IMA completion.

DVR (reloadAfterSeek and startup resume) stays experimental: content-only reloads work, but GAM ads after a seek are not part of the supported scope, and a no-fill or refusal never counts as a played ad. ROKU-* diagnostics are native-only, not part of the shared taxonomy. See Roku for the integration guide, diagnostics and limitations.

React Native: keep playback ownership separate from UI

@dolby-optiview/ads-sdk-react-native exports OptiViewAdsSession and useOptiViewAds on native and web. The session owns one connector startup and safe asynchronous cleanup; the hook observes its lifecycle without debug polling.

Use useOptiViewAds({ ownership: 'hook', createSession }) for ordinary components, with a memoized factory returning new OptiViewAdsSession(connector, sessionConfig) or null until the player is ready. The hook destroys its session on unmount and waits for cleanup before replacing it when the factory changes.

For a floating player, retain the session in the application's playback owner and use useOptiViewAds({ ownership: 'external', session }). UI unmount only removes observation; manifest polling and native playback continue. The owner must retain the actual native player too, and call await session.destroy() on real close. Restoring UI observes the same session instead of starting another. This ownership choice is independent of program-boundary targeting updates, which use the connector's updateAssetParameters and updateAssetParameterMacros methods.

Reusable React Native player wiring

useTHEOplayerAdsBinding({ config, adsConfig, sessionConfig, enabled }) returns playerConfig, playerHandlers, and a stable createSession factory. Pass the ready/destroy handlers and configuration to THEOplayerView, and the factory to useOptiViewAds({ ownership: 'hook', createSession }). Equivalent configuration values do not restart ads; other changed values do. Changes to sessionConfig.assetParameterMacros alone never restart: the binding applies them to the running session through updateAssetParameterMacros, so per-render targeting values cannot interrupt playback, an SSAI stream or an ad break. Use connector updateAssetParameters for asset-parameter changes that must not restart playback. For app-owned floating playback, retain the session outside React and call playerHandlers.onPlayerRestored(player) after a handoff; that callback is an application integration point, not a player-view prop.

Optional useOptiViewAdsDebug({ connector: ads.connector, status: ads.status, enabled: debugEnabled }) exposes bounded event summaries, ad metadata, sampled break/presentation state, history clearing and diagnostic export. It adds no UI and never owns playback. Disable it to remove automatic subscriptions and polling. History omits raw payloads; metadata is intended for local inspection, not telemetry.

Start VOD from a bookmark

Apply the saved position to the content player before starting the session or playback. Do not use sdk.seek() or connector.seek() after playback starts to restore a bookmark: those methods represent viewer seeks and can trigger snapback.

For VOD with a media-time ad schedule:

  • A saved position above 0.5 seconds skips all pre-rolls, including delayed pre-rolls and an ad break scheduled at zero.
  • Numeric breaks starting more than 0.5 seconds before the saved position are skipped. A break starting within 0.5 seconds of it plays in full.
  • Later breaks play normally. Starting at or below 0.5 seconds keeps normal pre-roll behavior, including immediate pre-roll holding.
  • Initial restoration is not viewer snapback. Subsequent viewer seeks retain normal snapback behavior; rewinding into or before an earlier break can make it eligible again.

Set the initial position as follows, then await startSession() before requesting playback. There is no separate bookmark session option.

SDK / content player Apply the saved position
Web — hls.js Set startPosition in the hls.js configuration before loading the source.
Web — Shaka Load with await player.load(url, savedSeconds).
Web — THEOplayer Set currentTime once source metadata is available and let the seek settle before playback.
Web — native video After loadedmetadata, set video.currentTime = savedSeconds and wait for seeked before playback.
Android / Android TV — Media3 Use setMediaItem(item, startPositionMs) or seekTo(startPositionMs) before prepare/play.
Android / Android TV — THEOplayer Set currentTime before playback; readiness requires current data and no pending seek.
iOS / tvOS — AVPlayer Complete seek(to:completionHandler:) or its tolerance overload successfully before calling startSession(), or otherwise position the item first. readyToPlay alone does not mean a raw seek has completed.
iOS / tvOS — THEOplayer Apply currentTime before session start. The bundled adapter waits for current data and no pending seek. Complete restoration first if a custom surface does not expose pending seeks.
React Native Set the position on the RN host player before startSession(); on iOS/tvOS, wait for the host seek to complete successfully first. Native hosts follow the Android/Apple rows; RN web follows the web rows.

Web and Android can start the session while the source is loading if the player's initial position is already configured. Scheduling waits for a finite, settled position. Custom web adapters reporting provisional positions should implement the existing optional playbackReady signal; custom native adapters should provide their existing readiness capability or complete restoration first.

TV browsers Tizen, webOS and Vizio use the same web bookmark behavior even though viewer snapback is disabled there. Live and wallclock/PTS schedules are unchanged. Roku VOD playback is not supported.

Try it: open the VOD demo, choose Load snapback sample, set Start position (seconds) to 45, then choose Run VOD demo. The break at 10 seconds is skipped and the break at 45 seconds plays in full. Use zero to compare normal startup, or paste a manifest with a pre-roll to compare its eligibility. The demo prepares the selected position before starting the session and requesting playback; changing the field affects the next run, not a running session.

Web

startSession(config: SessionConfig): Promise<void>

Starts manifest polling and (if GAM is configured) initializes the IMA stream session. Resolves when the first manifest has been fetched successfully.

await sdk.startSession({
  manifestUrl:
    'https://manifest.example.com/v1/your-org/channels/d7803a87-465a-4e43-b12e-6f479be119a1',
  customAssetKey: 'my-asset-key',
  adInsertionType: 'replacement', // 'replacement' (DAR, default) | 'insertion' (DAI)
  assetParameters: { cust_params: 'genre=sports' },
});
// Now load and play your content
hls.loadSource(contentUrl);
video.play();

Ads manifest from THEOlive discovery. With THEOplayer and a THEOlive source, the player loads a discovery response that can carry the channel's ads manifest URL (ads.adsManifestUrl). The THEOplayer adapter can read it. Turn this on with manifestUrlDiscovery: true in the SDK constructor (off by default); you can then omit manifestUrl:

const sdk = new OptiViewAds({ player, container, manifestUrlDiscovery: true });
player.source = { sources: [{ type: 'theolive', src: 'your-distribution-id' }] };
await sdk.startSession({}); // uses the discovered ads manifest URL
  • An explicit manifestUrl always wins.
  • With manifestUrlDiscovery off (the default), a missing manifestUrl rejects as before (DA-MANIFEST-URL-UNAVAILABLE reason disabled), and the adapter does not observe discovery at all.
  • If discovery has not finished yet, startSession() waits up to 10 seconds. It rejects when the discovery response has no ads manifest URL, when no discovery result arrives in time, or when the player adapter cannot discover a URL (every adapter except THEOplayer on Web and Android). A rejection does not end a session that is already running.
  • Set the source before you await startSession(): the discovery request only starts once the player has a THEOlive source.
  • Calling endSession() while startSession() waits cancels the start quietly.
  • A session started this way follows the discovery response: a new ads manifest URL restarts the session, and a distribution without one ends it. Sessions started with an explicit manifestUrl are never changed.
  • Create the SDK (and its THEOplayerAdapter) before you set the THEOlive source, otherwise the adapter misses the discovery response.
  • The adapter reads discovery responses from discovery.theo.live, discovery.sneezysparrow.com and api.sneezysparrow.com.
  • Reported through DA-MANIFEST-URL-DISCOVERED and DA-MANIFEST-URL-UNAVAILABLE.

The same rule applies on Android (OptiViewAdsConfig(manifestUrlDiscovery = true), then SessionConfig(manifestUrl = null)) and on iOS (OptiViewAdsConfig(manifestUrlDiscovery: true), then a SessionConfig without manifestUrl). On iOS the THEOplayer adapter needs THEOplayer 11.15.0 or later: it reads ads.adsManifestUrl from the THEOlive distribution, so the app must link THEOplayerTHEOliveIntegration. On Roku the OptiViewAds:OptiViewAdsInterceptor node does the same for the OptiView Player: call its configure function with the startSession config minus manifestUrl and it starts the session from the discovery response (see the Roku README).

Immediate pre-rolls hold content automatically. When the first manifest contains a content-covering pre-roll (start: { type: 'event', event: 'start' }, or the legacy position: 'pre') with no delay (or delay: 0), the SDK holds the content player at session start — pausing it and re-pausing if your own play() (above) starts it — so no content frames are shown before the ad. The pre-roll begins once the content player reports its media is loaded, or after 10 seconds. If content fails to load first, the pre-roll is cancelled and the SDK reports DA-PREROLL-CANCELLED-CONTENT-ERROR. The hold is released the moment the pre-roll begins (the break then owns content pause/resume) and on endSession(). A delay > 0 pre-roll plays content first: the delay counts played media time from the first content frame (paused time and seeks do not count). Reported via the DA-PREROLL-CONTENT-HELD diagnostic.

adInsertionType (DAR vs DAI, SGAI only). Controls how a break relates to the content timeline. replacement (DAR, the default) keeps the historical resume behaviour — the replaced content window is skipped only when a break carries an explicit resumeOffset. This is intended, not a bug: without a manifest resumeOffset, DAR resumes content from the same position the break started at (the classic "replace this window of content with an ad, then continue from where it left off" model); set resumeOffset on the break when you want DAR to skip forward past the replaced window. insertion (DAI) resumes content at the exact pre-break position. A break's manifest resumeOffset overrides the mode default in both cases. A manifest resumeOffset is exact: content resumes at the break position plus the offset whatever the ads delivered, shorter or longer. Resume-seek is applied on the positional pts and mediatime timebases for content-pausing break formats; it is ignored in SSAI mode (the stitcher controls insertion server-side, reported via the DA-INSERTION-TYPE-IGNORED-SSAI diagnostic). The demo's Ad Insertion Type selector drives this (and the ?adInsertionType= URL param). The dedicated VOD (DAR/DAI) demo page lets you contrast the two against your own VOD asset and break manifest: pick DAR or DAI, paste a PTS mid-roll manifest (provisioned via the break-manifest server — the hosted one on the deployed demo, or a local one under npm run dev), and watch the resume behaviour differ on break end.


endSession(): void

Stops manifest polling and resets the GAM session. Call this when the user navigates away, changes channel, or stops playback.

endSession() is for channel changes made by the application (a different manifestUrl). When the backend re-points the same manifest URL to another ads channel, the SDK handles it inside the running session and emits adchannelchange — see Channel switch on the Manifest page.

On an ads-channel switch, delivery mode is resolved again. An event boundary also emits adchannelchange with reason event-boundary and the active eventId. The event reports previousDeliveryMode and deliveryMode; after an ssai to sgai switch, load the content stream in the application after receiving the event.

sdk.endSession();

updateAssetParameters(params: Record<string, string>): void

Replaces the live-update layer of the asset parameters. Useful for changing targeting (a sport segment change, a consent update) without restarting the session.

The per-key precedence is SessionConfig.assetParameters < updateAssetParameters() < the manifest session layer (vendorConfiguration.gam.sgai[0].assetParameters or ssai[0].assetParameters) < the per-asset assetParameters map. It replaces the previous update rather than accumulating onto it. Static assets skip the manifest session layer, which targets GAM only.

Applies to future ad breaks — a break whose ad request has already gone out cannot be retargeted. Consumed by GAM pods (IMA ad-tag parameters), by VAST assets (appended to the tag URL as query parameters) and by static assets (appended to the resource URL: the media, image, companion or pause-ad URL, for HLS/DASH only the master playlist or MPD request). Inline data: URLs have no query component and are never changed. See the Manifest page.

sdk.updateAssetParameters({ cust_params: 'sport=basketball' });

updateAssetParameterMacros(macros: AssetParameterMacroUpdates): void

Merges the supplied macro names into the session table. "" and null mark a customer macro empty so parameters using it are not sent; undefined unregisters the macro so a built-in value can apply again. An undefined entry in the initial map is not registered. Names not supplied remain unchanged. An active GAM stream receives the re-resolved targeting through replaceAdTagParameters(), while VAST uses the new values on its next request. An ad already loaded is not re-requested.

sdk.updateAssetParameterMacros({ $CUSTOM_TEAM$: 'basketball', $OLD_TEAM$: undefined });

Asset-parameter macros (SessionConfig.assetParameterMacros)

type AssetParameterMacroValue = string | null | undefined;
type AssetParameterMacro = AssetParameterMacroValue | (() => AssetParameterMacroValue);
type AssetParameterMacros = Record<string, AssetParameterMacro>;

startSession() accepts asset-parameter macros as assetParameterMacros. Every full $NAME$ token found inside an asset-parameter value (from the manifest, the session, or updateAssetParameters()) is replaced by macros['$NAME#39;] when the ad request is built: a string replaces the token, null marks it empty, and a callback is invoked on every request (for values that change over time). A value may hold several macros next to literal text — "$OPTIVIEW_PLAYER_WIDTH$x$OPTIVIEW_PLAYER_HEIGHTquot; becomes "1920x1080". Names are case-sensitive, and $APP$ and $APP_NAME$ never collide. A $ without a closing $ is left unchanged. Session-level GAM/SSAI requests have no break yet, so break-duration macros are sent as literal text and reported as DA-ASSET-MACRO-UNKNOWN. The macros are cleared by endSession().

Macro values have three states:

  1. A non-empty string replaces the token; "", null, or undefined returned by a registered callback marks it empty.
  2. An empty macro omits a plain parameter, or only the containing pair in any value with a literal &. If no pair remains, the key is omitted. This applies to GAM, VAST, and static assets.
  3. A core-table unresolved value leaves the token literal. An undefined entry in the customer map is not registered; updateAssetParameterMacros() uses an undefined update to unregister a name.

The built-in macros are resolved by the SDK and can be overridden by registering the same name. Their names are exported as OPTIVIEW_ASSET_PARAMETER_MACROS (USER_AGENT, PLAYER_WIDTH, PLAYER_HEIGHT, BREAK_DURATION_MS, BREAK_DURATION_SECONDS):

Macro Value
$OPTIVIEW_USER_AGENT$ navigator.userAgent (Android: http.agent; iOS: none — register your own)
$OPTIVIEW_PLAYER_WIDTH$ Ad container width in logical pixels (CSS px / dp / pt)
$OPTIVIEW_PLAYER_HEIGHT$ Ad container height in logical pixels (CSS px / dp / pt)
$OPTIVIEW_BREAK_DURATION_MS$ Ad duration in whole milliseconds (the asset's duration, else the break's)
$OPTIVIEW_BREAK_DURATION_SECONDS$ The same duration in seconds (30, 15.5)

Resolution order and fallbacks:

  1. A customer macro wins over a built-in $OPTIVIEW_* name.
  2. Otherwise the built-in value is used.
  3. A macro that resolves to "", null, or a registered callback's undefined omits its parameter, or only the affected pair of any literal-& value.
  4. An unresolved $OPTIVIEW_* name (unknown or unavailable in the core table) is kept literally in the value; the parameter is still sent and emits DA-ASSET-MACRO-UNKNOWN once per parameter key and macro (context: key, macro).
  5. An unresolved complete token with any other prefix ($PUBLISHER_ID$, ${OPTIVIEW_X}, …) is kept literally in the value without a diagnostic, so vendor-side macros pass through untouched.

updateAssetParameterMacros() uses null or "" to mark a macro empty and undefined to unregister it. An undefined entry in the initial map is not registered. DA-ASSET-PARAMETER-OMITTED reports empty macros; DA-ASSET-MACRO-UNKNOWN reports unresolved built-in or registered macros.

import { OPTIVIEW_ASSET_PARAMETER_MACROS } from '@dolby-optiview/ads-sdk';

const assetParameterMacros = {
  $SEGMENT$: 'sports', // fixed value
  $CUSTOM_TEAM$: () => currentTeam(), // evaluated on every ad request
  $CUSTOM_USER_ID$: () => user?.id, // undefined → empty when the user id is unavailable
  [OPTIVIEW_ASSET_PARAMETER_MACROS.USER_AGENT]: 'MyApp/2.1 (SmartTV)', // overrides the built-in
};

await sdk.startSession({
  manifestUrl,
  assetParameterMacros,
  assetParameters: {
    pod_duration: '$OPTIVIEW_BREAK_DURATION_SECONDS#x27;,
    dimensions: '$OPTIVIEW_PLAYER_WIDTH$x$OPTIVIEW_PLAYER_HEIGHT#x27;, // macros inside a value → "1920x1080"
  },
});

In this demo, the Asset Parameter Macros field of the Session card takes the same map as JSON. Strings, "", and null can be written in JSON: {"$SEGMENTquot;: "sports", "$CUSTOM_TEAMquot;: null} sends $SEGMENT$ as sports and omits every parameter that contains $CUSTOM_TEAM$. Callbacks and undefined are not JSON; leave a macro out of the map to avoid registering it. The parsed map is passed to startSession() unchanged. The omission is visible after Load: the event log shows DA-ASSET-PARAMETER-OMITTED with the omitted key and macro, and the SDK debug log in the browser console (Preloading VAST ads: <url>) shows the tag URL without that key. After Load, the Update asset parameter macros input ($NAME$=value, $NAME$=null, $NAME$=undefined) calls updateAssetParameterMacros() for the next ad request.


destroy(): void

Tears down the entire SDK instance, releasing all resources. Call this when the player is unmounted.

sdk.destroy();

play(): Promise<void>

Proxy for contentPlayer.play(). Suppressed automatically during content-locking ad breaks (e.g. single format) so the ad is not interrupted. Prefer this over calling your player directly so break policies are honoured.

await sdk.play();

pause(): void

Proxy for contentPlayer.pause(). No-op during a content-locking ad break.

sdk.pause();

seek(time: number): void

Seek the content stream to a position in seconds; seeks during a break are let through (content is paused behind the ad). For VOD, a forward seek from before an unplayed, playable mediatime-scheduled snapback break to its start or later plays it in full at once, while content lands paused on the requested position; content is never seeked back to the break. This is seek-over regardless of ad duration. Single and L-Shape Ad pause content and resume at the requested position, overriding DAR/DAI insertion policy, resumeOffset and ad duration, even on no-fill. Double Box, L-Shape Content and Overlay are not snapback formats: a seek over them plays on, and content is never seeked at their edges. Backward seeks and seeks entirely after a scheduled start do not force that break, regardless of its declared ad duration. The last crossed snapback break is the only candidate; if it is already played or unplayable, all crossed breaks are skipped without fallback. Other crossed breaks cannot tune in or chain during that seek and remain unplayed for later viewer seeks. Once a break starts it cannot cause another snapback in the same session; a channel switch or destroy clears that ledger. Ordinary DVR replay is unchanged.

The SDK handles direct content seeked events, including small jumps. Scheduler position jumps greater than two seconds cover players without direct viewer seek notifications, including AVPlayer. The SDK issues no corrective seeks; diagnostics use DA-SNAPBACK-APPLIED (the crossed break that plays) and DA-SNAPBACK-NOT-APPLIED (for example a seek during an active break).

After a rewind, a viewer seek landing at or after an already-started break's scheduled start skips it instead of tuning into it again. Eligible forward seeks crossing a played break emit DA-SNAPBACK-NOT-APPLIED with reason already-played; normal playback reaching its start still replays it.

While an SDK return seek settles, stale content positions and seeked events repeating the latest stale position cannot trigger an earlier overlapping break. This protection ends on a landing within 0.5 seconds of the target, after two seconds, or on a viewer seek. Explicit viewer seeks, and raw seeked events at a different position, still supersede it. It does not change viewer seek-into behavior.

This policy applies to time-scheduled VOD client-side and GAM breaks only. Live, wallclock/PTS timebases, event-triggered breaks, SSAI and SSB are unchanged. The web single-decoder Tizen/webOS/Vizio gate remains off. Android/Android TV, iOS/tvOS and the React Native hosts use the same native scheduling policy.

For saved initial positions, see Start VOD from a bookmark. seek() is for subsequent viewer seeks, not initial restoration.

A seeked landing within an inclusive 0.5 seconds of the planned viewer target is part of the same seek only during the two seconds after planning. Bookmark re-earning and VOD rewind re-arming require going below the scheduled break start, not below start plus ad duration; the bookmark tolerance still applies. VOD starts crossed between consecutive playback samples still play in full during fast-forward or sparse updates, independently of tuneIn.enabled; explicit viewer seek notifications exclude that move. For non-jump crossings more than five seconds late, Single, L-Shape Ad and their fullscreen fallbacks seek back to the start before the break begins and resume from that start afterwards. Detected jumps (movement greater than elapsed wall time plus two seconds), including accelerated steps above that threshold, instead resume at the sampled landing after the ads; pausing layouts still begin at the break start. Content-continuing layouts do not seek. Short ads crossed within the five-second tolerance still play in full; non-jump crossings there need no correction. Only the last start crossed in a sampling gap plays; earlier breaks remain unwatched and can re-arm after rewind. A first sample already past the start, or a break first published after its start, does not late join. Declared ad duration is not VOD content time. Live/PTS/wallclock join-in-progress behavior is unchanged.

Try it: on the VOD demo page, choose Load snapback sample, start before 10 seconds and seek to 15 seconds. The full 15-second break plays. Single and L-Shape Ad then return to 15 seconds; content-continuing formats play on without a seek. Seeking past 25 seconds also returns to that requested target for pausing layouts. Ad duration does not change this rule.

The snapback sample includes a second 15-second mid-roll at 45 seconds. Seeking from before 10 seconds to past 60 seconds selects only the later mid-roll at 45 seconds. If it has already played or is unplayable, neither crossed break plays. Skipped crossed breaks cannot tune in or chain; uncrossed future breaks retain normal behaviour. A fresh session resets the played-once ledger. The default sample remains unchanged when snapback is off.

Snapback applies to every playable format: Single, Double Box, L-Shape Ad, L-Shape Content and Overlay. The complete break is presented from the beginning, including the full display duration of an image/backdrop break. Resume behavior uses the layout presented at break start: a fullscreen fallback (web shared-element, PiP or handheld fallback) counts as Single. L-Shape Content is not promoted to Single on these paths. Seek-over bypasses chaining only when it returns to the requested position; content-continuing formats use normal flow and chaining, with no return seek.

sdk.seek(180); // seek to 3:00 in the content stream

muted: boolean

Unified mute state. Reading or writing sdk.muted always targets whichever player is currently audible — the ad player while a break is playing, the content player otherwise — so a single mute control works correctly across break transitions in both directions. Setting it also bridges into IMA for a VAST/CSAI ad in progress, since IMA drives its own audio path independently of the underlying <video> element.

sdk.muted = true; // mute whatever is currently playing
const isMuted = sdk.muted;

volume: number

Unified volume (0-1). Same effective-player targeting as muted above.

sdk.volume = 0.5;

Event: volumechange

Fires whenever the unified mute/volume state changes — via the muted/volume setters above, a direct mutation of the content or ad element that the SDK's internal sync picked up, or an IMA CSAI ad's own UI. Carries the resulting muted/volume values so a UI can keep a mute button's label correct without polling:

muteButton.onclick = () => {
  sdk.muted = !sdk.muted;
};
sdk.addEventListener('volumechange', (e) => {
  muteButton.textContent = e.muted ? 'Unmute' : 'Mute';
});
Web (@dolby-optiview/ads-sdk-core) only for now — see Custom Player UI for a full worked example, and Events for the event payload shape. Android/iOS parity is tracked as a follow-up.

Lifecycle example

// App startup
const sdk = new OptiViewAds({ ... });

// User starts watching a channel
await sdk.startSession({ manifestUrl, customAssetKey });
hls.loadSource(channelUrl);

// User switches to another channel
sdk.endSession();
await sdk.startSession({ manifestUrl: newManifestUrl, customAssetKey: newKey });
hls.loadSource(newChannelUrl);

// App teardown
sdk.destroy();

Android (Kotlin)

The lifecycle methods mirror the web API. startSession is a suspend function (call it from a coroutine); the rest are synchronous. The method set is startSession / endSession / updateAssetParameters / updateAssetParameterMacros / play / pause / seek / destroy, plus isSessionActive() / isAdPlaying().

Method Signature Notes
startSession suspend fun startSession(config: SessionConfig) Begins polling + GAM init. Ends any active session first. Throws if the first manifest fetch fails.
endSession fun endSession() Stops polling and resets the GAM session. No-op if inactive.
updateAssetParameters fun updateAssetParameters(params: Map<String, String>) Replaces the live-update layer of the asset parameters (GAM, VAST and static assets). No-op (logs) without an active session.
updateAssetParameterMacros fun updateAssetParameterMacros(macros: Map<String, (() -> String?)?>) Merges the given macros into the session macros (other names stay); null or "" marks a name empty and undefined unregisters it. Applies to the next ad request. No-op (logs) without an active session.
SessionConfig.assetParameterMacros Map<String, () -> String?> Customer macros as zero-argument callbacks (a fixed value is a constant callback, { "sports" }); "" or null omits the parameter, and a callback returning undefined is empty. An undefined map entry is not registered. Any literal-& value drops only the containing pair. Built-in names: OptiViewAssetParameterMacros.
play / pause fun play() / fun pause() Proxy the content player; no-op while a content-locking break is active.
seek fun seek(time: Double) Seconds. A crossed unwatched snapback break plays first. No-op with no session.
destroy fun destroy() Tears down the SDK, detaches player listeners, cancels the scope.
// User starts watching a channel
scope.launch {
    sdk.startSession(
        SessionConfig(
            manifestUrl = "https://manifest.example.com/v1/your-org/channels/d7803a87-465a-4e43-b12e-6f479be119a1",
            customAssetKey = "my-asset-key",
            assetParameters = mapOf(
                "cust_params" to "genre=sports",
                "dimensions" to "\$OPTIVIEW_PLAYER_WIDTH\$x\$OPTIVIEW_PLAYER_HEIGHT\quot;, // macros inside a value → "1920x1080"
            ),
            assetParameterMacros = mapOf("\$CUSTOM_TEAM\quot; to { currentTeam() }),
        ),
    )
    contentPlayer.setMediaItem(MediaItem.fromUri(channelUrl))
    contentPlayer.prepare()
    contentPlayer.playWhenReady = true
}

// Update targeting mid-session (no restart)
sdk.updateAssetParameters(mapOf("cust_params" to "sport=basketball"))
sdk.updateAssetParameterMacros(mapOf("\$CUSTOM_TEAM\quot; to { "lakers" }))

// Switch channel
sdk.endSession()
scope.launch { sdk.startSession(SessionConfig(manifestUrl = newManifestUrl, customAssetKey = newKey)) }

// Teardown (then release your ExoPlayer)
sdk.destroy()

iOS / tvOS (Swift)

startSession is async throws (call it from a Task); the rest are synchronous. Same method set as Android.

Method Signature Notes
startSession func startSession(_ config: SessionConfig) async throws Begins polling + GAM init. Ends any active session first. Throws if the first manifest fetch fails.
endSession func endSession() Stops polling and resets the GAM session.
updateAssetParameters func updateAssetParameters(_ params: [String: String]) Replaces the live-update layer of the asset parameters (GAM, VAST and static assets).
updateAssetParameterMacros func updateAssetParameterMacros(_ macros: [String: (() -> String?)?]) Merges the given macros into the session macros (other names stay); nil removes a name so the built-in value applies again. Applies to the next ad request. No-op (logs) without an active session.
updateAssetParameterMacros(values:) func updateAssetParameterMacros(values: [String: (() -> AssetParameterMacroValue)?]) Same merge, with three-state callbacks: .text("…") replaces the token, .empty omits the parameter or affected pair of any literal-& value, .unresolved keeps the token literally and falls back to a built-in when one exists. A nil entry removes the name.
SessionConfig.assetParameterMacros [String: () -> String?] Customer macros as zero-argument callbacks (a fixed value is a constant callback, { "sports" }); "" or nil is empty. A nil map entry is not registered. Built-in names: OptiViewAssetParameterMacros. iOS has no built-in $OPTIVIEW_USER_AGENT$ — register one or the literal token is sent.
SessionConfig.assetParameterMacroValues [String: () -> AssetParameterMacroValue] Three-state customer macros (.text / .empty / .unresolved); an entry here wins over the same name in assetParameterMacros. An omitted parameter raises DA-ASSET-PARAMETER-OMITTED.
play / pause func play() / func pause() No-op while a content-locking break is active.
seek func seek(_ time: Double) Seconds. A crossed unwatched snapback break plays first.
destroy func destroy() Tears down the SDK and detaches player observers.
// User starts watching a channel
Task {
    do {
        try await sdk.startSession(
            SessionConfig(
                manifestUrl: "https://manifest.example.com/v1/your-org/channels/d7803a87-465a-4e43-b12e-6f479be119a1",
                customAssetKey: "my-asset-key",
                assetParameters: [
                    "cust_params": "genre=sports",
                    "dimensions": "$OPTIVIEW_PLAYER_WIDTH$x$OPTIVIEW_PLAYER_HEIGHTquot; // macros inside a value → "1920x1080"
                ],
                assetParameterMacros: ["$CUSTOM_TEAMquot;: { currentTeam() }]
            )
        )
        contentPlayer.replaceCurrentItem(with: AVPlayerItem(url: channelUrl))
        contentPlayer.play()
    } catch {
        print("startSession failed:", error)
    }
}

// Update targeting mid-session (no restart)
sdk.updateAssetParameters(["cust_params": "sport=basketball"])
sdk.updateAssetParameterMacros(["$CUSTOM_TEAMquot;: { "lakers" }])

// Switch channel
sdk.endSession()
Task { try await sdk.startSession(SessionConfig(manifestUrl: newManifestUrl, customAssetKey: newKey)) }

// Teardown
sdk.destroy()

Events

On Web, Android and iOS, an ad that fails before adbegin emits only aderror, without adend. If it already started, the order is adbegin → aderror → adend. Failed assets still reduce adsRemaining. Slate and empty-break events are unchanged.

On web, Android, iOS/tvOS and React Native, an active break ends with adbreakstatus(complete) → adbreakstatus(idle) → adbreakend. The single complete snapshot identifies the ending break and has ticking: false, breakRemainingSec: 0 and adsRemaining: 0. Cuts and errors also end a break; completion does not mean every ad was watched. Skipped breaks and session teardown do not synthesize completion. The getter returns idle after cleanup, so subscribe to the event to observe completion. See Ad break status.

Subscribe via sdk.addEventListener(type, handler). All events include a type string and a timestamp (epoch milliseconds with millisecond precision).

Scheduled break changes

scheduledbreakschange carries { breaks: ScheduledBreak[] }. It fires when manifest or viewer inputs change the list, after adbreakbegin marks a break played, when bookmark/overlap exclusions remove a break, and with [] on session end. Equal snapshots do not emit. Played stays true after rewind. The getter returns the same latest snapshot (a copy).

renderMarkers(sdk.getScheduledBreaks());
sdk.addEventListener('scheduledbreakschange', ({ breaks }) => renderMarkers(breaks));

Android:

renderMarkers(sdk.getScheduledBreaks())
sdk.addEventListener(OptiViewAdsEventType.SCHEDULEDBREAKSCHANGE) { event ->
    if (event is ScheduledBreaksChangeEvent) renderMarkers(event.breaks)
}

iOS:

renderMarkers(sdk.getScheduledBreaks())
sdk.addEventListener(.scheduledbreakschange) { event in
    if case let .scheduledBreaksChange(breaks, _) = event { renderMarkers(breaks) }
}

React Native uses the same listener and await connector.getScheduledBreaks(). Live wallclock starts are ISO dates, not content seconds; unresolved PTS starts are null. Map live dates to the host timeline before drawing scrubber markers.

Event list

All three SDKs expose the shared lifecycle event types (OptiViewAdsEventType) with equivalent payloads — only the subscription idiom differs. The event table below applies to every platform; use the Web / Android / iOS switcher at the top of the sidebar for platform-specific code. volumechange is currently Web-only.
Event When Key payload fields
adbreakskipped A scheduled opportunity is retired before its break begins break — full Break object; reason — stable skip reason; format? — selected format when known
adbreakstatus Break state or countdown changed — upcoming warning, active break progress, completion status — AdBreakStatus object (see below)
scheduledbreakschange Viewer-playable scrubber schedule changed; equal snapshots do not emit breaks — ScheduledBreak[], also returned by getScheduledBreaks() (a Promise in React Native)
adbreakbegin Ad break starts (content paused) break — the full Break object; format — the break's ad format; tuneIn? — present ({ elapsedSec, remainingSec }) only when the viewer joined while the break was already in progress
adbreakend Ad break ends (content resumes) break, format
adclick The viewer activates an ad click-through break, format?, asset, clickThrough? — the host decides whether and how to navigate
adbegin Individual ad starts playing break, format, asset, adIndex, totalAds, adId?, creativeId?
adend Individual ad finishes break, format, asset, adIndex, totalAds, adId?, creativeId?
aderror Playback fails (non-fatal for ads, SDK recovers) source ('ad' | 'content'), error, break?, format?, asset?
adfirstquartile Ad reaches 25% completion break, format, asset, adIndex?, totalAds?
admidpoint Ad reaches 50% completion break, format, asset, adIndex?, totalAds?
adthirdquartile Ad reaches 75% completion break, format, asset, adIndex?, totalAds?
adtimeupdate Fires on each timeupdate tick during ad playback (~4 Hz) break, format, asset, currentTime, duration
waiting Playback stalls for buffering (native waiting) source ('ad' | 'content'), break?, asset?
playing Playback (re)starts after stalling or pausing — fires on every native playing source ('ad' | 'content'), break?, asset?
volumechange (Web only) The SDK's unified mute/volume state changed — via sdk.muted/sdk.volume, a direct mutation of the content/ad element, or an IMA CSAI ad's own UI muted, volume (0-1) — always describe the effective audio owner (ad player during a break, content otherwise)
adchannelchange The SDK re-aligned ad configuration after a channel change or event boundary without ending the session or interrupting content playback previousChannelId, channelId, eventId (each string | null); reason ('channel-id-changed' | 'channel-id-added' | 'channel-id-removed' | 'vendor-configuration-changed' | 'timebase-changed' | 'event-boundary' | 'external-playback'), manifestUrl, previousDeliveryMode, deliveryMode ('sgai' | 'ssai' | 'ssb')
externalvendorconfigurationchange A provider's manifest parameter template was added, removed, or changed; the initial manifest reports every provider provider

waiting, playing, and aderror are emitted for both the content player and the SDK-managed ad player. Use the source field to tell them apart; break/asset are only present when source === 'ad'. The source follows the ad, not the player: when an ad plays through the content player (picture-in-picture on iOS and Safari, shared-element/adaptive insertion on iPhone), that player's stalls during the ad are reported with source: 'ad', and as 'content' again once content is handed back.

Channel or event change (adchannelchange) — fires after the SDK has re-aligned to the current manifest. For an event boundary, reason is event-boundary and eventId identifies the event now in effect (or is null when no event is active). If a break is playing when the change is detected, that break finishes first; the latest manifest is then applied. Event-boundary changes preserve the active reporting session, and no DA-SESSION-ENDED/DA-SESSION-STARTED pair is emitted. With reason external-playback the SDK switched the content player to the channel's server-side beaconing stream because AirPlay started (deliveryMode: 'ssb') or restored the previous source and mode after AirPlay stopped. It is emitted only for a confirmed switch; a failed switch is reported by diagnostics only.
External provider templates — externalvendorconfigurationchange fires once per provider added, removed, or changed, including providers in the first adopted manifest. Changes to resolved macro values alone do not fire it. Call getExternalVendorConfiguration() immediately before passing values to the external system to obtain current macro values.
Unified audio (volumechange) — read/write sdk.muted (boolean) and sdk.volume (0-1) to control whichever player is currently audible; the SDK keeps content and ad playback in sync across break transitions in both directions and bridges into IMA for a VAST/CSAI ad in progress. Listen for volumechange to keep a mute button's label correct without polling:
muteButton.onclick = () => {
  sdk.muted = !sdk.muted;
};
sdk.addEventListener('volumechange', (e) => {
  muteButton.textContent = e.muted ? 'Unmute' : 'Mute';
});
Every break/ad-scoped event carries format — the declared format of the break's selected variant (single, double, lshape_ad, lshape_content, overlay; see Ad Formats). It lets you branch on the format (e.g. distinct UI for an L-shape vs a full-screen ad) without re-reading the manifest variant. It can be absent on adbreakskipped when no variant was selected, and on content-sourced aderror/waiting/playing (no break). Available identically on Web (e.format), Android (e.format: BreakFormat?), and iOS (event.format).
GAM (Google IMA DAI) pod-served ads emit the same balanced lifecycle as any other ad — adbreakbegin → adbegin → adend → adbreakend — and the quartile events (adfirstquartile/admidpoint/adthirdquartile) fire during playout. This relies on the SDK forwarding the ad player's in-stream timed metadata (ID3) to IMA, which is what also drives IMA's own ad-tracking beacons (impressions/quartiles) for monetization — so a working GAM lifecycle and correct beacon firing go together.
A GAM pod holding several creatives reports one ad per creative (Web). A pod is a single vendor asset in the break manifest, but Google may fill it with five or six ads. The SDK asks IMA how the pod was actually filled and emits one adbegin/adend pair per real ad, so adIndex/totalAds describe the pod's true composition (0/6, 1/6, …) instead of claiming 0/1 for the whole pod. Each ad gets its own asset, derived from the manifest pod asset as <podAssetId>-ad-<n> so you can still tell which pod it came from, plus IMA's adId/creativeId when supplied. The quartile events carry the adIndex/totalAds of the ad they belong to, so successive cycles inside one pod are attributable rather than looking like one ad passing its own midpoint repeatedly. adbreakbegin/adbreakend still bracket the pod as a whole, exactly as before.

Because the pod's real composition is only knowable once IMA reports it, the first adbegin waits briefly (up to 3s) for that report rather than announcing a value it would have to contradict. If IMA reports nothing in that window — an unfilled pod, or a runtime whose IMA session receives no timed metadata — the pod is reported as a single ad exactly as it was before, so nothing regresses. Android and iOS still report a pod as one ad (adIndex: 0, totalAds: 1); per-ad reporting there is tracked separately.

One deliberate exception: adtimeupdate stays pod-level. A GAM pod is a single stitched stream, so the ad player's currentTime/duration describe the whole pod, not the creative on screen — its asset therefore remains the manifest pod asset rather than the per-ad one. Drive per-ad progress from the quartile events, and whole-break progress from adbreakstatus.breakRemainingSec.

Break cut short (ad longer than its break) — when the effective break duration plus adBreakCutSafetyMarginSec (default 2 seconds), counted from first ad playback, elapses while an ad is still playing, the SDK hard-cuts back to content but still ends the in-flight ad cleanly: it emits adend (truncated) before adbreakend. Set adBreakCutSafetyMarginSec to 0 to cut at exactly the effective break duration from first ad playback (see configuration). So adbegin and adend always balance — every adbegin is followed by exactly one adend, whether the ad ends naturally or is cut. (A break that is cut before any ad begins emits no adend.) Identical on Web, Android, and iOS.

For machine-readable, code-tagged signals (and a shareable exportDiagnostics() report), see Diagnostics.

Roku event contract

The preceding shared API examples and balanced-completion rules describe the three core SDKs, not complete Roku parity. Roku delivers events through CallFunc("addEventListener", eventType, m.top, "handler") on the OptiViewAds node: the shared ad/break/status types, plus diagnostic for diagnostics, operationresult for asynchronous operations (there are no promises) and gatewayrequest for interception/macros. Keep generation/sequence and occurrence correlation; an old generation's callback must not update the current UI or tracking. The Roku section lists the Roku-only diagnostic codes.

Roku also emits adtimeupdate about every 0.25 seconds while playback progresses, not while paused, stalled or seeking. currentTime and duration are in seconds. SGAI reports the manifest pod asset; SSAI reports the current ad asset and includes deliveryMode: "ssai" (an unknown duration is 0). Roku event timestamp values are epoch milliseconds with millisecond precision.

  • adbreakskipped is a terminal pre-presentation refusal with break, reason, format when known and occurrence correlation. reasonDetail adds the stitcher's specific cause when it differs from the public reason (for example pod-unavailable for not-ready). A pod-exceeds-break skip also carries podEvidence (breakSeconds, podSeconds, declaredPodSeconds, overrunSeconds); a pod-unavailable skip carries preparationEvidence (ledgerState, discoveredAgoSeconds, preparingAgoSeconds, preparations, resets, workerBusy). It is not an impression, viewer skip, or synthetic adbreakbegin/adbreakend pair. Content-first tune-in skips late/unready opportunities instead of rewriting exposed content. A start off the source segment grid is not a skip reason: the splice moves to the nearest segment boundary, and every shift above 1 ms is reported once as the ROKU-BREAK-START-SHIFTED diagnostic with reason (earlier/later), breakId, occurrence, signed shiftSeconds, requestedStart and spliceStart. adbreakbegin and the countdown follow the actual splice start. At the return to content, a shift above 1 ms is reported once as ROKU-RESUME-SHIFTED with reason (delayed when content resumes later, advanced when content is skipped to reach the nearest segment boundary), signed shiftSeconds and nearestBoundary. A pod refill that fails on the network (for example segment-timeout) is retried up to three times; each retry is reported as ROKU-PREPARATION-RETRY with reason, attempt, breakId and occurrence, and only a final failure ends the break. When publication paused for a pod that was still preparing, ROKU-BREAK-HELD reports reason (pod-ready or skipped), heldSeconds, breakId and occurrence.
  • adbreakstatus and getAdBreakStatus expose ledger/countdown state. Native Video.positionInfo UTC (epoch: 1) must match published source-PDT spans and coherent generation/clip samples, or use an externally verified, generation-scoped anchor. Progress follows playback, not pause/stall wall time.
  • playbackreloadrequired fences old tracking after a deliberate viewer seek. Its verified bookmark, when available, carries generation, position and sourcePdt. getSessionInfo/getAdBreakStatus also expose reloadRequired. The initial zero-to-live-edge transition is guarded against false reloads. This event is not a prerequisite for caller-intent startup reload: the app can stop/detach the same Video and pass the requested old-relative target directly, without first issuing an old Video.seek.
  • reloadAfterSeek with optional resumeStrategy: "startup" reports reloading → ready → resumed through correlated operationresult events, or terminates with error/cancelled. After last-coherent-native-clock validation and fresh GAM warmup, ready.resume carries strategy: "startup", sourcePdt, verified: true, generation, contentPlayStart, contentPlayStartTimebase: "roku-hls-pdt-2004", windowOffset, requiresNativeClock: true and timelineRevision. The app sets ContentNode.playStart to the supplied Double unchanged and Video.seekMode = "accurate" before attaching the new URL on the same Video and playing. contentPlayStart is the target's published PDT minus 1072915200, not the separate relative windowOffset. No Video.seek or resume-ready is needed. resumed requires actual coherent new-generation native UTC/progression within the unchanged one-second source-bookmark tolerance before tracking resumes; ready alone does not prove landing.
  • The backward-compatible default resumeStrategy: "seek" still reports reloading → ready → resume-ready → resumed. Only resume-ready supplies its validated resume.requestedPlayerPosition; the caller applies video.seek and awaits actual landing/bookmark confirmation. Short native seek-command repeatability is not certified. Neither strategy is an ordinary ad-boundary source change; named errors never invent a clock or clamp a failed DVR target to live.
  • Latest-wins channel changes wait behind committed/active playback; future preparation uses the latest applicable parameters. Do not infer a new playback generation or a source switch from adchannelchange alone.
  • In manifest-steered SSAI (Google DAI live), IMA's callbacks produce adbreakbegin, adbegin, adfirstquartile, admidpoint, adthirdquartile, adend and adbreakend with deliveryMode: "ssai", synthetic ssai-break-N / ssai-break-N-ad-M ids and IMA's adId, creativeId, podPosition and totalAds when known. IMA errors after the stream loaded are aderror plus DA-SSAI-IMA-ERROR. A viewer exit from a RAF interactive ad is adinteractiveexit; stop playback then.
  • adchannelchange carries previousDeliveryMode, deliveryMode, and eventId. Event-boundary changes use reason event-boundary. A channel switch that changes either delivery mode, or the DAI stream identity, is followed by playbackreloadrequired with reason: "delivery-mode-changed" or "ssai-stream-changed" and deliveryMode; monetization stops until the app starts a new session. Delivery decisions are diagnosed with DA-DELIVERY-MODE-RESOLVED, -UNKNOWN, -OVERRIDDEN, -CHANGE-IGNORED, DA-SSAI-UNAVAILABLE and DA-SSAI-SESSION-FAILED.
  • Missing IMA end metadata or an abandoned occurrence does not authorize a fabricated adend, quartile, beacon or adbreakend. Recovery fences tracking and reports aderror/abandonment diagnostics; verified return to source content or explicit detachment can release the blocker without claiming completion. Worker retirement/retry is bounded and failure is explicit.

Rendition-policy refusals retain the existing shared skip categories. Frame-rate, AAC sample-rate/channel mismatches and qualities outside the published envelope map to unsupported; unverified FPS/sample-rate/channel/quality metadata maps to not-ready. The precise native reason (for example frame-rate-mismatch, audio-sample-rate-mismatch or frame-rate-unverified) remains in the diagnostic stream. Neither outcome emits an ad lifecycle for media that was not published. These are native media-policy reasons, not new shared diagnostic codes.

For gam-metadata-unproven, ROKU-PREPARATION-FAILED can include a bounded, redacted mediaEvidence summary: segmentCount, totalBytes, containers, videoMax, audioMax, metadataPidCountMax, metadataAvailableSegments, metadataReasons, rawScannedSegments, rawId3HeaderSegments, rawGoogleMarkerSegments, rawId3UnsupportedVersionSegments, rawId3TagFlagsSegments, rawId3FrameFlagsSegments and truncated. These are counts/layout/reason hints, not URLs, IDs, raw media or tracking proof. A raw marker match does not establish valid metadata or authorize a beacon. Inspect truncated before treating zero counts as exhaustive evidence.

A pod refused for unproven metadata (for example after an experimental DVR reload) ends in adbreakskipped.reason: "preparation-failed" with the diagnostic above; it is never counted as an ad lifecycle or a successful refill.

Three native canonical GAM tracking comparisons (multi-ad, unknown total and durations) match their goldens. Unknown-position remains a different model: native code infers an internal index without fabricating finish/adend. This partial fixture coverage is not full core/event parity or real-beacon evidence. The shared emitted-DA-* guard now scans exactly the shipped BrightScript, excluding proof/tests, and rejects undeclared codes. ROKU-* diagnostics are native-only, outside the shared taxonomy.

getCapabilities describes the implementation, not a monetization certification. See Roku for the integration guide and limitations, and Roku session/reload lifecycle for the lifecycle details.

Web

TypeScript types

// Base — all events extend this
interface OptiViewAdsEvent {
  type: string;
  timestamp: number;
}

// Break events
sdk.addEventListener('adbreakbegin', (e: AdBreakBeginEvent) => {
  // e.break.id, e.break.duration, e.break.start
});

// Ad events — one pair per ad, including each creative of a multi-ad GAM pod
sdk.addEventListener('adbegin', (e: AdBeginEvent) => {
  // e.asset.id, e.asset.type, e.adIndex, e.totalAds, e.format ('single' | 'double' | …)
  // e.adId / e.creativeId — IMA's ids, set only for the ads of a GAM pod
  console.log(`Ad ${e.adIndex + 1} of ${e.totalAds}`);
});

// Quartiles carry adIndex/totalAds when the SDK knows which ad they belong to
// (the ads of a GAM pod), so repeated cycles in one pod stay attributable.
sdk.addEventListener('admidpoint', (e: AdMidpointEvent) => {
  trackMidpoint(e.asset.id, e.adIndex, e.totalAds);
});

// Error events — covers both ad and content playback (check e.source)
sdk.addEventListener('aderror', (e: AdErrorEvent) => {
  console.error(`[${e.source}]`, e.error.message);
  // For ad errors the SDK automatically recovers — content will resume
});

// Buffering / playback state — fires for both content and ad (check e.source)
sdk.addEventListener('waiting', (e: WaitingEvent) => {
  if (e.source === 'content') showSpinner();
});
sdk.addEventListener('playing', (e: PlayingEvent) => {
  if (e.source === 'content') hideSpinner();
});

// Ad progress — track ad position to drive a custom progress bar
sdk.addEventListener('adtimeupdate', (e: AdTimeupdateEvent) => {
  const pct = (e.currentTime / e.duration) * 100;
  progressBar.style.width = `${pct}%`;
});

The slate and the ad events

When the break manifest carries a slate it fills the part of a break no ad covers without emitting ad events: adbegin/adend still bracket real ads only, so ad counts and analytics are unaffected, and adbreakend follows the slate's end, which is the break's scheduled end. While the slate plays, adbreakstatus.breakRemainingSec counts down to that same end and ticking is true while the slate is on screen. A slate that cannot play emits an aderror carrying the slate asset. Its start and end are diagnostics (DA-SLATE-STARTED, DA-SLATE-ENDED).

Retired opportunities: adbreakskipped

This event means a scheduled opportunity reached a terminal outcome before the break began. It is not the viewer's skip action on an active ad, and must not be counted as an impression. The SDK emits it once for the retired occurrence, not once per manifest poll or preparation retry. A legitimate later playback occurrence, such as a re-armed DVR replay, is separate; the same break ID is not suppressed forever.

The payload contains type: 'adbreakskipped', the full break: Break, reason: AdBreakSkipReason, and optional format: BreakFormat. Reasons are late, not-ready, preparation-failed, unsupported, overlap, start-delay, removed, insufficient-remaining, and resource-limit. Low-level failure details remain in diagnostics. An aderror may still accompany a failure; it does not replace the terminal skip notification.

A retired opportunity must not manufacture adbreakbegin, adbegin, quartiles or impressions. Content remains available and later ready opportunities remain eligible. Do not synthesize an adbreakend to balance a break that never began.

sdk.addEventListener('adbreakskipped', (event: AdBreakSkippedEvent) => {
  console.log('Opportunity retired', event.break.id, event.reason, event.format);
});

The demo event log displays the break ID, reason and format when present without switching its UI into ad playback.

Unsubscribing

const handler = (e) => console.log(e);
sdk.addEventListener('adbreakbegin', handler);
// Later:
sdk.removeEventListener('adbreakbegin', handler);

Building a custom player UI

Replace the browser's native controls with your own UI so you can:

  • Hide controls during ad breaks and show a countdown toast instead.
  • Route play/pause through the SDK so break policies (content-lock, snapback) are honoured.

Key rules

  • Use sdk.play() / sdk.pause() instead of video.play() / video.pause() — the SDK will no-op these during content-locking breaks, preventing the user from accidentally resuming content mid-break.
  • Use sdk.seek(time) instead of setting video.currentTime directly — honours snapback enforcement.
  • VOD snapback uses the existing adbreakbegin → adbegin → adend → adbreakend lifecycle; no new public event is added. Ad elapsed time starts at zero even when the viewer seeks into a break. After a forward seek crossing the break start (regardless of ad duration), Single and L-Shape Ad return to the requested content position after adbreakend; Double Box, L-Shape Content and Overlay play on without a seek. Fullscreen fallbacks at break start count as Single. Backward seeks and seeks entirely after a scheduled start do not force that break, regardless of its declared ad duration. A seeked landing within an inclusive 0.5 seconds of the planned target belongs to the same viewer seek. Diagnostics explain correction or abandonment separately from lifecycle events. Direct player seeks are also corrected once without recursively re-seeking when the correction emits another seeked event.
  • Drive your countdown from adbreakstatus — the SDK emits this event whenever the break state or countdown changes. Use sdk.getAdBreakStatus() at any time for the current status, or subscribe to adbreakstatus for live updates. The status object includes phase ('idle' | 'upcoming' | 'active' | 'complete'), secondsUntilBreak, breakRemainingSec, adsRemaining, adIndex, totalAds, and ticking. adsRemaining counts the currently playing ad while an ad plays (totalAds − adIndex) and the ads still to come after an adend (totalAds − adIndex − 1, so 0 after the last ad). breakRemainingSec follows the break's media time — for a GAM DAI pod that is the pod's single media timeline, so the countdown runs continuously across the pod's ads.
  • breakWarnings config controls pre-break warnings. Set breakWarnings: { seconds: [10, 5] } to receive adbreakstatus with phase: 'upcoming' at 10s and 5s before the break.
  • Dismiss the countdown on adbreakend — adbreakend fires after all assets in the break have played (or been skipped/errored).

Minimal example

<!-- Remove the native controls attribute -->
<video id="video" muted playsinline></video>

<!-- Custom controls bar (inside the player wrapper) -->
<div id="playerControls" class="player-controls">
  <button id="btnPlay">▶</button>
  <button id="btnMute">🔇</button>
  <button id="btnFullscreen">⤢</button>
</div>

<!-- Break countdown toast (positioned over the player) -->
<div id="breakToast" class="break-toast hidden">
  <span class="toast-badge">AD</span>
  <span id="toastText">Ad break</span>
</div>
sdk.addEventListener('adbreakbegin', (e: AdBreakBeginEvent) => {
  // Hide player controls during the break
  document.getElementById('playerControls')!.classList.remove('visible');
});

sdk.addEventListener('adbreakstatus', (e: AdBreakStatusEvent) => {
  const { status } = e;
  const toast = document.getElementById('breakToast')!;
  const text = document.getElementById('toastText')!;

  if (status.phase === 'upcoming') {
    toast.classList.add('visible');
    text.textContent = `Ad break in ${status.secondsUntilBreak}s`;
    return;
  }

  if (status.phase === 'active') {
    toast.classList.add('visible');
    if (status.ticking && status.breakRemainingSec != null) {
      text.textContent = `Ad break · ${status.breakRemainingSec}s remaining`;
    } else {
      text.textContent = 'Ad break';
    }
    return;
  }

  if (status.phase === 'idle' || status.phase === 'complete') {
    toast.classList.remove('visible');
  }
});

sdk.addEventListener('adbreakend', () => {
  // Dismiss toast and restore controls
  document.getElementById('breakToast')!.classList.remove('visible');
  document.getElementById('playerControls')!.classList.add('visible');
});

// Route play/pause through the SDK
document.getElementById('btnPlay')!.addEventListener('click', () => {
  if (video.paused) sdk.play();
  else sdk.pause();
});

Android (Kotlin)

Subscribe with addEventListener(event: OptiViewAdsEventType, handler: (OptiViewAdsEvent) -> Unit) and unsubscribe with removeEventListener(event, handler). Events are modelled as a sealed class hierarchy — when (event) narrows to the concrete subtype. Note the property is break_ (Kotlin reserves break), and ad-level events carry assetId: String rather than a rich asset object.

import com.dolby.optiview.ads.sdk.*

// Break boundaries
sdk.addEventListener(OptiViewAdsEventType.ADBREAKBEGIN) { event ->
    val e = event as AdBreakBeginEvent
    Log.d("Ads", "Break ${e.break_.id} (${e.break_.duration}s)")
}

// Individual ads
sdk.addEventListener(OptiViewAdsEventType.ADBEGIN) { event ->
    val e = event as AdBeginEvent
    Log.d("Ads", "Ad ${e.adIndex + 1}/${e.totalAds} — asset ${e.assetId} [${e.format?.value}]")
}

// Errors — covers both ad and content (check source); SDK auto-recovers for ads
sdk.addEventListener(OptiViewAdsEventType.ADERROR) { event ->
    val e = event as AdErrorEvent
    Log.e("Ads", "[${e.source.value}] ${e.error.message}")
}

// Buffering / playback state — fires for both content and ad (check source)
sdk.addEventListener(OptiViewAdsEventType.WAITING) { event ->
    if ((event as WaitingEvent).source == PlaybackSource.CONTENT) showSpinner()
}

// Ad progress — drive a custom progress bar
sdk.addEventListener(OptiViewAdsEventType.ADTIMEUPDATE) { event ->
    val e = event as AdTimeupdateEvent
    progressBar.progress = ((e.currentTime / e.duration) * 100).toInt()
}
// Unsubscribing
val handler: OptiViewAdsEventListener = { event -> Log.d("Ads", "$event") }
sdk.addEventListener(OptiViewAdsEventType.ADBREAKBEGIN, handler)
// Later:
sdk.removeEventListener(OptiViewAdsEventType.ADBREAKBEGIN, handler)

iOS / tvOS (Swift)

addEventListener(_:_:) returns a Subscription token; pass it to removeEventListener(_:_:) to unsubscribe. Events are a Swift enum with associated values — switch to read the payload, or use the convenience accessors event.type / event.timestamp / event.source / event.breakId / event.assetId / event.format.

import OptiViewAdsRuntime

// Break boundaries
sdk.addEventListener(.adbreakbegin) { event in
    if case let .adBreakBegin(brk, _, tuneIn, format) = event {
        // `tuneIn` is non-nil when the viewer joined mid-break; `format` is the ad format.
        print("Break \(brk.id) [\(format?.rawValue ?? "?")] (\(brk.duration ?? 0)s)", tuneIn.map { "tune-in, \($0.remainingSec)s left" } ?? "")
    }
}

// Individual ads
sdk.addEventListener(.adbegin) { event in
    if case let .adBegin(_, assetId, adIndex, totalAds, _, format, _, _, _, asset) = event {
        print("Ad \(adIndex + 1)/\(totalAds) — asset \(asset?.id ?? assetId) [\(format?.rawValue ?? "?")]")
    }
    // Or, regardless of case: event.format
}

// Errors — covers both ad and content (check source); SDK auto-recovers for ads
sdk.addEventListener(.aderror) { event in
    if case let .adError(source, _, _, error, _, _) = event {
        print("[\(source.rawValue)] \(error.localizedDescription)")
    }
}

// Buffering / playback state — fires for both content and ad
sdk.addEventListener(.waiting) { event in
    if event.source == .content { showSpinner() }
}

// Ad progress — drive a custom progress bar
sdk.addEventListener(.adtimeupdate) { event in
    if case let .adTimeUpdate(_, _, currentTime, duration, _, _) = event {
        progressView.progress = Float(currentTime / duration)
    }
}
// Unsubscribing — keep the returned token
let token = sdk.addEventListener(.adbreakbegin) { event in print(event.type.rawValue) }
// Later:
sdk.removeEventListener(.adbreakbegin, token)

Diagnostics

VOD snapback corrections

DA-SNAPBACK-APPLIED identifies an eligible unplayed VOD break selected for seek correction. Its resumePosition is set only for seek-over of a content-pausing format (Single or L-Shape Ad, including fullscreen fallbacks at break start). Content-continuing formats omit it and play on without a return seek. DA-SNAPBACK-ABANDONED reports a corrective seek that failed after its one retry. DA-SNAPBACK-NOT-APPLIED explains a seek excluded by eligibility or platform policy; reason unsupported-format marks a Double Box, L-Shape Content or Overlay break, which snapback does not apply to by default. These diagnostics do not replace break lifecycle events or prove that the full ad played; correlate them with the break lifecycle and ad media-clock samples. See session seeking for seek-over versus seek-into resume behavior and the TV-web gate.

Validate the initial live offset

All platforms emit DA-LIVE-START-PUSHBACK when requesting the startup adjustment. Its context includes targetDurationSec, targetDurationSource (adapter or config), initialOffsetSec, initialOffsetTargetDurations, requestedOffsetSec, requestedOffsetTargetDurations, rewindSec, rewindTargetDurations, target, targetOffsetSec, targetOffsetTargetDurations and windowClamped. The message also includes TD and the offsets for plain-text logs.

For example, TD=10s and initial offset=30s (3×TD) requests 50s (5×TD), rewinding 20s (2×TD). An initial 40s offset instead rewinds 10s. A 50s or larger initial offset is left unchanged, reported as DA-LIVE-START-PUSHBACK-SKIPPED with reason already-behind.

DA-LIVE-START-PUSHBACK-LANDED reports landed, errorSec relative to the requested target, liveEdgeAtLanding, landedOffsetSec and landedOffsetTargetDurations from the seeked event. A missing seeked event reports landed: null and reason: timeout; it is not proof of a successful seek. The observed edge may move while the seek settles, so compare target error as well as live distance. A no-target-duration or no-range skip means metadata was unavailable, not that the viewer was already far enough back. These diagnostics are available through onDiagnostic() and exportDiagnostics(); enable debug for console output.

The SDK emits a structured diagnostic stream alongside the typed events. Each diagnostic is machine-readable — a stable code, a category, a severity level, and a JSON-serialisable context — so it can be reasoned over by tooling (including the AI troubleshooting assistant).

All three SDKs share the same diagnostic codes, categories, and levels — the codes table further down applies to every platform — and the same redacted exportDiagnostics() report shape. Use the Web / Android / iOS switcher at the top of the sidebar for platform-specific code.

Web

Subscribe to diagnostics

sdk.onDiagnostic((d) => {
  console.log(`[${d.level}] ${d.code} — ${d.message}`, d.context);
});

// later
sdk.offDiagnostic(handler);

A DiagnosticEvent has this shape:

interface DiagnosticEvent {
  ts: number; // epoch ms
  level: 'debug' | 'info' | 'warn' | 'error';
  code: string; // stable, e.g. 'DA-MANIFEST-FETCH-FAILED'
  category:
    | 'manifest'
    | 'session'
    | 'break'
    | 'preload'
    | 'gam'
    | 'playback'
    | 'chaining'
    | 'event'
    | 'lifecycle';
  message: string;
  context?: Record<string, unknown>; // never contains secrets
}

Export a shareable report

exportDiagnostics() returns a self-contained, redacted report — the recent diagnostic + event timeline plus a redacted config summary, the SDK version, and the user agent. It contains no secrets: asset parameter values are stripped (only hasAssetParameters is reported).

const report = sdk.exportDiagnostics();
navigator.clipboard.writeText(JSON.stringify(report, null, 2));

This is the single artifact to paste into a support ticket or feed to the AI troubleshooting assistant.

Configuration

The diagnostic ring buffer that backs exportDiagnostics() is bounded. Tune it via the diagnostics config:

new OptiViewAds({
  // ...
  diagnostics: { bufferSize: 200 }, // default 200; older records are evicted first
});

Diagnostic codes

Codes are part of the public contract and never renamed. The full table (cause + suggested fix per code) is generated from the source taxonomy and published in @dolby-optiview/ads-sdk/ai/reference/error-codes.md.

Code Category Level Meaning
DA-SESSION-STARTED session info Session started; manifest polling began.
DA-SESSION-ENDED session info Session ended; polling and scheduling stopped.
DA-ASSET-PARAMETERS-UPDATED session info Manifest session-level asset parameters changed; merged parameters were pushed to the active GAM stream.
DA-SESSION-STARTING session info A startSession() step was entered (begin, gam-init, manifest-fetch, scheduling); the last one recorded names a hung step.
DA-MANIFEST-URL-DISCOVERED session info startSession() had no manifestUrl and used the ads manifest URL the player adapter discovered (THEOplayer with a THEOlive source). context: manifestUrl, source.
DA-MANIFEST-URL-UNAVAILABLE session error startSession() had no manifestUrl and could not get one from the player adapter; the call rejects. context: reason (disabled, unsupported-adapter, no-ads, timeout).
DA-MANIFEST-FETCH-FAILED manifest error Initial manifest fetch failed; session could not start.
DA-MANIFEST-POLL-FAILED manifest warn A manifest poll failed; last good manifest retained, retrying.
DA-MANIFEST-CHANNEL-CHANGED manifest info A polled manifest describes a different ads channel (channelId, GAM identity or timebase changed); the SDK re-aligned its ad setup and resolved delivery mode again while the session and content continued. context: previousChannelId, channelId, reason, manifestUrl. A matching adchannelchange event with delivery-mode fields is emitted.
DA-MANIFEST-EVENT-INVALID manifest warn A channel event was ignored because its time window or configuration is invalid, or because events are unsupported for the manifest timebase. context includes eventId and index when available.
DA-ASSET-MEDIA-TYPE-MISMATCH manifest warn An asset's mimeType names another kind than its mediaType (for example mediaType: "video" with mimeType: "image/png"); the SDK follows the mimeType. Reported once per asset and value. context: assetId, mimeType, mediaType, kind (the kind it plays as).
DA-ASSET-MIME-TYPE-UNKNOWN manifest warn An asset declares a mimeType the SDK does not recognise for its type (a vast asset expects application/xml or text/xml), so mediaType and the URL or file decide, as without one. Reported once per asset and value. context: assetId, mimeType, mediaType, kind.
DA-IMAGE-MIME-UNSUPPORTED manifest warn An asset declares an image mimeType the SDK does not handle (anything but GIF, WebP, PNG, JPEG and SVG; for example image/avif). The asset still renders as an image and the file decides its format. Not reported when the asset is already a DA-ASSET-MEDIA-TYPE-MISMATCH. Reported once per asset and value. context: assetId, mimeType, mediaType, kind.
DA-SLATE-INVALID manifest warn The manifest's slate was ignored because it is unusable (context.reason: not-object, invalid-min-duration, no-assets or invalid-asset); its breaks play without a slate and are otherwise unaffected. Reported once per distinct fault.
DA-DELIVERY-MODE-CHANGE-IGNORED session warn An ordinary poll resolves a different delivery mode; the mode pinned for the session stays in force. Ads-channel switches resolve the mode again.
DA-MANIFEST-INTERCEPT-FAILED manifest warn The interceptManifestResponse hook threw; the un-modified parsed manifest was used instead.
DA-MANIFEST-REQUEST-INTERCEPT-FAILED manifest warn The interceptManifestRequest hook threw; the normal network fetch of the original URL was used instead.
DA-SLATE-PRELOADED preload info The manifest slate was fetched ahead of its first use (first appearance, or its URL changed). context: slateAssetId, mediaType, path.
DA-SLATE-STARTED break info The slate began because no ad covered the rest of the break. context: breakId, slateAssetId, reason (ads-ended or no-ad), durationSec (the real time left to the break's scheduled end), adsPlayedSec, effectiveDurationSec, minDurationSec. No adbegin/adend is emitted for it.
DA-SLATE-NOT-STARTED break info A break with a slate left part of its time uncovered but no slate started: less than minDuration remained (below-min-duration), or the stitched stream fills the break (not-rendered). context: breakId, reason, remainingSec, minDurationSec.
DA-SLATE-ENDED break info The slate stopped. context: breakId, slateAssetId, plannedSec (real time left when it started), filledSec (seconds on screen; start-up, stalls and loops shorten it), loops, interruptedSec, breakOverrunSec (slate end minus the scheduled end, about 0 with break-end), reason (break-end, skipped, removed).
DA-SLATE-FAILED playback error The slate could not load or play (context.reason: load or stalled); the break ends as without a slate and an aderror carries the slate asset.
DA-PDT-MISSING playback warn No EXT-X-PROGRAM-DATE-TIME once content is playing (or after the pdtGraceSeconds backstop); wallclock breaks fall back to the clock.
DA-ANVATO-CUE-PENDING break info ptsSource: 'anvatoCue': no Anvato in-stream cue observed yet for a PTS break; the break stays pending.
DA-ANVATO-CUE-MATCHED break info ptsSource: 'anvatoCue': a PTS break was matched to an Anvato cue and scheduled at the cue's media time.
DA-ANVATO-CUE-OBSERVED break info ptsSource: 'anvatoCue': an Anvato break-signaling (type=cue) frame was observed in the stream (context: pts, mediaTime, recorded, raw payload).
DA-ANVATO-CUE-SEGMENT-ANCHORED break warn ptsSource: 'anvatoCue': an Anvato DASH emsg cue arrived without the adapter's ptsOffset, so its break is scheduled at the carrying segment's start (up to one segment early). Once per session; context: pts, mediaTime.
DA-ANVATO-CUE-OFFSET-REJECTED break warn ptsSource: 'anvatoCue': the adapter's ptsOffset placed an Anvato cue more than 0.1s before or 15s after its startTime; the startTime is used instead. Once per cue pts; context: pts, startTime, ptsOffset, mappedTime.
DA-ANVATO-CUE-END-MATCHED break info ptsSource: 'anvatoCue': the active break's Anvato type=cue_end was observed and its stream-clock length is within 2s of the break duration. Once per break; context: breakId, mediaTime, lengthSec, durationSec.
DA-ANVATO-CUE-END-REJECTED break warn ptsSource: 'anvatoCue': a type=cue_end for the active break signals a length more than 2s from the break duration; it is ignored. Once per break; context: breakId, mediaTime, lengthSec, durationSec.
DA-RESUME-CUE-END playback info iOS/tvOS, web and Android, ptsSource: 'anvatoCue': the matched cue_end replaced the computed live resume target (applied: false when the resume policy does not resume at the break end). context: breakId, computedTarget, cueEndTarget, deltaSec, stage (Android: hand-back), corrected.
DA-RESUME-CUE-END-LATE playback info iOS/tvOS and Android, ptsSource: 'anvatoCue': the cue_end arrived only after the hand-back. Content is moved forward to it once when it is more than 1s ahead and buffered, never backward. context: breakId, cueEndTarget, currentTime, deltaSec, corrected.
DA-RESUME-PREPARED playback info Android, live break that resumes at its end: paused content was parked exactly on the resume point before the hand-back, so the hand-back only plays (DA-RESUME-SEEK prepared: true). context: breakId, target, source (cue_end or cue+duration), leadMs, refresh.
DA-RESUME-PTS-MAP playback info iOS/tvOS and web, ptsSource: 'anvatoCue': the live resume point was mapped onto currentTime through the stream's own clock (beacons since the run-up's last seek). context: breakId, target, landingStreamSec, landingSource, offsetSec, beacons, generation, computedTarget, deltaSec.
DA-RESUME-PTS-REMAP playback warn iOS/tvOS and web, ptsSource: 'anvatoCue': a beacon showed currentTime re-anchored by more than 0.2s against the stream clock; the resume point is mapped again. context: breakId, fromOffsetSec, toOffsetSec, deltaSec, currentTime, stage.
DA-RESUME-PTS-CORRECTED playback info iOS/tvOS and web, ptsSource: 'anvatoCue': once per break at the hand-back, whether the stream clock placed the resume point and how far it moved it from the currentTime target. context: breakId, applied, computedTarget, streamClockTarget, correctionSec, currentTimeShiftSec, landingSource, remaps, reason.
DA-RESUME-PTS-LANDED playback info iOS/tvOS and web, ptsSource: 'anvatoCue': where a stream-clock resume landed on the stream clock; errorSec < 0 means slate was shown. context: breakId, landingStreamSec, landedStreamSec, errorSec, resumedAt, offsetSec, beacons, reason.
DA-RESUME-PDT-MAP playback info All platforms, timebase: 'wallclock': the live resume point (manifest start + duration) was mapped onto currentTime through the Program Date Time the content player reports now; reported when the run-up first reads it and whenever it moves by 0.1s or more (remapped: true). context: breakId, target, landingPdt, pdtOffsetSec, currentTime, remapped, computedTarget, deltaSec.
DA-RESUME-PDT-CORRECTED playback info All platforms, timebase: 'wallclock': once per break at the hand-back of a break anchored on the Program Date Time — whether the stream clock placed the resume (applied), correctionSec from the anchor target and currentTimeShiftSec (how far currentTime moved against the stream during the break); reason when no PDT sample was available. context: breakId, applied, computedTarget, pdtTarget, correctionSec, currentTimeShiftSec, reason.
DA-RESUME-PDT-LANDED playback info All platforms, timebase: 'wallclock': where a Program-Date-Time resume landed on the stream clock, from the first position sample after the hand-back; errorSec < 0 means the stream's own break is shown, > 0 means post-break content was skipped. context: breakId, landingPdt, landedPdt, landedAt, errorSec, sinceHandBackSec, reason.
DA-PRELOAD-FAILED preload warn Ad preload failed; asset will load on demand at break start.
DA-PRELOAD-MODE-RESOLVED preload info The preload mode in force for the session (context.configured vs context.resolved), once at startup.
DA-PRELOAD-PATH preload info The preload path actually taken per break (context.path) and the creative container (context.creative: stream vs progressive). On iOS/tvOS the break preparation warms a video asset up on an idle ad player itself (path: first-frame): played muted and hidden to its first frame, then paused on it, so the cut shows the ad at the break's start; firstFrame: false means no frame rendered within the warm-up wait and the cut starts a loaded item cold.
DA-BREAK-EARLY-RETURN break info The active break was removed from a polled manifest (early return); the break ends immediately and content resumes at break start plus the seconds already played.
DA-BREAK-SUPPRESSED-OVERLAP break warn A break was suppressed because an ad was already playing.
DA-BREAK-NO-PLAYABLE-ASSET break warn A break with nothing to play never begins: no adbreakbegin/adbreakend, content keeps playing, and an aderror (source ad) + this diagnostic report why (context.reason: no-variant, no-qualifying-variant — device targeting/format playability matched nothing —, no-assets, or lshape-content-skipped; plus context.declaredAssetCount).
DA-BREAK-ABANDONED lifecycle warn The session was torn down while a break was still in flight (context.cause, context.unbalancedAdBegin).
DA-RENDERER-UNAVAILABLE lifecycle error Android: the renderer lacked something it needed (context.missing), so the break began and never ends.
DA-BREAK-FORMAT-DEGRADED break warn A split format needed to reframe the content surface, but the host could not supply the required content or sibling container; rendering may be degraded until attachment succeeds.
DA-BREAK-TRANSITION break info Measured duration of a playback transition into a break, between ads/breaks, or back to content.
DA-BREAK-CUT-LATE break warn All platforms, timebase: 'wallclock': content was cut more than 0.5s after the break's manifest start on the stream's Program Date Time (typically the ad's first frame was not ready at the cut and content kept playing under the cross-fade), so the viewer saw the stream's own break until then. The replaced window is unaffected: the resume anchor is the content time of the manifest start. context: breakId, lateSec, start, cutPdt, cutAt, anchor, waitedForAdMs (iOS/Android).
DA-PREROLL-CONTENT-HELD break info Content was held at session start until a pending pre-roll began, so no content shows before the ad.
DA-PREROLL-CONTENT-WAIT-TIMEOUT break info A pending pre-roll began after content readiness was not reported within the wait timeout.
DA-PREROLL-CANCELLED-CONTENT-ERROR break warn A pending pre-roll was cancelled because the content failed to load before it could begin.
DA-CHAIN-RESOLVER-ERROR chaining warn The chained-successor resolver threw; chaining skipped.
DA-BREAK-CHAIN chaining info Summary of one chain of back-to-back breaks, emitted once when content plays again (or the chain is flushed). See Chain summary.
DA-GAM-NO-ASSET-KEY gam warn GAM configured but no customAssetKey; GAM breaks skipped.
DA-GAM-SESSION-FAILED gam error GAM/IMA session failed to initialize; GAM breaks will not serve.
DA-GAM-SESSION-PRELOADED gam info A GAM/IMA session was preloaded for the next event; context includes the event boundary and GAM pod identity.
DA-CONTENT-PLAYBACK-ERROR playback error The content player reported a playback error.
DA-EXTERNAL-PLAYBACK-CHANGED playback info The content player's external (AirPlay) playback state changed; context carries the new state and the target.
DA-EXTERNAL-PLAYBACK-BLOCKED playback warn AirPlay was requested while an ad break is active or about to start; the content player stays on the device and the request is retried when the break ends.
DA-EXTERNAL-PLAYBACK-ALLOWED playback info An AirPlay request passed the ad-break guard; context.trigger says whether it was the request itself or the retry after a break.
DA-SSB-SWITCH-FAILED playback warn Switching the content player to the SSB stream for AirPlay failed (context.reason: no-restore-source, load-error, load-timeout, external-not-active or receiver-paused); the SDK restores the previous content.
DA-SSB-RESTORE-FAILED playback error The previous content source could not be reloaded after the SSB stream (AirPlay ended or the switch failed); the session stays in ssb delivery until the app reloads its content.
DA-AD-PLAYBACK-ERROR playback error The ad player reported a playback error during a break; context.adErrorCode names the cause (one of the codes below, or DA-AD-PLAYBACK-ERROR when unknown) and context.vendorCode the raw vendor code.
DA-AD-URI-MISSING playback error The ad asset had no usable media URI, VAST tag URL or render surface. Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-AD-MEDIA-LOAD-FAILED playback error The ad player could not fetch the ad media (network or HTTP failure). Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-AD-MEDIA-UNSUPPORTED playback error The ad player could not decode the ad media or does not support its format. Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-AD-START-TIMEOUT playback error The ad did not load, render a first frame or start within its start budget. Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-VAST-NO-FILL gam error The VAST ad server returned no ad (empty response, no ads after wrappers or no assets). Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-VAST-TIMEOUT gam error The VAST response or its media file did not load in time. Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-VAST-MALFORMED gam error The VAST response could not be parsed or uses an unsupported VAST version. Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-VAST-REQUEST-FAILED gam error The VAST ad request failed (network error, invalid tag URL, wrapper error or too many redirects). Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-VAST-CREATIVE-FAILED gam error The VAST creative could not be played (no compatible media file, playback error or trafficking error). Reported as context.adErrorCode and CMCD adec, not as a diagnostic of its own.
DA-AD-START-INTERRUPTED playback warn The ad element's play() was interrupted by a browser-initiated pause before the ad started; the SDK re-issued play() once (context.breakId, context.error).
DA-AD-STALLED playback warn Android: an ad began and then stopped advancing (context.stalledForMs, context.bufferedAheadMs).
DA-AD-FOREGROUND-RESUMED playback info iOS: an in-flight ad resumed after foregrounding (context.suspendedSec, context.resumePositionSec).
DA-AD-FOCUS-GRANTED playback info Android: the overlay ad acquired media focus for the break (context.breakId, context.cause, context.alreadyHeld).
DA-AD-FOCUS-DENIED playback warn Android: the platform refused the overlay ad's media-focus request (context.breakId, context.cause).
DA-AD-FOCUS-ABANDONED playback info Android: the overlay ad released media focus (context.breakId, context.cause).
DA-MANIFEST-SIGNATURE-INVALID manifest error The break-manifest response failed detached-JWS signature verification (missing/malformed X-Manifest-Signature, unsupported alg, unknown kid, unknown critical param, or signature mismatch); the manifest was rejected and no breaks were scheduled. context: url, reason.
DA-ANVATO-CUE-ENTERED break info ptsSource: 'anvatoCue' — a break was started by the cue reaching the playhead rather than by the scheduler's 250ms tick; context carries the breakId, the cue pts and the media time it fired at, so the two start paths are distinguishable in the field.
DA-BREAK-WINDOW-ESCAPED break warn An active wallclock break outlived its window on the stream clock (ad stall, bogus trigger position, or a re-fired completed break); the SDK ended it and returned to content. context.overrunSec says by how much.
DA-BREAK-EVENT-UNSUPPORTED break warn A break is triggered by a spec event this SDK version does not schedule on this platform (web schedules start, pause and end; Android and iOS do not schedule end yet); the break was ignored. context.event names the event.
DA-SHARED-ELEMENT-UNSUPPORTED break warn Configured shared-element insertion is unsupported on this platform (non-iPhone/iPod); fell back to overlay insertion.
DA-SHARED-ELEMENT-RESTORE-FAILED playback error Content did not resume after a shared-element break: the reload/seek/play restore failed twice; the viewer is left paused on the handed-back element.
DA-IMAGE-ANIMATED break debug An animated image (GIF or animated WebP) started animating on a companion, backdrop, image ad, pause image or slate. Native renderers only: browsers animate the image element themselves. context: surface ('companion', 'backdrop', 'image-ad', 'pause' or 'slate'), uri, frameCount (iOS/tvOS; null on Android), formatSource ('mimeType' when the asset declares image/gif or image/webp, 'file' when the file's content was used).
DA-IMAGE-ANIMATION-UNSUPPORTED break warn An image is animated, or declared as image/gif or image/webp, but this device cannot animate it, so its first frame is shown. context: surface, uri, reason ('api-below-28' on Android below API 28, also for a still file declared as GIF or WebP; 'canvas-too-large' on iOS/tvOS when the animation exceeds the decode budget).
DA-PIP-TRANSFER-FAILED break warn The picture-in-picture window could not be moved between the content and ad elements; the break continues but the viewer may not see the ad in the PiP window.
DA-PIP-AUTODETECT-UNAVAILABLE break warn No Activity could be resolved from the renderer's Context or the overlay's view tree, so picture-in-picture cannot be detected automatically; the host must call OptiViewAds.setPictureInPicture() from Activity.onPictureInPictureModeChanged or breaks will be laid out for a fullscreen surface. Android only.
DA-CONTENT-ELEMENT-SWAPPED break info The content player replaced its
DA-PIP-FORMAT-OVERRIDE break info The content player is in picture-in-picture, so the break's declared format was overruled and it plays as a single fullscreen ad.
DA-PIP-ADOPTION-STATE break info Native PiP reconciliation deferred or reused a layout/handoff decision. Context carries reason, active, adPlaying, applied, and asset/break IDs when available; this is not evidence that a format override occurred.
DA-PIP-HANDOFF break info The picture-in-picture handoff route chosen for the ad: 'layer-swap' (the presented AVPlayerLayer is re-pointed at the ad player) or 'borrow' (the ad plays through the content player). context: route, layers. iOS only.
DA-PIP-LAYER-SWAP break debug Read-back check after a PiP layer-swap: whether the presented layer still points at the ad player after the re-point. context: held, layers. iOS only.
DA-PIP-PRESENTED break debug Status trace of the player on the PiP-presented layer during a layer-swap: owner (ad/content/other) and time-control-status transitions, plus ad-item ends observed while presented. context: owner/status, or errored/reachedEnd/adStatus. iOS only.
DA-GAM-START-DEFERRED gam info The SGAI IMA stream request is deferred until the configured ad start delay has been played; context includes adStartDelaySec.
DA-GAM-CONFIG-RESOLVED gam info The GAM stream identity for this session was resolved from the manifest's vendorConfiguration.
DA-GAM-CONFIG-MISSING gam error The break manifest carries no usable "gam" vendorConfiguration entry; GAM assets are skipped.
DA-GAM-POD-IDENTITY-MISMATCH gam error A GAM pod asset's vendorParameters name a different network code or custom asset key than the stream session was created with; the asset is skipped because the pod request cannot serve.
DA-GAM-POD-MID-BREAK-END gam warn IMA reported the ad break ended before the pod's last ad while pod stream remains; per-ad reporting continues until the pod ends.
DA-GAM-DUPLICATE-METADATA gam info The stream carries the same ad marker more than once at the same time (for example in both the audio and video renditions of an fMP4 stream); the duplicate was not passed to IMA, so each ad event fires once. Reported once per stream session.
DA-VENDOR-CONFIG-UNKNOWN-TYPE manifest info One or more vendorConfiguration entries declare a type this SDK version does not recognise and were ignored.
DA-EXTERNAL-VENDOR-INVALID manifest warn External vendorConfiguration entries were ignored because provider was blank or assetParameters was not an object. context: count.
DA-EXTERNAL-VENDOR-DUPLICATE manifest warn External vendorConfiguration entries repeated a provider; the first valid entry was used. context: providers.
DA-CONTENT-RESUME-STALLED playback warn Content did not resume within the watchdog window after a break that paused it ended; the SDK re-issued play() once. iOS only for now.
DA-CONTENT-RECOVERY-MODE-RESOLVED playback info The resolved post-break content recovery mode for the session (recreate or none); context carries configured and resolved.
DA-CONTENT-PIPELINE-RECREATED playback info The content player's media pipeline was rebuilt at break end before content resumed (recovery mode recreate); context carries breakId, startTime and durationMs.
DA-CONTENT-PIPELINE-RECREATE-FAILED playback warn Rebuilding the content media pipeline at break end failed or timed out — or the adapter does not implement recreateMediaPipeline() (reason 'unsupported-adapter', e.g. a wrapper adapter that does not forward it); the SDK fell back to resuming in place with seek + play; context carries breakId, startTime, reason.
DA-AD-LOAD-RETRIED playback warn The ad player's load() had not settled within the retry window of the ad-start budget and the ad element showed no progress (readyState 0, nothing buffered), so a second load() was issued for the same URI; a slow-but-progressing load is not retried. Context carries breakId, assetId, uri, elapsedMs, remainingBudgetMs. A still-stalled retry ends as DA-AD-PLAYBACK-ERROR "Ad load timeout".
DA-AD-DURATION-PREPARED playback info The ad media for a break was prepared and its real playable duration is now known, BEFORE the first frame. context: breakId, assetId, index, total, preparedDurationSec (the loaded media's own duration — on a GAM pod, the stitched pod's length), declaredDurationSec (what the manifest said about this asset, when it said anything) and breakDurationSec (the slot the break declares). Emitted per asset, so a multi-asset break reports one per asset and the break total is their sum. The three together separate a short break caused by a short POD from one caused by a short request or a late join.
DA-DELIVERY-MODE-RESOLVED session info Delivery mode (sgai/ssai) resolved for the session at start and again on an ads-channel switch from the manifest's delivery rules (or the explicit client config), with the detected device profile.
DA-TARGETING-VALUE-UNKNOWN manifest warn A targeting value is not recognized and the targeted entry does not match.
DA-TARGETING-FIELD-UNKNOWN manifest warn A targeting field is not recognized and the targeted entry does not match.
DA-TARGETING-INVALID manifest warn A targeting constraint is malformed or incomplete and the targeted entry does not match.
DA-DELIVERY-MODE-UNKNOWN session warn The matching delivery rule carried an unrecognized mode value; sgai is used (forward compatibility).
DA-DELIVERY-MODE-OVERRIDDEN session info The manifest's delivery rules resolved a different mode, but the explicit client config takes precedence.
DA-SSAI-UNAVAILABLE session error The manifest selected ssai delivery but no vendor configuration can provide a stitched stream (no gam entry with an assetKey); at start the session fails, while on a channel switch the session stays in sgai.
DA-SSAI-SESSION-FAILED session error The SSAI session failed to start (IMA stream init, stream id, or stitched-stream load).
DA-SSAI-IMA-ERROR gam error IMA reported an error during the SSAI stream session.
DA-INSERTION-TYPE-RESOLVED session info Per-session ad insertion type resolved, and whether the integrator set it or left it unset (unset lets the manifest's resumeOffset drive the resume point).
DA-RESUME-OFFSET-CLAMPED break info The resume offset was shortened to the ad duration actually played, so the break could not skip further than the ads it delivered.
DA-INSERTION-TYPE-IGNORED-SSAI session warn adInsertionType is ignored in SSAI mode; the stitcher controls ad insertion server-side.
DA-VAST-UNSUPPORTED-FORMAT break warn A VAST asset appeared in an unsupported break format; VAST is only supported in single, double, and lshape_ad. The break was skipped.
DA-ASSET-MACRO-UNKNOWN break warn An asset parameter value contained a macro the SDK has no value for (an unknown or unavailable OptiView macro, or a registered customer macro that returned no value); the parameter was still sent, with the macro kept as its literal token. Raised once per parameter key and macro. context: key, macro, breakId, assetId.
DA-ASSET-PARAMETER-OMITTED break info An asset parameter value contained an empty macro ("", null, or a registered callback result of undefined), so the parameter or affected pair was not sent. Any value with a literal & is processed as a pair list for every request. Raised once per parameter key and macro. context: key, macro, pair (when a pair was dropped), breakId, assetId.
DA-VAST-SSAI-UNSUPPORTED session warn VAST assets are not supported in SSAI mode (VAST is SGAI-only); the asset was skipped.
DA-PAUSE-AD-SHOWN break info A pause ad (full-screen image or video) was shown while content is paused.
DA-PAUSE-AD-DISMISSED break info A pause ad was dismissed (content resumed, or the duration cap elapsed).
DA-PAUSE-AD-RESUME-ALLOWED break info The viewer may now resume content over the shown pause ad: the break's controls.skipOffset elapsed, or (no skipOffset) the ad was watched fully: a video creative ended, an image reached its duration cap or has none. context: breakId.
DA-PAUSE-AD-RESUME-BLOCKED break info Content tried to resume while a pause ad must still be watched (controls.skipOffset not reached, or no skipOffset and the video creative has not ended / the image duration cap has not elapsed); the SDK keeps content paused. context: breakId, elapsedSec, skipOffset.
DA-PAUSE-AD-DVR-EXPIRED break info The viewer paused for longer than the DVR window is deep, so the position they paused at aged out and playback resumed at the live edge instead. context: pinnedPosition, liveEdge.
DA-PAUSE-AD-NO-ASSET break warn A pause break had no usable image or video asset (no first asset, unsupported media type, or no resolvable VAST creative); the pause ad was skipped.
DA-PAUSE-AD-SSAI-UNSUPPORTED session warn Pause ads are SGAI-only and not supported in SSAI mode; the pause break was skipped.
DA-MANIFEST-POLLED manifest info A manifest poll refresh succeeded (cadence follows the manifest polling config).
DA-AD-SKIPPED playback info The viewer skipped the active ad break (controls.skipOffset honored).
DA-AD-SKIP-SUPPRESSED playback info A skip request was suppressed (no skipOffset declared, or requested before the offset).
DA-AD-CLICKED playback info The viewer clicked the ad on screen (adclick emitted).
DA-RESUME-UNADDRESSABLE playback warn A break played through the content player (picture-in-picture), so content came back on a reloaded source whose timeline has its own origin, and that source published neither a program-date-time nor a seekable range to re-address the resume point against. Content stays where the reload left it — near the live edge — rather than being seeked to a position that does not exist on the new timeline. Context carries breakId, target (the position on the pre-borrow timeline) and offset.
DA-RESUME-LANDED playback info Where the post-break resume-seek actually landed, measured on the seeked event rather than inferred: context carries breakId, target (the position requested), landed and errorSec (landed - target; negative means the player settled EARLIER than asked). errorSec only says whether the SEEK did what it was asked: when the live-window clamp moved the seek, policyTarget is the resume point before the clamp and policyErrorSec (landed - policyTarget) is how far the viewer really is from it. landed is null with a reason when no seeked event arrived, which is normal for a seek to the position the playhead already holds. Report-only: the SDK does not correct the position.
DA-RESUME-PREPOSITIONED playback info The break resumed without a seek: content was moved onto its resume position DURING the break, so the transition needed no jump. Context carries breakId, target, prepositionedTo, landed, shortfallSec and exact. exact=true means it reached the policy target. exact=false means the live window never published those frames, so content was moved as close as exists — the viewer lands short, but arrives already in place rather than via a visible seek at the cut.
DA-RESUME-CATCHUP playback info Content began playing behind the ad to reach its resume point. Context carries breakId, startPos, target, remainingAdSec, publishedEnd and clampedStart — clampedStart true means the stream had not published the ideal start position, so playback began late and the alignment loop must make up the difference (the zero-live-headroom case). Its ABSENCE on a live break that resumed short means catch-up never ran at all, which is a different fault from it running and falling short.
DA-RESUME-TARGET-CLAMPED playback warn The computed resume position sat outside the held live window and was clamped to the nearest end of it; context carries breakId, requested, clamped, shortfallSec and bound — 'end' when the target is ahead of the published edge, 'start' when it is behind the live window start (already evicted) — applied only when the gap is at most half the held window, otherwise DA-RESUME-START-CLAMP-SKIPPED is emitted instead. Distinct from DA-RESUME-OFFSET-CLAMPED, which shortens the OFFSET to the ad seconds actually played.
DA-RESUME-START-CLAMP-SKIPPED playback info The resume target sat behind the element's live seekable start by more than half the held window, which cannot be DVR eviction (the element's seekable range disagrees with the adapter timeline); the target was left unchanged and the engine resolved the seek itself. Context carries breakId, requested, seekableStart, behindSec, windowSec and maxBehindSec.
DA-RESUME-ALIGN-BLOCKED playback warn Resume alignment wanted to move content past the live edge and stood down, because no seek can reach media the stream has not published yet; content is left riding the edge and the break-end clamp places it. Context carries target, requested, safeEnd, shortfallSec and remainingSec. Emitted once per break. A persistent shortfall here means the resume target is further ahead than the feed's published edge — typically the player's view of the edge is stale, not that the seek is wrong.
DA-CONTINUE-PLAYOUT-BEGIN playback info continueContentDuringBreak engaged: content keeps PLAYING through the break, hidden and muted, so no resume seek is needed. Context carries breakId, anchor, breakDurationSec and edgeDistanceSec.
DA-CONTINUE-PLAYOUT-END playback info continueContentDuringBreak reached the cut. Context carries driftSec (content position minus where the break says it should be), maxDriftSec, the corrections applied, rateHonoured (false if the engine drove playbackRate itself) and driftUnrecoverable.
DA-CONTINUE-PLAYOUT-REFUSED playback info continueContentDuringBreak was not used this session, so breaks pause content and resume with a seek as before. Emitted once per session; context carries the reason (disabled, not-replacement, format, shared-element, picture-in-picture, single-decoder) and the break format. Its ABSENCE on an eligible session is the signal the mode engaged.
DA-CONTINUE-PLAYOUT-QUALITY-UNAVAILABLE playback warn Content continues through the replacement break without a video-quality constraint, so the content stream may retain its normal bitrate alongside the ad. Context carries breakId and reason (unsupported when the optional Web adapter method is absent, not-applied when the adapter returned false or could not apply the request).
DA-CONTINUE-PLAYOUT-DRIFT playback warn Content drifted further from the break timeline than the remaining break can remove within the playback-rate bounds, so part of it is carried into the cut. Context carries driftSec, remainingSec, the rate applied and seekIssued (always false: a corrective seek would be clipped).
DA-CONTINUE-PLAYOUT-ABANDONED playback warn Content could not be kept playing through the break, so it reverted to the pause-and-resume path mid-break. Context carries breakId, the reason and the driftSec at the moment it converted.
DA-AD-AV-DESYNC playback warn The ad player's audio sink was handed a buffer whose timestamp does not continue the audio it has already been fed, so the media clock had to be re-anchored mid-ad. Video is scheduled off that clock while the audio already queued in the output track keeps draining, so every re-anchor pushes the picture further from the sound actually being heard. Context carries breakId, assetId, expectedSec, actualSec, deltaSec (negative = audio running behind the picture) and positionSec. Seen on server-stitched pods whose per-ad audio and video durations do not match; a single event near the end of a pod is the accumulated total, not an isolated glitch.
DA-AD-PLAYOUT-SYNC playback info Per-break summary of ad playout health, emitted once at break end. Context carries podUri (the resolved ad media, so a stitched pod can be fetched and inspected), desyncEvents, maxDesyncSec, droppedFrames, audioUnderruns, audioFormats and videoFormats (the distinct decoder input formats seen during the break — more than one means the stitched stream changed sample rate or codec mid-pod) and frameOffsetMeanMs (mean video frame processing offset; large negative values mean frames were released late against the audio clock).
DA-BREAK-CONTENT-MASK break warn The host's content surface cannot follow view transforms (punch-through SurfaceView, e.g. react-native-video's default), so the two-box format masks the backdrop with a transparent hole over the content box instead of reframing the content view. context: format.
DA-BREAK-LSHAPE-ANCHOR-UNKNOWN break warn An lshape_ad or lshape_content variant declares an anchor this SDK version does not recognise (manifest spec 1.11.0 knows top_left, top_right, bottom_left and bottom_right), so the break still plays with the video box in the default top_left corner. Raised once per break begin on the selected variant. context: breakId, format, anchor (the raw manifest string).
DA-BREAK-VARIANT-FORMAT-UNKNOWN break warn A break variant declares a format this SDK version does not recognise, so it was passed over during variant selection rather than guessed at - an unknown format is never playable, because rendering it as a fullscreen single would be the most invasive possible misreading. Raised once per skipped variant: a break that still has a playable variant plays it and reports this too, so the skip is never silent, and a break left with nothing also reports DA-BREAK-NO-PLAYABLE-ASSET with reason no-qualifying-variant. An ABSENT format is treated identically to an unrecognised one. context: breakId, format (the raw manifest string; empty when the field was absent).
DA-AD-FOCUS-LOST playback warn The overlay ad lost permanent audio focus during an active break; the host player must not reclaim focus while the SDK ad is on screen. context: breakId, transient, reason.
Emitted SDK events are also captured into the diagnostic timeline under the DA-EVENT code (category event), so a single exported report shows diagnostics and the playback timeline together.

Ad error codes

Every aderror names its cause with one canonical code: DA-AD-URI-MISSING, DA-AD-MEDIA-LOAD-FAILED, DA-AD-MEDIA-UNSUPPORTED and DA-AD-START-TIMEOUT for static creatives; DA-VAST-NO-FILL, DA-VAST-TIMEOUT, DA-VAST-MALFORMED, DA-VAST-REQUEST-FAILED and DA-VAST-CREATIVE-FAILED for VAST; and existing codes such as DA-VAST-IMA-SDK-MISSING, DA-VAST-IMA-ERROR or DA-IMAGE-LOAD-FAILED where they fit. DA-AD-PLAYBACK-ERROR is used only when the cause is unknown. The code appears in the DA-AD-PLAYBACK-ERROR diagnostic as context.adErrorCode and in CMCD as adec. The raw vendor code (for example the IMA error number) stays in context.vendorCode and adevc. Web, Android and iOS map the same failure to the same code.

On the web, every player (hls.js, Shaka, THEOplayer and the browser's own video element) reports a missing, unreachable or failing ad URL (HTTP 4xx/5xx, network error or timeout) as DA-AD-MEDIA-LOAD-FAILED, and an ad URL that answers with something that is not playable media (for example a web page) or a codec the browser cannot play as DA-AD-MEDIA-UNSUPPORTED. Browsers report a missing progressive MP4 and an unplayable one with the same element error, so when the video element fails before it has any data the SDK sends one short request (at most 2 seconds) to the ad URL to tell them apart. A server that does not allow cross-origin requests is reported as DA-AD-MEDIA-LOAD-FAILED. When one ad fails in several ways, the first classified cause is reported and the ad gets one aderror.

Diagnosing a playback error

message on a playback error is the player's category, not the cause — media3 reports Source error, and a browser MediaError is barely more specific. The context carries the layer underneath, which is what actually identifies the failure:

field example what it tells you
errorCode 2 (web), -1009 (iOS) the platform's numeric code
errorName MEDIA_ERR_NETWORK the named MediaError code, web only
errorType PlaybackException, NSURLErrorDomain the error's class or domain
cause InvalidResponseCodeException: Response code: 403 the chain beneath it, up to three levels
url https://discovery.example.com/…/main.m3u8 the URL the player was ASKED to open
finalUrl https://cdn.example.com/v2/origin-lon-1/…m3u8 the URL that ANSWERED, after redirects
httpStatus 403 the status, as a number
responseHeaders x-served-by=cache-ams21033-AMS; via=1.1 varnish who answered — see below

cause is normally the decisive one: it distinguishes an HTTP rejection from an unreachable host from a malformed manifest, none of which are separable from the message alone.

url and finalUrl are different questions, and conflating them is a trap: when a discovery or routing service answers 302 with a regional origin, a failure reported against the requested URL says nothing about which hop refused. finalUrl is reported only when it differs, and only where the platform exposes it — web reads the XHR's post-redirect responseURL, iOS reads HTTPURLResponse.url, and Android usually cannot: media3 builds its exception from the original DataSpec and keeps no post-redirect URL, so there the field is honestly absent rather than implied by url.

responseHeaders answers the question that follows a rejection: whose rejection was it? A 403 that the origin's own logs do not show means something in between answered — a proxy, a corporate egress, a CDN edge — and the headers name it (x-served-by and x-cache are Fastly; via and server are usually a proxy). The set is an allowlist, never the whole header block: diagnostics travel off-device into reports and dashboards and must never carry a set-cookie or an authorization. The set covers who answered (x-served-by, via, cf-ray) and why (x-error, cf-ipcountry, retry-after) — a geo rule and a rate limit are indistinguishable without the latter.

Availability differs by platform, and the SDK reports what exists rather than inventing parity: Android surfaces all three (read structurally off the player's HTTP exception, with no ExoPlayer dependency in the core); web surfaces them when the engine reports a network error; iOS usually surfaces only url — AVFoundation reports an opaque error with the HTTP layer buried in an underlying CFNetwork error and exposes no response headers at all.

Measuring transition cost (DA-BREAK-TRANSITION)

A transition is the gap where the viewer sees neither the outgoing nor the incoming media. The SDK times each one and reports it as a DA-BREAK-TRANSITION diagnostic whose context carries:

Field Meaning
transition into-break (break triggered → the break's first ad renders), ad-to-ad (one ad ends → the next ad in the same break renders), break-to-break (the outgoing break's last ad ends → the chained break's first ad renders), out-of-break (break ends → content is playing again).
path break-to-break, and ad-to-ad on web: queued (the incoming ad was buffered behind the outgoing ad), late-queued (buffered after the next break appeared or changed during the last ad) or cold (loaded at the switch).
leadMs With path, when the incoming ad was buffered: milliseconds it was buffered before the switch.
durationMs Wallclock milliseconds the transition took.
breakId The break the transition led into, or out of.
adPreload The resolved preload mode (parallel / single-decoder) — so measurements are comparable across devices and configurations.
adInsertion The resolved insertion mode.
phases Debug only. Ordered sub-phase checkpoints attributing the transition cost, each { name, atMs, sinceLastMs }. Absent unless the SDK is constructed with debug: true.

On iOS and Android, a back-to-back break that opens with a static video ad is buffered while the last ad of the previous break plays (path: queued, debug phase load-skipped-queued). On web the same applies to static HLS ads played by the SDK's default ad player with adPreload resolved to parallel. VAST, GAM and image ads, the iOS picture-in-picture window, web Smart TVs, progressive MP4 ads and custom createAdAdapter players still load the next ad at the switch (path: cold). On web the next ad inside a multi-ad break is buffered the same way, so ad-to-ad also reports path (queued or cold) and leadMs; the Android and iOS SDKs report ad-to-ad without them.

sdk.onDiagnostic((d) => {
  if (d.code !== 'DA-BREAK-TRANSITION') return;
  const { transition, durationMs, adPreload } = d.context;
  console.log(`${transition}: ${durationMs}ms (preload: ${adPreload})`);
});

Attributing the cost per phase (debug)

With debug: true, an into-break measurement is broken down so a slow transition can be attributed rather than guessed at:

Phase Meaning
uri-resolved The ad's media URI is known (includes vendor/GAM resolution).
load-start About to attach + load the ad media.
load-resolved Attach + manifest parse finished. sinceLastMs here is the attach/manifest cost.
load-skipped-preloaded Emitted instead of load-start/load-resolved when the break was already preloaded, so no load was needed.
play-called Playback requested. The remaining time to durationMs is first-frame decode/render cost.
first-frame Android and iOS only, and only when a measurement is still open. See DA-AD-SURFACE-REVEALED below, which reports the same moment unconditionally.
sdk.onDiagnostic((d) => {
  if (d.code !== 'DA-BREAK-TRANSITION') return;
  // Where did this transition actually spend its time?
  d.context.phases?.forEach((p) => console.log(`${p.name}: +${p.sinceLastMs}ms`));
});
A transition that never completes (e.g. a break cut short before its first ad rendered, or a format that never pauses content and so never emits a content playing) is dropped rather than reported with a misleading duration — so an absent measurement is itself a signal.

Chain summary (DA-BREAK-CHAIN)

Back-to-back breaks that play as one chain (see chaining in the configuration) are summarised once, when content plays again; a chain that never returns to content (a new chain begins, the session ends) is reported without contentResumeMs. The context carries:

Field Meaning
chainId The chain's first break (also in breakId).
breaks Per break: id, scheduledStart (manifest start), plannedDurationSec, beganAtMs, endedAtMs, playedSec, announcedDuringChain (it joined after the chain began) and path (how the switch into it went).
switches Per measured switch: toBreakId, gapMs (outgoing ad's end → incoming ad's first frame), path and, when buffered, leadMs.
contentResumeMs Milliseconds from the last break's end to content playing again.
totalMs Milliseconds from the first break's begin to the last break's end.

When the ad actually became visible (DA-AD-SURFACE-REVEALED)

Android and iOS hold the ad surface invisible until the ad has really rendered a frame (Media3's onRenderedFirstFrame / AVFoundation's isReadyForDisplay) instead of ramping up to a black surface. The reveal is a cut on every platform: the surface jumps to its alpha and content is paused in the same turn (a fade over the content would show the stream's own break under it, and with the first frame already rendered there is no gap left to hide). This diagnostic reports that moment, once per revealed ad:

Field Meaning
reason first-frame — revealed because the ad had a picture. reveal-timeout — no frame arrived before the ad-start deadline, so it was revealed anyway rather than played invisibly (expected for an audio-only creative; worth investigating otherwise). shown-before-frame (web only) — the surface was already on screen before the ad had a picture.
waitedMs How long the surface was held back. This is the black gap the viewer would have seen before the gate existed, so it is the number to trend. 0 for shown-before-frame: nothing was held.
visibleGapMs Web only, when the surface was shown before the picture: how long the viewer saw the ad surface without a picture. The number to trend on web.
transitionMs The fade duration in force, from OptiViewAdsConfig.transition (always 0 now: the reveal is a cut on every platform, cut: true).
assetId / breakId Which ad and break, when known.

Web reports the same diagnostic, on every web player and on both the overlay and the shared-element path. Its first frame is the first one the browser presents on the element that draws the ad (requestVideoFrameCallback, or the first timeupdate past 0 where a browser lacks it): the SDK's ad video, the video IMA plays a VAST ad in, or the content video on the shared-element path. Web shows the ad surface at break start, so an ad is normally reported as shown-before-frame with visibleGapMs; only a held pre-roll waits for its picture and reports first-frame with waitedMs (its visibleGapMs is the time from the reveal to the picture). Android and iOS report the diagnostic once per break, for its first ad; web reports it for every ad of a pod. The gap between two ads is also measured by DA-BREAK-TRANSITION.

VAST ads follow the same rule: IMA plays them on the SDK's own ad player (Android's ExoPlayer, iOS/tvOS's AVPlayer), so their first frame reveals them like any other video ad. On iOS and tvOS a VAST ad that IMA reports started is shown within about one second even if no frame has reached the surface, and is reported as reveal-timeout.

It is separate from DA-BREAK-TRANSITION rather than a sub-phase of it because that measurement settles at adbegin — before the first frame — so a phase reported at reveal time would arrive after the measurement closed and be dropped. durationMs is unchanged and still measures commit → playback start.

Android (Kotlin)

onDiagnostic(handler) / offDiagnostic(handler) subscribe to the stream; exportDiagnostics() returns a redacted DiagnosticReport. The codes, categories, and levels are identical to the table above.

val handler: DiagnosticHandler = { d ->
    Log.d("Ads", "[${d.level}] ${d.code} — ${d.message} ${d.context ?: ""}")
}
sdk.onDiagnostic(handler)

// later
sdk.offDiagnostic(handler)

// Shareable, redacted report for a support ticket / AI tooling
val report = sdk.exportDiagnostics()

DiagnosticEvent (com.dolby.optiview.ads.sdk):

data class DiagnosticEvent(
    val ts: Long,                        // epoch ms
    val level: DiagnosticLevel,          // DEBUG | INFO | WARN | ERROR
    val code: String,                    // stable, e.g. "DA-MANIFEST-FETCH-FAILED"
    val category: DiagnosticCategory,    // MANIFEST | SESSION | BREAK | PRELOAD | GAM
                                         // | PLAYBACK | CHAINING | EVENT | LIFECYCLE
    val message: String,
    val context: Map<String, Any?>? = null,   // never contains secrets
)

Tune the ring buffer via OptiViewAdsConfig.diagnostics = DiagnosticsConfig(bufferSize = 200).

iOS / tvOS (Swift)

onDiagnostic(_:) returns a Subscription token (pass it to offDiagnostic(_:)); exportDiagnostics() returns a redacted DiagnosticReport.

let token = sdk.onDiagnostic { d in
    print("[\(d.level)] \(d.code) — \(d.message)", d.context ?? [:])
}

// later
sdk.offDiagnostic(token)

// Shareable, redacted report
let report = sdk.exportDiagnostics()

DiagnosticEvent (OptiViewAdsSDK):

public struct DiagnosticEvent {
    public let ts: Int64                 // epoch ms
    public let level: DiagnosticLevel    // .debug | .info | .warn | .error
    public let code: String              // stable, e.g. "DA-MANIFEST-FETCH-FAILED"
    public let category: DiagnosticCategory  // .manifest | .session | .break | .preload
                                             // | .gam | .playback | .chaining | .event | .lifecycle
    public let message: String
    public let context: [String: Any]?  // never contains secrets
}

Tune the ring buffer via OptiViewAdsConfig(diagnostics: DiagnosticsConfig(bufferSize: 200)).

Custom Player UI

The SDK is designed to work alongside a fully custom player UI. By replacing the browser's native controls with your own, you get complete control over how playback and ad breaks are presented to users.

The principle is the same on every platform: route playback through the SDK (play/pause/seek), provide an overlay container for the SDK-owned ad surface, and swap your controls for a break indicator on the adbreakbegin/adbreakend events. Use the Web / Android / iOS switcher at the top of the sidebar to choose your platform.

Web

Non-16:9 content and the SDK stage

The SDK creates a pixel-sized .dolby-stage inside the configured container. Once the content <video> reports valid intrinsic dimensions, the stage uses that media aspect ratio rather than assuming 16:9. This matters for edge-anchored overlay, double, and L-shape layouts: their percentages resolve against the painted content rectangle, including after a rendition or source change. If metadata is not available yet, the historical 16:9 geometry remains the safe fallback.

Why custom controls?

Native browser controls have no awareness of ad breaks. A user could hit pause, seek, or unmute at exactly the wrong moment during a break. Routing all interactions through the SDK prevents this:

Action Native With SDK
video.pause() during locked break Pauses content No-op (SDK ignores it)
video.currentTime = x during break Seeks content SDK snaps back if snapback: true
Play button during break Resumes content SDK blocks until break ends

Setup

Remove the controls attribute and position your own UI elements inside the player container:

<!-- The SDK stage -->
<div id="container" style="position:relative;">
  <!--
    Provide an explicit playerContainer that wraps ONLY the content player(s)
    (<video>, and <div id="theoPlayerEl"> if you use THEOplayer). The SDK
    resizes/repositions playerContainer into a pip corner during a
    double/L-shape break — your controls and the break toast must live
    OUTSIDE it, as direct siblings on #container, so they keep spanning the
    full stage instead of shrinking into the pip. If you omit playerContainer
    the SDK auto-wraps ALL of #container's children (including your controls)
    into its own internal wrapper, which has the same shrinking problem.
  -->
  <div id="playerContainer" style="position:absolute;inset:0;">
    <video id="video" muted playsinline></video>
  </div>

  <!-- Controls bar: a sibling of playerContainer, always spans #container -->
  <div id="playerControls" class="player-controls">
    <button id="btnPlay" aria-label="Play/Pause"></button>
    <button id="btnMute" aria-label="Mute/Unmute"></button>
    <button id="btnFullscreen" aria-label="Fullscreen"></button>
  </div>

  <!-- Break toast: also a sibling, so it always covers the full stage -->
  <div id="breakToast" class="break-toast">
    <span class="toast-badge">AD</span>
    <span id="toastText">Ad break</span>
  </div>
</div>

Routing playback through the SDK

Always call sdk.play(), sdk.pause(), and sdk.seek() — never manipulate the video element directly from your UI:

btnPlay.addEventListener('click', () => {
  if (video.paused)
    sdk.play(); // SDK will block if break is content-locking
  else sdk.pause(); // SDK will no-op if break is content-locking
});

// Seek to 3:00 — SDK will snap back if a locked break is active
btnSeek.addEventListener('click', () => sdk.seek(180));

Hiding controls during ad breaks

The SDK fires adbreakbegin and adbreakend when a break starts and ends. Use these to swap your play/seek controls for a break indicator — but keep the mute control reachable: a viewer who cannot unmute a playing pre-roll has no way to hear it. The simplest approach is to only hide the controls that don't apply during a break (play/pause, seek) rather than the whole bar, or to include a Mute button in your break-toast markup too:

sdk.addEventListener('adbreakbegin', () => {
  // Keep the control bar (and its mute button) visible — do not hide it here.
  document.getElementById('breakToast')!.classList.add('visible');
});

sdk.addEventListener('adbreakend', () => {
  document.getElementById('breakToast')!.classList.remove('visible');
});

Break countdown timer

adbreakbegin gives you the total break duration via e.break.duration (seconds, may be undefined for dynamic breaks). Drive a countdown with setInterval:

let countdownTimer: ReturnType<typeof setInterval> | null = null;

sdk.addEventListener('adbreakbegin', (e: AdBreakBeginEvent) => {
  const toastText = document.getElementById('toastText')!;
  let remaining = Math.round(e.break.duration ?? 0);

  const fmt = (s: number) => (s >= 60 ? `${Math.floor(s / 60)}m ${s % 60}s` : `${s}s`);

  toastText.textContent = remaining > 0 ? `Ad break · ${fmt(remaining)} remaining` : 'Ad break';

  if (remaining > 0) {
    countdownTimer = setInterval(() => {
      remaining = Math.max(0, remaining - 1);
      toastText.textContent =
        remaining > 0 ? `Ad break · ${fmt(remaining)} remaining` : 'Ad break ending…';
      if (remaining === 0) {
        clearInterval(countdownTimer!);
        countdownTimer = null;
      }
    }, 1000);
  }
});

sdk.addEventListener('adbreakend', () => {
  clearInterval(countdownTimer!);
  countdownTimer = null;
});

For a more accurate countdown that stays in sync with actual ad playback, use adtimeupdate instead:

sdk.addEventListener('adtimeupdate', (e: AdTimeupdateEvent) => {
  const remaining = Math.ceil(e.duration - e.currentTime);
  document.getElementById('toastText')!.textContent = `Ad break · ${remaining}s remaining`;
});

Ad progress bar

adtimeupdate fires at ~4 Hz during ad playback and includes both currentTime and duration:

sdk.addEventListener('adtimeupdate', (e: AdTimeupdateEvent) => {
  const pct = e.duration > 0 ? (e.currentTime / e.duration) * 100 : 0;
  progressBar.style.width = `${pct}%`;
});

Auto-hiding controls

Show controls on mouse interaction and hide them after a timeout during playback:

let hideTimer: ReturnType<typeof setTimeout> | null = null;

function showControls() {
  controls.classList.add('visible');
  clearTimeout(hideTimer!);
  if (!video.paused) {
    hideTimer = setTimeout(() => controls.classList.remove('visible'), 3000);
  }
}

container.addEventListener('mousemove', showControls);
video.addEventListener('pause', showControls); // keep visible when paused

Fullscreen

Request fullscreen on the SDK container (not the video element) so ad overlays and companion banners are included:

btnFullscreen.addEventListener('click', () => {
  if (!document.fullscreenElement) container.requestFullscreen();
  else document.exitFullscreen();
});

document.addEventListener('fullscreenchange', () => {
  btnFullscreen.setAttribute(
    'aria-label',
    document.fullscreenElement ? 'Exit fullscreen' : 'Fullscreen'
  );
});

Mute / volume sync

Drive mute/volume through the SDK's unified sdk.muted / sdk.volume — they always target whichever player is currently audible (the ad player during a break, the content player otherwise), so one button works correctly through break transitions in both directions. Listen for the SDK's volumechange event to keep your icon in sync without polling — it fires on every change, whether triggered by your button, a direct mutation of the content/ad element, or an IMA CSAI ad's own UI:

btnMute.addEventListener('click', () => {
  sdk.muted = !sdk.muted;
});

sdk.addEventListener('volumechange', (e) => {
  btnMute.setAttribute('aria-label', e.muted ? 'Unmute' : 'Mute');
  // swap icon here
});

Current-time indicator

Show the elapsed content time by polling the player on a short interval and formatting currentTime. Reading the player's currentTime works the same way across HLS.js / Shaka / THEOplayer / native, so a single poll drives the label:

const fmt = (seconds: number) => {
  if (!Number.isFinite(seconds) || seconds <= 0) return '0:00';
  const t = Math.floor(seconds);
  const h = Math.floor(t / 3600);
  const m = Math.floor((t % 3600) / 60);
  const ss = String(t % 60).padStart(2, '0');
  return h > 0 ? `${h}:${String(m).padStart(2, '0')}:${ss}` : `${m}:${ss}`;
};

const timer = setInterval(() => {
  timeIndicator.textContent = fmt(video.currentTime);
}, 250); // ~4 Hz

// On teardown: clearInterval(timer);

Keep the indicator inside #playerControls so it auto-hides during ad breaks alongside the rest of your controls (the break toast covers the ad). The demo factors this into a shared formatPlayerTime() / createTimeIndicator() helper used by every demo page.

Skip forward / back

Add skip buttons that jump the content timeline by a fixed offset. Route them through sdk.seek() and clamp the target to the playable range so you never seek past the end (or before the start). Because the seek goes through the SDK, it is a no-op without an active session and is suppressed during snapback breaks:

const clampSeekTarget = (current: number, delta: number, duration: number) => {
  const target = (Number.isFinite(current) ? current : 0) + delta;
  if (target < 0) return 0;
  if (Number.isFinite(duration) && target > duration) return duration; // live: skip upper clamp
  return target;
};

function skip(delta: number) {
  sdk.seek(clampSeekTarget(video.currentTime, delta, video.duration));
}

btnBack15.addEventListener('click', () => skip(-15));
btnFwd30.addEventListener('click', () => skip(30));

The demo's VOD page wires exactly this (−15s / +30s) with the shared clampSeekTarget() helper in web/demo/src/seek.ts. The buttons live inside #playerControls, so they auto-hide during ad breaks.

Remembered session fields

The demo's Player page remembers your per-user Org ID, Channel ID, Custom Asset Key, Content URL, and Ad Tag Parameters in localStorage, so edits survive a reload. The built-in defaults stay as the fallback for a fresh browser, and a Reset to defaults link under the Load button clears the saved values and restores them. This is a demo-page convenience (helper in web/demo/src/field-storage.ts); the SDK itself stores nothing. URL query-param overrides used by the e2e suite still take precedence over stored values.

Predefined configurations via URL (?presets)

The Player page can be seeded with named, fully-formed configurations passed in the URL — handy for sharing reproducible setups without hand-editing the form. Pass a base64-encoded JSON array of configuration objects in the ?presets= query parameter. When present, a Predefined Configurations card appears at the top of the config column; choosing an entry fills the whole form and auto-loads it. The first entry is auto-selected and loaded on page open. With no ?presets parameter, the card is hidden and the page behaves exactly as before (the manual form stays available either way).

Every field on the page is configurable. All fields except name are optional — an omitted field keeps the form's current/default value. The one exception is preRoll: it is a full on/off toggle, so a preset that omits preRoll (or sets "enabled": false) turns pre-roll OFF. This means switching from a pre-roll preset to one without never inherits the previous pre-roll injection.

[
  {
    "name": "Sponsor A — SGAI DAR", // required, non-empty; the selector label
    "mode": "sgai", // "sgai" | "ssai"
    "player": "hlsjs", // "hlsjs" | "shaka" | "theo" | "native"
    "manifestBaseUrl": "https://us.staging.ads.sneezysparrow.com/manifest/v1",
    "gam": true, // Enable GAM
    "networkCode": "23285652104",
    "orgId": "0bda787b-…",
    "channelId": "d7803a87-…",
    "customAssetKey": "assetkey_michel",
    "adInsertionType": "replacement", // "replacement" (DAR) | "insertion" (DAI)
    "contentUrl": "https://…/main.m3u8",
    "assetParams": { "iu": "/23285652104/dcoffey-v2-adunit" }, // object or JSON string
    "preRoll": { "enabled": true, "format": "single", "delaySeconds": 0 },
    "stitcherBaseUrl": "http://localhost:4600", // SSAI only — demo composes the master URL from it + orgId/channelId
    "stitcherOriginUrl": "https://…/main.m3u8",
    "maxBitrate": 2000000,
    "ssaiAutoplay": true,
    "stitcherPort": "4600",
    "snapPolicy": "nearest", // "nearest" | "start" | "end"
  },
]

Build the parameter by base64-encoding the JSON array (standard or URL-safe base64 is accepted), e.g. in the browser console:

const presets = [{ name: 'Sponsor A', orgId: '…', channelId: '…' }];
location.search = '?presets=' + encodeURIComponent(btoa(JSON.stringify(presets)));

Unknown keys are ignored and unknown enum values (mode, player, insertion type, snap policy, pre-roll format) are skipped with a logged warning, so a config is forward-compatible. A malformed, empty, or non-array ?presets value is ignored (with one warning in the event log) and the card is not shown. Decoding/applying is handled by the unit-tested web/demo/src/demo-presets.ts helper (decodeUrlPresets / applyPreset); demo only — no SDK/core change.

Preset Builder

You don't have to hand-write that base64 array. The Preset Builder page (sidebar → Preset Builder, /preset-builder.html) lets you visually assemble one or more presets, generates the shareable URL-safe ?presets= link and the raw JSON live, and offers Copy + Open in Player. You can also paste an existing ?presets URL (or base64 token) to import and edit it — a full round-trip. The builder reuses the same demo-presets.ts primitives (encodeUrlPresetsSafe / decodeUrlPresets) and the pure web/demo/src/preset-builder-model.ts helper (buildPreset / presetToValues / presetsToUrl / urlToPresets), so the links it produces are exactly what the Player page consumes.

Android (Kotlin)

The SDK plays ads on its own PlayerView inside the overlayContainer FrameLayout you pass to OverlayAdRenderer, stacked above your content surface. Build your own controls (or use a Compose overlay) and follow the same rules:

  • Provide an overlay container above your content PlayerView — a FrameLayout matching the content bounds, passed to OverlayAdRenderer(context, overlayContainer, contentAdapter).
  • Route playback through the SDK — call sdk.play() / sdk.pause() / sdk.seek(seconds) instead of touching the ExoPlayer directly, so content-lock and snapback are honoured.
  • Swap controls for a break indicator on ADBREAKBEGIN / ADBREAKEND.
  • Drive a countdown from the ADTIMEUPDATE event (currentTime / duration) or from break_.duration.
// Hide your controls + show a break indicator during the break
sdk.addEventListener(OptiViewAdsEventType.ADBREAKBEGIN) {
    playerControls.isVisible = false
    breakToast.isVisible = true
}
sdk.addEventListener(OptiViewAdsEventType.ADBREAKEND) {
    breakToast.isVisible = false
    playerControls.isVisible = true
}

// Countdown that stays in sync with actual ad playback
sdk.addEventListener(OptiViewAdsEventType.ADTIMEUPDATE) { event ->
    val e = event as AdTimeupdateEvent
    val remaining = kotlin.math.ceil(e.duration - e.currentTime).toInt()
    toastText.text = "Ad break · ${remaining}s remaining"
}

// Route the play/pause button through the SDK (no-op during content-locking breaks)
playPauseButton.setOnClickListener {
    if (contentPlayer.isPlaying) sdk.pause() else sdk.play()
}
Mute/volume are synced between the content and ad players by the SDK; just update your own icon. Never hand your content ExoPlayer to the renderer — the SDK owns a separate ad player.

iOS / tvOS (Swift)

The SDK plays ads on its own AVPlayer in an AVPlayerLayer inside the overlayContainer UIView you pass to OverlayAdRenderer, stacked above your content surface. The same rules apply:

  • Provide an overlay container above your content surface — a UIView matching the content bounds, passed to OverlayAdRenderer(overlayContainer:contentPlayer:).
  • Route playback through the SDK — call sdk.play() / sdk.pause() / sdk.seek(seconds) instead of touching the AVPlayer directly.
  • Swap controls for a break indicator on .adbreakbegin / .adbreakend.
  • Drive a countdown from the .adtimeupdate event, or from the break duration.
// Hide your controls + show a break indicator during the break
sdk.addEventListener(.adbreakbegin) { _ in
    playerControls.isHidden = true
    breakToast.isHidden = false
}
sdk.addEventListener(.adbreakend) { _ in
    breakToast.isHidden = true
    playerControls.isHidden = false
}

// Countdown that stays in sync with actual ad playback
sdk.addEventListener(.adtimeupdate) { event in
    if case let .adTimeUpdate(_, _, currentTime, duration, _) = event {
        let remaining = Int(ceil(duration - currentTime))
        toastLabel.text = "Ad break · \(remaining)s remaining"
    }
}

// Route the play/pause button through the SDK (no-op during content-locking breaks)
playPauseButton.addAction(UIAction { _ in
    contentPlayer.timeControlStatus == .playing ? sdk.pause() : sdk.play()
}, for: .touchUpInside)
On iPhone the SDK may resolve to shared-element / adaptive insertion (a single fullscreen ad through the content player) to preserve iOS native fullscreen — see SDK Configuration. tvOS and iPad use the overlay compositor.

Ad Formats

Each break in the manifest carries a variant that specifies the format. The SDK applies the correct layout automatically and controls whether content playback is paused.

Format Content paused? Companion? Description
single ✅ Yes — Full-screen ad overlay. Content is hidden and paused. On Android and iOS the whole overlay container is covered, letterbox bars included, so content subtitles drawn there stay hidden until content resumes.
double ❌ No¹ ✅ Image (picture-relative artwork) Content and ad play side-by-side in equal boxes (920×517.5px at 1080p, 20px border). Companion artwork follows the painted picture while native hosts fill letterbox bars opaquely. Animated transition in/out. ¹On handheld/tablet web devices the split layout cannot be read, so double renders as a single fullscreen ad with content paused (platform-capability fallback); events still report double.
lshape_ad ✅ Yes ✅ Image (picture-relative artwork) Content player is hidden. Ad video plays in a 65% pip anchored to a corner of the picture (anchor, default top-left, 5% inset). Companion artwork follows the painted picture while native hosts fill letterbox bars opaquely. Animated transition in/out.
lshape_content ❌ No — Content player shrinks to a 65% pip anchored to a corner of the picture (anchor, default top-left) — content keeps playing. A backdrop image (from assets[0]) follows the painted picture while its host fills letterbox bars opaquely. No ad video plays. Animated transition in/out.
overlay ❌ No — Semi-transparent ad positioned over content using manifest-supplied position and size values (fractional 0.0–1.0, converted to %). Content keeps playing.
When the manifest carries a slate, every format above shows it in its own layout for the part of a break no ad covers (on the web, Android and iOS today): a double or lshape_ad companion stays up, and an lshape_content break without a backdrop asset shows the slate in the backdrop's place.
The above are client-side (SGAI) layouts. The server-side SSAI Stitcher always stitches a fullscreen single ad, and by default also stitches double and lshape_ad as fullscreen single (their companion is dropped) — set stitchCompositedAsSingle: false to stitch only genuine single breaks. lshape_content and overlay are never stitched.

Manifest variant shapes

single / lshape_content / overlay — simple assets array

{
  "format": "single",
  "assets": [
    { "id": "a1", "type": "static", "mediaType": "video", "uri": "https://cdn.example.com/ad.m3u8" }
  ]
}

double / lshape_ad — assets with companion (flat)

The companion is a property directly on the asset object (flat intersection, not nested).

{
  "format": "double",
  "assets": [
    {
      "id": "a1",
      "type": "static",
      "mediaType": "video",
      "uri": "https://cdn.example.com/ad.m3u8",
      "companion": {
        "id": "c1",
        "type": "static",
        "mediaType": "image",
        "uri": "https://cdn.example.com/companion.jpg"
      }
    }
  ]
}

With a vast asset that was not preloaded, the content stays full screen while the tag loads and moves into its box once the ad has loaded. A tag that fails changes nothing on screen. See VAST (CSAI).

lshape_ad / lshape_content — anchor (manifest spec 1.11.0)

The L-shape video box is 65% of the content picture, inset 5% from the two edges of the corner it is anchored to; the ad band runs along the two other edges. anchor picks that corner: top_left (the default, same as a manifest without the field), top_right, bottom_left or bottom_right. An unrecognised value renders top_left and raises DA-BREAK-LSHAPE-ANCHOR-UNKNOWN; the break is not dropped. The backdrop/companion image is authored for one orientation, so pick artwork that matches the anchor.

{
  "format": "lshape_content",
  "anchor": "top_right",
  "assets": [
    { "id": "backdrop-1", "type": "static", "mediaType": "image", "uri": "https://cdn.example.com/backdrop.png" }
  ]
}
anchor Box (left, top, width, height) of the picture Band
top_left 5%, 5%, 65%, 65% right + bottom
top_right 30%, 5%, 65%, 65% left + bottom
bottom_left 5%, 30%, 65%, 65% right + top
bottom_right 30%, 30%, 65%, 65% left + top

Animated companions and backdrops

Every image surface can be an animated GIF or animated WebP: the companion of a double or lshape_ad break, the backdrop of an lshape_content break, an image ad (mediaType: "image" on an overlay or single break) and a pause-ad image. Set mediaType: "image" and point uri at the file. When mimeType is declared the SDK uses it: image/gif or image/webp takes the animated path without the file being checked and animates when the file has frames, and a still type (image/png, image/jpeg or image/jpg, image/svg+xml) is always shown still on Android and iOS. Another image type, such as image/avif, is shown as an image whose file decides the format, and is reported once as DA-IMAGE-MIME-UNSUPPORTED. Without a mimeType the SDK detects an animation from the file itself. A slate image follows the same rules. The animation plays for as long as the break shows its artwork and stops with it, at the frame timing and loop count stored in the file (loop count 0 loops forever; a finite count stops on the last frame, as in a browser).

{
  "format": "double",
  "assets": [
    {
      "id": "a1",
      "type": "vast",
      "mediaType": "video",
      "uri": "https://ads.example.com/vast.xml",
      "companion": {
        "id": "c1",
        "type": "static",
        "mediaType": "image",
        "mimeType": "image/gif",
        "uri": "https://cdn.example.com/companion.gif"
      }
    }
  ]
}
Platform Animated GIF / WebP Notes
Web Yes The browser animates the <img>.
Android / Android TV API 28 and above Decoded off the main thread at the size the picture needs. Below API 28 the first frame is shown and DA-IMAGE-ANIMATION-UNSUPPORTED is reported once per image.
iOS / tvOS Yes Frames are decoded on a background queue; a frame that is late is skipped, never queued. An animation whose canvas is larger than about 1080p keeps its first frame and reports DA-IMAGE-ANIMATION-UNSUPPORTED (canvas-too-large).
Roku No The first frame is shown.

Animated PNG (APNG) is not supported.

Authoring guidance. Every frame is decoded in software, so the file size and canvas decide how much CPU a low-end TV spends:

  • Keep the canvas at 1080p or below. On Apple TV, prefer 720p or below for WebP: its decoder is slower than GIF's.
  • Keep the frame rate at 15 fps or below and the file under about 2 MB. A file above 8 MB is refused on Android and iOS (DA-IMAGE-LOAD-FAILED, error: "too-large").
  • Export with loop count 0 when the artwork should animate for the whole break.
  • The break still plays if the artwork is refused or cannot animate; only that image is affected.

overlay — position + size (fractional 0.0–1.0)

{
  "format": "overlay",
  "assets": ["..."],
  "position": { "bottom": 0.05, "right": 0.05 },
  "size": { "width": 0.3, "height": 0.2 },
  "opacity": 0.9
}

Image (non-linear) overlay assets

An overlay asset can be an image instead of a video by setting mediaType: "image" (e.g. a banner or logo bug). The SDK renders it as an <img> (web) / ImageView (Android) / UIImageView (iOS) inside the overlay's position/size/opacity box, and holds it on screen for the asset's duration (seconds). When duration is omitted, the break duration is used as the fallback.

{
  "format": "overlay",
  "assets": [
    {
      "id": "a1",
      "type": "static",
      "mediaType": "image",
      "uri": "https://cdn.example.com/banner.png",
      "duration": 8
    }
  ],
  "position": { "bottom": 0.05, "right": 0.05 },
  "size": { "width": 0.3, "height": 0.2 },
  "opacity": 0.9
}
  • Preload — image overlay assets are warmed (decoded) ahead of the break, so they appear instantly with no flash.
  • Failure handling — if an image fails to load, the SDK dispatches aderror for that asset and ignores it (no adbegin); any remaining assets in the break still play, and content keeps playing throughout (overlay never pauses content).
  • Native parity — image overlay rendering, preload, and failure handling behave identically on web, Android, and iOS.

Layout DOM structure

At initialize() the SDK permanently sets playerContainer to position:absolute; top:0; left:0; right:0; bottom:0 with a 0.3s ease-in-out transition on all position axes, enabling smooth animated transitions between formats. At break end the container animates back to the base position. On destroy() the original styles are fully restored.

Format playerContainer at break start .dolby-ad-container .dolby-companion
single base (full stage) top:0; left:0; right:0; bottom:0 —
double top:26.04%; left:1.04%; right:51.04%; bottom:26.04% (left box) top:26.04%; left:51.04%; right:1.04%; bottom:26.04% (right box) Picture-relative artwork, opaque host fill, z-index 99
lshape_ad Anchored pip (top_left: top:5%; left:5%; right:30%; bottom:30%) then opacity:0 (content scales to pip before hiding) Same anchored pip, z-index 100 (ad plays here) Picture-relative artwork, opaque host fill, z-index 99
lshape_content Anchored pip (top_left: top:5%; left:5%; right:30%; bottom:30%), z-index 101 (content plays here) Hidden (display:none) Backdrop from assets[0], picture-relative artwork, opaque host fill, z-index 99
overlay base (full stage) Manifest fractional position/size → CSS % —

Break Manifest

The break manifest is a JSON document served by the OptiView Ads backend. The SDK fetches it at session start and polls it at the intervals specified in the manifest.

Manifest URL

GET https://<your-manifest-host>/manifest/v1/{orgId}/channels/{channelId}

# Pass the finished URL to startSession({ manifestUrl }); the SDK fetches and
# polls it verbatim, so the path shape above is the manifest service's contract.

Structure overview

{
  "version": "1.0.0",
  "timebase": "wallclock",
  "polling": {
    "idle": 30,
    "active": 5
  },
  "breaks": [
    {
      "id": "break-001",
      "start": "2026-06-07T14:00:00Z",
      "duration": 30,
      "variant": {
        "format": "single",
        "assets": [
          {
            "id": "asset-001",
            "type": "vendor",
            "vendor": "gam",
            "mediaType": "video",
            "uri": "pod-id-from-eabn",
            "vendorParameters": {
              "type": "pod",
              "eabnVersion": "V2",
              "networkCode": "23285652104",
              "customAssetKey": "my-asset-key"
            }
          }
        ]
      }
    }
  ]
}

Variant-level fields beyond format, assets and targeting: overlay carries position, size and opacity; lshape_ad and lshape_content may carry anchor (spec 1.11.0 — the corner the video box is pinned to: top_left default, top_right, bottom_left, bottom_right; an unknown value renders top_left with DA-BREAK-LSHAPE-ANCHOR-UNKNOWN). See Ad formats for the geometry.

Manifest signature

Every manifest response is authenticated before it is parsed: the server signs the response body and sends a detached JWS (Ed25519, RFC 7515 Appendix F + RFC 7797 b64:false) in the X-Manifest-Signature header, which the SDK verifies against an embedded trusted key list. Verification fails closed — a missing header, unknown key id, unsupported algorithm, or tampered body rejects the manifest (DA-MANIFEST-SIGNATURE-INVALID) and schedules no breaks; a failed poll keeps the last verified manifest and retries at the next interval. Two hosting requirements:

  • the manifest host must expose the header to browsers: Access-Control-Expose-Headers: X-Manifest-Signature;
  • the body must reach the SDK byte-identical to what was signed (any rewriting proxy invalidates the signature).

The internal Web demo/tests additionally trust a repo-public test key, and the demo's local manifest server signs with it. Every published Android and iOS/tvOS SDK—release, dev build, or custom—trusts only the three backend keys; their unit/conformance tests inject the test key through non-production wiring. Mock responses returned by interceptManifestRequest bypass the network and are not signature-checked.

Polling

The manifest's polling object is the only source of the refresh cadence — there is no client-side default and no configuration override:

  • polling.idle — seconds between re-fetches while no ad break is active.
  • polling.active — seconds between re-fetches while a break is playing. The SDK switches the running timer between the two intervals the moment the break-active state changes.
  • No polling object — the manifest is fetched exactly once at session start and never re-polled (typical for VOD).

A polled manifest may itself change or remove its polling object; the SDK re-resolves the cadence after every poll.

Delivery steering (delivery + vendorConfiguration)

The manifest's optional delivery array lets the backend steer which ad-insertion architecture a session uses, per platform:

{
  "delivery": [
    { "mode": "ssai", "targeting": { "deviceType": "tv" } },
    { "mode": "sgai" }
  ],
  "vendorConfiguration": [
    {
      "type": "gam",
      "networkCode": "23285652104",
      "customAssetKey": "pod-serving-key",
      "assetKey": "full-service-dai-key"
    }
  ]
}
  • Rules are evaluated in order against the client's deviceType (desktop / mobile / tablet / tv); the first matching targeted rule wins, and a rule without targeting is the default. Absent delivery or no matching rule resolves sgai (the current behaviour). An unrecognized mode value resolves sgai and emits DA-DELIVERY-MODE-UNKNOWN (forward compatibility).
  • On the web, tv covers Samsung Tizen, LG webOS, Vizio SmartCast, Sony BRAVIA, Google TV, Apple TV, HbbTV, NetCast and VIDAA browsers, detected from the User-Agent.
  • The mode is resolved on the first manifest fetch and again on an ads-channel switch (DA-DELIVERY-MODE-RESOLVED). Ordinary polls keep the current mode and log DA-DELIVERY-MODE-CHANGE-IGNORED when the rules differ. Everything else in a polled manifest (breaks, polling, vendor configuration) is honored normally.
  • An explicit constructor mode overrides manifest steering (DA-DELIVERY-MODE-OVERRIDDEN) — explicit client configuration always wins.
  • Manifest-steered ssai requires a vendor configuration able to provide the stitched stream — currently a gam entry carrying an assetKey (the channel's full-service DAI livestream identifier, distinct from the pod-serving customAssetKey). The SDK requests the stitched livestream via IMA (LiveStreamRequest) and plays it on the content player; timebased breaks are carried by the stream. The SDK keeps polling the manifest and still schedules event-triggered breaks (pre-roll, pause ads) client-side.
  • When ssai is selected but no vendor configuration provides a stitched stream, startSession rejects with the catchable SsaiUnavailableError (DA-SSAI-UNAVAILABLE) — there is no silent fallback to sgai; the application decides which stream to play.
  • Platform support: web, Android / Android TV, iOS / tvOS and React Native (Android and iOS) resolve manifest steering the same way. Steered ssai opens the channel's full-service DAI livestream (assetKey) on the content player (the content AVPlayer on iOS / tvOS). The failure is SsaiUnavailableError (DA-SSAI-UNAVAILABLE) on web, SsaiUnavailableException on Android and SsaiUnavailableError on iOS / tvOS. On React Native Android the explicit override is the JS config's mode. The stitcher-URL flavour of an explicit mode: 'ssai' remains web-only.

Server-side beaconing stream (ssb) and the AirPlay guard

A channel can offer a server-side beaconing (SSB) stream next to its DAI livestream, as an ssb object on a gam ssai[] entry (a spec 1.9.0 draft field; players ignore it when absent):

{
  "type": "gam",
  "networkCode": "23285652104",
  "ssai": [
    {
      "assetKey": "live_assetkey_dev",
      "ssb": {
        "uri": "https://pubads.g.doubleclick.net/ssai/event/live_assetkey_dev/master.m3u8",
        "format": "hls",
        "assetParameters": { "cust_params": "section=sports&delivery=ssb" },
        "drm": { "integration": "ezdrm", "fairplay": { "licenseUrl": "…", "certificateUrl": "…" } }
      }
    }
  ]
}

The SDK reads the first usable ssb of the first gam entry; an ssb without a non-blank uri is ignored, assetParameters keeps string values only and drm is passed through untouched.

While a manifest carries an ssb stream and the content adapter can gate external playback (setExternalPlaybackAllowed, see Player Adapters → External playback), the SDK closes the AirPlay gate for the session and guards it around ad breaks:

  • An AirPlay request while a break is active, or within externalPlayback.blockBeforeBreakSec seconds (default 5) of the next scheduled break, is blocked for the content player and the SDK records DA-EXTERNAL-PLAYBACK-BLOCKED (reason: break-active or break-imminent). On iOS the running ad plays on the receiver instead: the SDK lets the ad player take AirPlay so iOS does not fall back to an audio-only route, which stalls the ad. At the break end the SSB switch takes the receiver over.
  • A blocked request is retried when the break ends if the route is still on AirPlay. A request that passes the guard records DA-EXTERNAL-PLAYBACK-ALLOWED (trigger: connecting, active or break-ended); the gate stays closed.
  • adbreakstatus.externalPlaybackAllowed reports the current answer.
  • The gate is restored when the session ends or a channel switch drops the stream. Sessions without an ssb stream never touch the gate.
  • On Safari the gate cannot hold the video on the device: disableRemotePlayback hides the AirPlay affordances but does not stop webkitShowPlaybackTargetPicker() or end an active route, so a blocked request shows the content on the TV until the break ends and the switch runs (see Player Adapters → External playback).

Playing the SSB stream over AirPlay

When AirPlay starts and the guard lets the request through (DA-EXTERNAL-PLAYBACK-ALLOWED), the SDK switches the content player to the ssb stream:

  1. It records the current source (PlayerAdapter.sourceUrl), position and live state, stops any break, closes the GAM session and halts the break scheduler.
  2. It loads ssb.uri with the asset parameters as query parameters (SessionConfig.assetParameters < updateAssetParameters() < manifest ssb.assetParameters, as everywhere else), resumes playback if content was playing, then opens the AirPlay gate. Customer and runtime macros resolve in the URL; built-in $OPTIVIEW_* macros resolve only where the platform provides them (the web user agent), otherwise the token stays literal.
  3. The receiver must report active within 1.5 s of the stream being ready to play (the load itself is capped at 15 s) and must not pause within 3 s of that; otherwise the switch fails (DA-SSB-SWITCH-FAILED, reasons no-restore-source, load-error, load-timeout, external-not-active, receiver-paused) and the SDK restores the previous content. adbreakstatus.deliveryMode reads ssb from the switch on. Only when the receiver held the stream for those 3 s does adchannelchange fire with reason: 'external-playback' and deliveryMode: 'ssb'; a switch that fails earlier emits DA-SSB-SWITCH-FAILED and the DA-DELIVERY-MODE-RESOLVED restore diagnostic, but no adchannelchange pair. While the stream plays, adbreakstatus.externalPlaybackAllowed stays true. A new AirPlay request while the switch or the restore is in progress is ignored (no DA-EXTERNAL-PLAYBACK-ALLOWED or -BLOCKED).

When AirPlay stops, or the switch failed, the SDK closes the gate and reloads the previous source itself: live content returns to the live edge, VOD to the recorded position. It then returns to the previous delivery mode: sgai reopens GAM; steered ssai opens the stitched stream again, and falls back to sgai when that is unavailable. Breaks that started while the stream played are retired with adbreakskipped reason played-by-ssb; later breaks run normally. If the reload fails twice the SDK reports DA-SSB-RESTORE-FAILED and the session stays in ssb delivery with the gate closed: reload your content and start a new session. A channel switch seen while the stream plays is applied after the restore. Sessions without an ssb stream are unaffected.

THEOplayer web on Safari cannot change source during an AirPlay session (the session ends and the new source is not loaded), so the switch does not reach the receiver there; see Player Adapters → External playback.

The gate controls video only. After a failed switch the video returns to the device, but the system audio route stays on the AirPlay receiver until the viewer disconnects it, so the device can show the content without sound while the receiver plays the audio. The SDK cannot change a system route; keep an AirPlay route picker (AVRoutePickerView on iOS, the browser's AirPlay control on Safari) reachable so the viewer can end the route, and treat DA-SSB-SWITCH-FAILED as the cue to point them to it.

Ad-free start (adStartDelay)

An optional top-level adStartDelay (seconds >= 0, next to polling; omitted means 0) keeps the start of a session ad-free. It counts played media time only, from the first actual content frame — a play request, pause, buffering or seeking does not advance it, so viewers cannot fast-forward through the ad-free window.

For SGAI sessions with a resolved GAM identity, the IMA pod stream is requested only after the full delay has played. Break starts, preloads, pause ads and snapback remain held until IMA setup succeeds or fails; a stream-clock live/PTS/wallclock break already in progress is joined for its remaining duration after the hold opens, while VOD does not late tune in after a missed start. If IMA setup fails, the existing GAM failure handling applies and GAM assets are skipped. Missing or zero delay keeps the existing session-start IMA request behavior.

When a manifest channel switch is applied before playback starts, the new manifest's adStartDelay replaces the previous value and still counts from the first frame of the session. After playback starts, a channel switch does not update the delay in effect.

While the delay has not elapsed, no break may start and controls.snapback does not apply. Once it elapses, the SDK looks at the current position and resumes normal behavior:

  • For stream-clock live/PTS/wallclock breaks, if the position is inside a break, the SDK tunes in to its remainder (resume point per resumeOffset or the break duration). VOD does not late tune in after a missed scheduled start.
  • Breaks whose start passed during the delay are not started retroactively, but they are not consumed either — seeking over one with snapback enabled afterwards snaps back to it, and seeking back into the DVR window and reaching one plays it as normally scheduled.
  • It applies to timebase-scheduled and event-triggered breaks alike, judged on the break's effective start moment (trigger plus the break's own delay). A pre-roll therefore plays only when its own delay >= adStartDelay (both count played media time from session start); an immediate pre-roll under an ad-free start is intentionally skipped.

This supports players initialized speculatively (e.g. while scrolling through a feed): ads only show once the viewer has actually watched for a while.

Try it: the Manifests page has an Ad-free start (adStartDelay 20 s) preset with one mid-roll before the delay elapses (passed, unconsumed) and one after it (plays normally). Create it as a channel, play it on the Player page, and pause or seek during the first 20 s to see the delay hold.

Slate (slate)

An optional top-level slate (manifest spec 1.12.0) names media the player shows during the part of a break that no ad covers, so a break of 150 seconds whose ads play for 130 is not handed back to content 20 seconds early.

{
  "slate": {
    "minDuration": 5,
    "assets": [
      { "id": "slate-brand", "type": "static", "mediaType": "video", "uri": "https://cdn.example.com/slate/master.m3u8" }
    ]
  }
}
  • One slate for every break. Only the first asset is played; it must be a static video or image (its mimeType decides, else its mediaType; see Declared media type) and carries no duration. A video loops from its start for as long as the slate lasts, an image stays on screen. interaction.clickThrough works as it does on an ad.
  • It fills the gap and never more. The slate starts when the last ad has ended (or, when no ad could play at all, at the start of the break) and runs until the break's scheduled end: the break's clock start (see below) plus the break's duration, or the remainder a viewer tuned into. The break's clock starts at the first frame of its first ad, the same moment the hard cut-off starts counting, so that ad's loading and start-up time counts for neither the ads nor the slate: a 20-second break with a 15-second ad leaves 5 seconds. Everything after that counts as break time, so time lost to an ad that never played (the break's clock then runs from adbreakbegin), to the slate's own start-up, stalls and loop restarts shortens the slate and never lengthens the break. DA-SLATE-ENDED.breakOverrunSec reports how far from the scheduled end the slate stopped. Content resumes at the same point as without a slate. On Android and iOS this is wall time: a slate in an app that went to the background ends at the scheduled end too.
  • minDuration (seconds >= 0, default 5) is the least remaining time worth filling, measured in real time left to the scheduled end, counted from the first ad frame as above. A remainder exactly equal to minDuration starts the slate. A smaller gap is left to content as before (DA-SLATE-NOT-STARTED, reason below-min-duration); 0 fills any gap.
  • No ad ever played (an empty ad response, every ad failed, a variant with no assets) still gets the slate for the whole break. A break the viewer skips or the operator removes ends the slate at once.
  • Same layout and companion. The slate takes the place of the ad in the break's own layout; a double or lshape_ad companion stays up, and an lshape_content break without a backdrop asset shows the slate in its place.
  • No ad events. The slate emits no adbegin/adend, so ad counts and ad analytics are unaffected; it is visible in diagnostics only (DA-SLATE-STARTED, DA-SLATE-ENDED, DA-SLATE-NOT-STARTED). If the slate cannot load or play, an aderror carrying the slate asset is emitted, DA-SLATE-FAILED is reported and the break ends as it would without a slate.
  • Warmed once. The slate is the same for every break, so the SDK fetches it ahead of need, on its first appearance in the manifest or when its URL changes (DA-SLATE-PRELOADED; skipped with adPreload: 'none').
  • Shared element (single-surface devices such as iPhone Safari). The ad and the slate play on the content element in turn. Only a video slate can be shown there: an image has no surface on the content element, so such a break ends when its ad ends (DA-SLATE-NOT-STARTED, reason not-rendered). A shared-element break needs an ad to begin, and an lshape_content break is not rendered there at all, so neither gets a slate.
  • Pause breaks. A pause break shows its own pause ad until the viewer resumes or its duration passes; the slate does not play there yet.
  • Stitched streams. A time-based break under server-side delivery (ssai), or while a server-side beaconing stream plays, already fills the break itself, so no client slate is shown there (DA-SLATE-NOT-STARTED, reason not-rendered).
  • An unusable slate (not an object, a negative minDuration, no assets, or an unusable first asset) is ignored and reported once as DA-SLATE-INVALID; the breaks of that manifest are unaffected. The MCP validate_manifest tool reports the same problems.

Slate playback is implemented on the web, the Android overlay renderer and the iOS/tvOS overlay renderer. On iOS a video slate loops by seeking back to its start, and a break shown in picture-in-picture shows no slate (the PiP window presents only the content player).

Try it: the Manifests page has a Slate preset with a 40-second mid-roll holding a single ad. Create it as a channel and play it on the Player page: the slate fills what the ad leaves, and the break ends at its declared end.

Break removal (early return)

When a break is removed from a polled manifest while it is playing, the SDK ends the break immediately (the balanced adend + adbreakend still fire) and resumes content at break.start plus the seconds the break already played — including in replacement mode, where a completed break normally does not seek. A chained successor is deliberately not started early; it still triggers at its own scheduled start. The removal surfaces as the DA-BREAK-EARLY-RETURN diagnostic.

Channel switch

A successful poll can describe a different ads channel than the manifest the session was started with. The SDK detects this when, compared with the previous manifest:

  • the top-level channelId is added, removed or changed (reason: channel-id-added, channel-id-removed, channel-id-changed);
  • the GAM pod identity (networkCode/customAssetKey) or the stitched-stream vendor identity changes while channelId stays the same (reason: vendor-configuration-changed);
  • the timebase changes while channelId stays the same (reason: timebase-changed).

The SDK then re-aligns its ad setup to the new manifest without ending the session: content playback continues, startSession()/endSession() are not needed, and no DA-SESSION-ENDED/DA-SESSION-STARTED is emitted. The delivery mode is resolved again. The switch surfaces as the DA-MANIFEST-CHANNEL-CHANGED diagnostic and, once the re-alignment is complete, as the adchannelchange event (previousChannelId, channelId, eventId, reason, manifestUrl, previousDeliveryMode, deliveryMode; see Events).

What is reset:

  • Pending breaks, completed-break history and retired breaks of the old channel are dropped. A break id that already played on the old channel may play again on the new one.
  • Preload and break-warning state restart for the new channel. Poll-based channel switches restart reporting; event-boundary switches keep the reporting session open.
  • When the GAM pod identity changed, the IMA stream session is closed and re-opened with the new identity (DA-GAM-SESSION-FAILED is emitted if the new session cannot be opened; the switch still completes).

What is preserved:

  • The parent content session, the content player and its playback position.
  • The startup assetParameters/assetParameterMacros and any runtime updateAssetParameters() overrides; both are re-applied to a re-opened GAM session.
  • The delivery mode is resolved again from the new manifest. An sgai to ssai switch loads the stitched stream into the player. If no stitched stream is available, DA-SSAI-UNAVAILABLE is logged and the session stays in sgai. An ssai to sgai switch stops the stitched stream; the SDK does not load a content stream, so the application must load it after adchannelchange (previousDeliveryMode: 'ssai', deliveryMode: 'sgai'). Explicit constructor mode still wins.

Runtime updateAssetParameters() overrides made while in steered ssai are not carried into the sgai GAM pod session after ssai to sgai; startup parameters/macros and sgai-side runtime overrides are used.

Active break rule: a break that is playing when the poll arrives finishes its playout first. The switch takes effect when that break ends; the break is not aborted and it is not carried over as a break of the new channel. If more manifests are polled while the break plays, the latest one is applied at that moment.

Pre-roll and adStartDelay: the new channel's pre-roll plays. Its delay counts played media time from the moment of the switch, not from session start. While playback has not started yet, the adStartDelay of the latest manifest applies and counts from the first frame. Once playback has started, a switch no longer changes the adStartDelay in effect.

A poll that returns the same channel (same channelId, vendor identity and timebase) is an ordinary update: breaks, polling and the other fields are merged as described above and no adchannelchange fires.

Channel events

Channel events let a live manifest select ad configuration by playback position. The SDK resolves the active event from the stream's wallclock position and applies that event's ad configuration when playback crosses either its start or end, in either direction. Event windows are supported only with timebase: "wallclock"; invalid windows or configuration are ignored and reported as DA-MANIFEST-EVENT-INVALID.

At each boundary the SDK emits adchannelchange with reason: "event-boundary" and the active eventId (or null when playback leaves an event). A break that has already played remains played when playback moves between events. A break scheduled at a boundary uses the configuration of the event that becomes active there. If a break is already playing, it finishes before the new event configuration is applied. Event configuration does not apply to VOD playback.

When the next event uses a different GAM identity, the web and Android SDKs can prepare its IMA session before the boundary; DA-GAM-SESSION-PRELOADED reports the preparation. The current session remains active until the event takes effect.

Timebase

Value break.start type Matching strategy
wallclock ISO-8601 string Compared against the stream's EXT-X-PROGRAM-DATE-TIME via programDateTime.
pts number (seconds) Live streams. Compared against player.currentTime, or resolved through an Anvato cue (ptsSource).
mediatime number (seconds) VOD only. Seconds from the start of the asset, compared against player.currentTime. Never uses cues.

For a playable time-scheduled VOD break, controls.snapback: true protects forward seeks from strictly before its scheduled start to that start or later: playback corrects to the break start and plays the whole break. Snapback applies only to content-pausing Single and L-Shape Ad, which return to the requested position after the break, overriding resumeOffset and insertion policy. Double Box, L-Shape Content and Overlay ignore controls.snapback: a seek over them plays on, and seeking during them is not blocked. A fullscreen fallback at break start counts as Single. Backward seeks and seeks entirely after a scheduled start do not force that break, even within its declared ad duration. The last crossed snapback break is the only candidate; if it is already played or unplayable, all crossed breaks are skipped without fallback. Other crossed breaks cannot tune in or chain during that seek and remain unplayed for later viewer seeks. The break is snapback-eligible only until it first starts in the session. Event-triggered breaks and live/PTS/wallclock, SSAI and SSB delivery are unchanged. See session seek behavior for platform gates and diagnostics.

Pre-roll breaks

A pre-roll is a break whose start is an event trigger for the start event, as defined by the Ads Manifest Specification (1.1.0+). It fires when content playback begins instead of at a timebase-derived position. An optional delay (seconds, default 0) is the amount of played media time before the pre-roll fires: paused time and seek jumps do not advance it.

{
  "id": "preroll-1",
  "start": { "type": "event", "event": "start", "delay": 0 },
  "duration": 15,
  "variant": { "format": "single", "assets": [{ "..." }] }
}
Field Type Default Description
start.type "event" — Declares an event-triggered break.
start.event "start" — Content playback start. This is the pre-roll trigger.
start.delay number (seconds) 0 Played media time after playback starts before the pre-roll triggers.

Pre-roll rules, on every platform (web, Android, iOS, React Native):

  • A pre-roll fires once per session. Seeking back to the start, or replaying content, does not trigger it again.
  • An immediate pre-roll (delay 0) holds content until the ad starts (see Session). A delayed pre-roll starts counting its delay when the first content frame plays, not when the session is created.
  • adStartDelay applies: a pre-roll plays only when its delay >= adStartDelay.
  • resumeOffset applies; controls.snapback is ignored for event-triggered breaks.
  • The start and end events are scheduled on every platform (see Post-roll breaks); the pause event drives pause ads. A break whose start.event is an unknown value is ignored and reported once as DA-BREAK-EVENT-UNSUPPORTED.

Note: Pre-rolls are only supported in SGAI mode (client-side insertion).

Legacy shape: the SDK still accepts position: "pre" with a top-level delay (and a placeholder start: 0). Both shapes are scheduled identically. New manifests should use the event trigger above.

Try it (load a published channel): the VOD page has a Break source toggle. Leave it on Break manifest (JSON) to paste/edit a manifest (the demo spins up the local server and provisions it), or switch to Channel ID to load a channel another tool already published to the ad-break server — the SDK is pointed at the configured manifest server directly (no local server, no POST). Only the channel ID is required; the manifest host and org ID are pre-filled under Advanced, and pasting a full channel URL auto-fills all three.

Try it: the demo has a dedicated Pre-roll page (sidebar → Pre-roll). The player selector shows the bundled HLS.js, Shaka and THEOplayer versions, the content URL accepts any reachable HTTP(S) HLS stream, and the player panel shows its current program date time in ISO-8601 UTC for wall-clock scheduling (Unavailable until the adapter receives a valid EXT-X-PROGRAM-DATE-TIME). In Generated manifest mode, Run starts the local manifest server, creates a pre-roll channel using the selected ad experience (single, double-box, L-shape ad, L-shape content or overlay), and switches between immediate and 5-second-delayed playback with the delay checkbox. In Custom URL mode, the page skips local channel creation and passes the supplied full, signed manifest URL directly to the SDK. The page loads the Google IMA client-side SDK (ima3.js) so custom manifests can contain VAST/CSAI assets. Remote content and manifest servers must permit browser CORS requests. Requires the Vite dev server (npm run dev).

Try it (main Player page, real backend): the Player page talks to the real ad-manifest backend, which does not serve pre-roll yet. Click Configure Pre-roll… (under the Session card) to open a modal where you can enable pre-roll, pick the ad format, and set a delay in seconds (0 = immediate). When enabled, the demo augments the backend break manifest client-side via the SDK's interceptManifestResponse hook: the callback receives the parsed, validated BreakManifest (on the initial fetch and every poll) and prepends a pre-roll break (start: { "type": "event", "event": "start" }), so the pre-roll plays at session start while every other break still comes from the backend. This is a demo-only convenience (the modal carries the same warning); leave it disabled to use the backend manifest verbatim. SGAI only — it has no effect in SSAI mode.

Post-roll breaks

A post-roll is a break whose start is an event trigger for the end event, as defined by the Ads Manifest Specification (1.3.0+). It fires when content playback ends (the player's ended event) instead of at a timebase-derived position. An optional delay (seconds, default 0) is the wallclock time between the end of content and the start of the break.

{
  "id": "postroll-1",
  "start": { "type": "event", "event": "end", "delay": 0 },
  "duration": 15,
  "variant": { "format": "single", "assets": [{ "..." }] }
}
Field Type Default Description
start.type "event" — Declares an event-triggered break.
start.event "end" — Content playback end. This is the post-roll trigger.
start.delay number (seconds) 0 Wallclock time after playback ends before the post-roll triggers.

Post-roll rules:

  • A post-roll fires once per session. Replaying the content after the post-roll, or a manifest re-poll, does not trigger it again.
  • With a finite positive content duration and explicit VOD status (isLive: false), the SDK requests preload when duration - currentTime + delay is within eight seconds. This includes zero-delay post-rolls and short VOD. It uses the configured preload mode and does not start the break; live and unknown-duration content keep the end-triggered behavior. A seek into the window may preload immediately, but an accepted preload is not requested again on subsequent ticks or seeks.
  • The delay starts counting when content playback ends. When the adapter explicitly reports VOD (isLive: false), the SDK also infers the end from the playhead if the player does not fire ended: within 0.25 seconds of the duration while playing (0.05 seconds while paused), or stalled for two seconds within the final second while not paused.
  • A replay before the delay elapses cancels the pending post-roll only when the position moves back more than one second from the recorded end position. A playing event at or past the end does not cancel it. If the position is unknown, a playback-start event still cancels it. The post-roll is armed again the next time content ends.
  • adStartDelay applies, judged on the effective start moment (content end plus delay): a post-roll is not started while the ad-free start is still active.
  • duration is the maximum duration of the break. Without controls.skipOffset the break is watched fully; with it the viewer can end the break once the offset is reached.
  • resumeOffset and controls.snapback are ignored. After the break, the content stays at its end position and is not restarted: the SDK does not seek or call play(). In shared-element mode the content source is restored on the element at its end position and left paused.
  • Event-triggered breaks and timebase breaks can be mixed in one manifest. In manifest-steered ssai mode, post-rolls are still scheduled client-side.

Note: Post-rolls are only supported in SGAI mode (client-side insertion). They are scheduled on every platform (web, Android, iOS/tvOS, React Native).

Asset types

type Description
static A direct media or image URL (HLS, DASH, MP4, PNG, ...). SDK loads it as-is, with any asset parameters appended as query parameters (see below).
vendor (gam) A GAM pod ID. SDK builds a DAI pod manifest URL using the IMA stream session.
vast A VAST ad tag URL. The SDK fetches, parses, and plays it client-side (CSAI) via the Google IMA SDK (ima3.js). Web, Android, and iOS support landed. SGAI-only and linear-only (single/double/lshape_ad) — unsupported placements are skipped with a DA-VAST-* diagnostic. See VAST (CSAI).

Declared media type (mimeType)

When an asset declares mimeType, the SDK uses it. This holds for every asset in the manifest: an ad asset in any variant, a companion, an lshape_content backdrop, a pause asset and the slate.

  • It decides video or image. A recognised mimeType wins over mediaType: an asset with mediaType: "video" and mimeType: "image/png" is shown as an image. The SDK reports the contradiction once as DA-ASSET-MEDIA-TYPE-MISMATCH.
  • It tells the player the format. A video plays as the declared format instead of a guess from the URL, so an extensionless URL plays without a probe: the web ad player picks the native <video> or hls.js from it (no HEAD request), ExoPlayer and THEOplayer get it as the source type, and AVPlayer gets it on iOS/tvOS 17 and later (earlier versions keep reading the URL). Custom web adapters receive it as load(url, { mimeType }). Two paths keep reading the URL: the web pause-ad <video>, which the browser plays from its own content check, and an ad moved into the iOS picture-in-picture window, which plays on the content player through PlayerAdapter.load(url).
  • It decides whether an image may animate. A still type (image/png, image/jpeg, also written image/jpg, and image/svg+xml) is always shown still on Android and iOS; image/gif and image/webp take the animated path without the file being checked first, and animate when the file has frames. Android below API 28 shows their first frame and reports DA-IMAGE-ANIMATION-UNSUPPORTED. Browsers decode an <img> by its content, so on the web a GIF labelled image/png still animates.
  • An image type the SDK does not handle is reported. Another image/* value, such as image/avif, still shows the asset as an image and lets the file decide its format, as without a mimeType. It is reported once as DA-IMAGE-MIME-UNSUPPORTED, unless the asset is already reported as DA-ASSET-MEDIA-TYPE-MISMATCH.
  • Companions and backdrops show images only. One whose mimeType names a video is not drawn (DA-IMAGE-LOAD-FAILED, error: "not-an-image").
  • A value the SDK does not recognise is ignored: mediaType decides, and the URL or the file decides the format, as without a mimeType. It is reported once as DA-ASSET-MIME-TYPE-UNKNOWN. A vast asset's mimeType names its tag response, so only application/xml and text/xml are accepted there; its mediaType keeps deciding which creative the VAST response is read for.
mimeType (case and parameters ignored) Plays as Format
video/mp4, video/x-m4v, video/webm, video/ogg, video/quicktime video progressive file
application/x-mpegurl, application/vnd.apple.mpegurl, audio/mpegurl, audio/x-mpegurl video HLS
application/dash+xml video DASH (players that support it)
image/gif, image/webp image animates when the file has frames
image/png, image/jpeg (image/jpg), image/svg+xml image always still
any other image/* image from the file (DA-IMAGE-MIME-UNSUPPORTED)
any other video/* video from the URL

The MCP validate_manifest tool warns about the same mismatches and unrecognised values.

{
  "id": "artwork-animated",
  "type": "static",
  "mediaType": "image",
  "mimeType": "image/webp",
  "uri": "https://cdn.example.com/ads/backdrop.webp"
}

vendor, vast (since Break Manifest 1.4.0) and static (since 1.5.0) assets may carry assetParameters, a string map the SDK forwards to the ad server — as IMA ad-tag parameters for GAM, as query parameters on the tag URL for VAST, and as query parameters on the resource URL for a static asset (its own uri, a static companion and a pause-ad image or video). $NAME$ tokens inside a value are macros, replaced in place ("$OPTIVIEW_PLAYER_WIDTH$x$OPTIVIEW_PLAYER_HEIGHTquot; → "1920x1080"): the SDK fills in $OPTIVIEW_USER_AGENT$, $OPTIVIEW_PLAYER_WIDTH$, $OPTIVIEW_PLAYER_HEIGHT$, $OPTIVIEW_BREAK_DURATION_MS$ and $OPTIVIEW_BREAK_DURATION_SECONDS$, and the app can add or override names with SessionConfig.assetParameterMacros. A string replaces a token. "", null, or a registered callback result of undefined marks it empty, so the parameter is omitted or only the containing pair of any literal-& value is dropped; this applies to GAM, VAST, and static assets. An undefined initial map entry is not registered, and an update entry of undefined unregisters the name. An unresolved core-table value leaves the token literal and still sends the parameter. A value with an unresolved $OPTIVIEW_* name is kept literally and sent with DA-ASSET-MACRO-UNKNOWN raised once per parameter key and macro; a throwing customer callback is unresolved if there is no built-in fallback. Empty omissions raise DA-ASSET-PARAMETER-OMITTED. Any other unresolved complete token is kept literally without a diagnostic. A $ without a closing $ is left unchanged. $APP$ and $APP_NAME$ never collide. See the Session page for the full rules and the GAM page for how the session, update, manifest-session and per-asset layers combine.

Static assets. The request URL of a static asset carries the parameters the app supplies (SessionConfig.assetParameters, then updateAssetParameters()) with the asset's own assetParameters on top: a key in both is taken from the asset. The session-level assetParameters of the gam vendor configuration (sgai / ssai) target GAM only and never apply to static assets. Macros are filled in when the URL is requested, as for VAST, with one difference for empty macros: any value that contains a literal & is treated as a list of key=value pairs, and only the pairs with an empty macro are dropped (a plain value is omitted as a whole). For a uri array the parameters go on the selected entry. Only that request carries them: for an HLS or DASH asset the master playlist or MPD request, not the variant playlists or segments. Keys and values are percent-encoded and inserted before any #fragment; an inline data: URL is never changed. A static asset without parameters, in a session without app-supplied parameters, is requested with exactly the manifest URL. Do not use asset parameters with a signed or tokenized URL: the added query parameters can invalidate its signature, and app-supplied parameters are added to every static asset request.

{
  "id": "spring-sale",
  "type": "static",
  "uri": "https://cdn.example.com/ads/spring-sale/master.m3u8",
  "mediaType": "video",
  "assetParameters": {
    "campaign": "spring-sale",
    "ppid": "$CUSTOM_VIEWER_ID$",
    "dim": "$OPTIVIEW_PLAYER_WIDTH$x$OPTIVIEW_PLAYER_HEIGHT$"
  }
}

With $CUSTOM_VIEWER_ID$ = v1 on a 1920x1080 player, the SDK requests https://cdn.example.com/ads/spring-sale/master.m3u8?campaign=spring-sale&dim=1920x1080&ppid=v1.

Try it: the Manifests page has a Static asset parameters preset: a mid-roll at 10 s whose static asset carries assetParameters with built-in macros. Create it as a channel, play it on the Player page (optionally with Asset Parameters set in the session card) and watch the ad's .m3u8 request in the browser's network tab.

Try it: the Manifests page has a VAST — CSAI (IMA sample tag) preset that builds a vast pre-roll using Google's public IMA sample tag. Create it as a channel, then play that channel on the Player page to watch a client-side VAST ad. See the VAST (CSAI) page for the full walkthrough.

Creative hosting requirements (CORS). Every asset uri — static media, VAST tag XML and its referenced media files, and companion/pause-ad images — is fetched directly by the browser (or, for vast, by the Google IMA SDK from its own iframe), so the hosting server must send permissive CORS headers (and answer HEAD, which some ad-tech CDNs skip). A non-CORS host fails with MEDIA_ELEMENT_ERROR: Format error (static/vast media) or a silent tag fetch failure (VAST XML) — easy to mistake for a manifest or SDK bug. If a creative host cannot be made CORS-compliant, proxy it through your own origin. All demo sample creatives (SAMPLE_AD_MP4, SAMPLE_AD_VAST, SAMPLE_COMPANION_IMG, etc.) are pre-verified CORS-enabled hosts.

Platform, OS and version targeting

The manifest Targeting object supports deviceType, platform, os, and inclusive osVersion bounds (min and/or max). A version is a dot-separated sequence of decimal integers; missing device-version parts compare as zero and extra device parts are ignored. osVersion requires os. Unknown values, unknown fields, and malformed constraints fail closed, so that entry does not match. The Targeting enums and schema are defined by manifest spec v1.9.0; the SDK's global manifest compatibility pin remains v1.4.0.

For web players, vizio and xbox are detected from the case-insensitive VIZIO and Xbox User-Agent tokens. These device-specific OS values take precedence over generic linux, windows, or android tokens in the same User-Agent. Vizio devices have deviceType: tv; Xbox devices have deviceType: console, which represents a game console. Neither OS has a detectable version, so an osVersion-targeted entry does not match. SmartCast alone identifies a TV but does not select the vizio OS value. An Xbox app WebView whose User-Agent lacks Xbox reports windows.

Any web User-Agent containing Tizen reports os: tizen; osVersion is included only when the User-Agent contains a Tizen version.

Bounds compare numerically and inclusively at the bound's precision: osVersion: { "max": "3" } matches major version 3, including 3.x, not only 3.0. If the detected OS version is unknown, a version-gated variant does not match; an untargeted default placed last handles that profile.

Runtime Detected profile values
Web platform: web; OS from the user agent. iPad Safari in desktop mode reports macos / desktop. macOS and Windows versions are not detected.
Android platform: android, os: android, version from Build.VERSION.RELEASE.
iOS platform: ios; phone → ios, iPad → ipados, tv → tvos; version from the OS. An iOS app on Mac reports macos without a version.
tvOS platform: tvos, os: tvos, version from the OS.
Roku deviceType: tv, platform: roku, os: rokuos; OS version comes from the device and is included only when all four decimal parts are available.

For webOS, the browser derives the LG release from Chromium: 38→3, 53→4, 68→5, 79→6, 87→22, 94→23, 108→24, and 120→25. Other Chromium versions are left undetected unless they are newer than the highest mapping, in which case they report the newest known webOS version until the SDK adds a mapping for that release. The 2022+ values use LG's year names.

Try OS-version variants (VOD)

On Manifests, select Platform/OS version variants (VOD pre-roll) (platform-os-version-variants) and inspect the existing Detected device profile display. Copy the generated JSON to VOD → Break manifest (JSON) and run it. This mediatime SGAI pre-roll uses only static single variants, with no GAM configuration or live ad backend:

Order Target Asset ID
1 platform: web, Tizen ≤3 (max: "3") ad-tizen-3-and-older
2 platform: web, Tizen ≥4 (min: "4") ad-tizen-4-and-newer
3 platform: web, webOS ≤6 (max: "6") ad-webos-6-and-older
4 platform: web, webOS ≥22 (min: "22") ad-webos-22-and-newer
5 Untargeted default for nonmatches, including unknown versions ad-platform-os-default

The matching declared variant is used for playback; the default is last. Asset IDs distinguish the choices, but all use the same sample creative. The demo's local manifest server and reachable sample media are still required. The separate platform-os-targeting preset remains the delivery-steering and URI-targeting example; it can select SSAI and requires its vendor setup.

Variant selection (device targeting + format fallbacks)

A break may declare several variants, and the SDK picks ONE with a single ordered walk over them (identical on web, Android, and iOS — locked by the cross-language conformance harness):

  1. Targeting match. Every supplied targeting field must match the detected device profile. An absent or empty targeting object is a default and qualifies on any device.
  2. Format playability. A qualifying variant whose format the platform cannot render in the current context is passed over in favor of the next qualifying variant (e.g. authoring [double, single] gives platforms that cannot show a two-box layout the single fallback). A variant with an unknown format is never playable. While content is in picture-in-picture at break start the playable set narrows to single, so a declared single variant is picked over overriding a rich one.

Declaration order wins whenever several variants qualify — both for multiple defaults and for multiple variants targeting the same device type.

PiP after preload (Web): if inline playback preloads double asset ad1 and PiP entry before break start selects a declared single variant with asset ad2, playback loads ad2 rather than reusing ad1. An earlier request for ad1 is legitimate when PiP was entered after preload; it does not mean ad1 plays. Attached media is reused only once and only when the break ID, asset ID, resolved URI and owning adapter instance match. These web-runtime cache rules do not change the variant-selection policy above or cover IMA/VAST manager reuse.

When nothing qualifies (and no downgrade path applies), the break does not begin: no adbreakbegin/adbreakend is emitted, content keeps playing, and the SDK reports an aderror event (source: 'ad', carrying the break) plus the DA-BREAK-NO-PLAYABLE-ASSET diagnostic naming the reason (no-qualifying-variant). The same no-begin contract now applies to every break with nothing to play (empty asset lists included) — previously such breaks emitted a misleading empty adbreakbegin/adbreakend pair.

Try it: on the Manifests page, author a break whose variant is an array — e.g. a tv-targeted double first and an untargeted single behind it — and play it on the Player page: a desktop browser plays the single, and a break whose only variant targets tv never begins (watch the aderror

  • DA-BREAK-NO-PLAYABLE-ASSET in the event log).
The full manifest specification — including break variants, asset targeting, forward compatibility rules, and JSON schema — is documented in the OptiView Ads manifest spec (v1.9.0).

Manifest interception

Two optional SGAI hooks let you intercept the break manifest on the client — without standing up a proxy — at the two natural points around the fetch. Both run on the initial fetch and every subsequent poll.

  • interceptManifestRequest runs before the network request (rewrite URL, add headers, or mock the response).
  • interceptManifestResponse runs after fetch + validation (transform the parsed BreakManifest).

Request interception (interceptManifestRequest)

The interceptManifestRequest hook is invoked before the SDK fetches the manifest, so you can redirect the request, attach headers, or short-circuit the network entirely with a mocked response. It is primarily a testing aid (point the SDK at a fixture, or exercise header-based auth) but is a supported production hook.

Return one of:

  • a ManifestRequest ({ url, headers? }) — fetch this (possibly rewritten) URL with the given headers;
  • a ManifestMockResponse ({ body }) — skip the network and use body (a raw JSON string or object) as the fetched manifest body. The mock body goes through the normal parse + validation path — an invalid body still fails validation, and interceptManifestResponse (if set) still runs afterward;
  • nothing (void/undefined) — fetch unchanged.

Failure is non-fatal: if the hook throws (or its promise rejects), the SDK emits DA-MANIFEST-REQUEST-INTERCEPT-FAILED and falls back to the normal network fetch of the original URL. May be async.

import { OptiViewAds, type ManifestRequest } from '@dolby-optiview/ads-sdk-core';

const sdk = new OptiViewAds({
  // ...
  // Add an auth header to every manifest request (initial fetch + every poll):
  interceptManifestRequest: (request: ManifestRequest) => ({
    ...request,
    headers: { ...request.headers, Authorization: `Bearer ${token}` },
  }),
});

// Or short-circuit the network with a fixture (great for tests):
new OptiViewAds({
  // ...
  interceptManifestRequest: () => ({ body: JSON.stringify(myFixtureManifest) }),
});
SGAI only. The same API exists on Android ((suspend (ManifestRequest, ManifestRequestContext) -> ManifestRequestResult?)?) and iOS (ManifestRequestInterceptor? returning .request/.mock/nil); both forward it to the injected ManifestSource, which applies it before the network fetch.

Response interception (interceptManifestResponse)

Some integrations need to adjust the break manifest on the client — inject a pre-roll, drop a break, rewrite an asset URL, or layer in client-side targeting — without standing up a proxy. The optional interceptManifestResponse SDK config hook is invoked after the SDK has fetched and validated the manifest, on the initial fetch and on every subsequent poll, so you can transform it before it is scheduled.

Key guarantees:

  • Typed, never raw. The callback receives the parsed BreakManifest (normalized variants arrays, parsed numbers/enums) — never the raw JSON. An invalid manifest fails validation before the hook runs, so it is never called with garbage.
  • Its return value is used as-is. Return the (possibly new) BreakManifest to schedule; it is used directly, without re-validation. Returning the input unchanged is a no-op.
  • Runs on every poll. Live channels re-poll; the hook is applied each time, so keep it pure/idempotent (e.g. guard against injecting the same break twice).
  • Failure is non-fatal. If the hook throws (or its promise rejects), the SDK emits the DA-MANIFEST-INTERCEPT-FAILED diagnostic and falls back to the unmodified parsed manifest — the fetch/poll does not fail.
  • May be async. Return a Promise<BreakManifest> to do async work (the poll awaits it).
import { OptiViewAds, type BreakManifest } from '@dolby-optiview/ads-sdk-core';

const sdk = new OptiViewAds({
  // ...
  interceptManifestResponse: (manifest: BreakManifest, ctx) => {
    // Inject a client-side pre-roll, idempotently (runs on every poll).
    if (manifest.breaks.some((b) => b.id === 'my-preroll')) return manifest;
    return {
      ...manifest,
      breaks: [
        {
          id: 'my-preroll',
          start: { type: 'event', event: 'start' },
          duration: 15,
          variants: [
            /* ... */
          ],
        },
        ...manifest.breaks,
      ],
    };
  },
});
SGAI only. The demo's Pre-roll feature on the Player page is built on this hook. The same API exists on Android ((suspend (BreakManifest, ManifestInterceptContext) -> BreakManifest)?) and iOS (ManifestResponseInterceptor?); both forward it to the injected ManifestSource, which applies it after parsing. See the per-platform config tables under SDK Configuration.

Google Ad Manager

The SDK integrates with Google DAI Pod Serving via the IMA DAI SDK. When a GAM vendor asset is scheduled, the SDK requests a pod manifest URL and plays it in the ad player.

With a positive manifest adStartDelay on SGAI, the IMA pod stream request waits until the viewer has played the full ad-free start. Only advancing content position counts; pause, buffering, seeking and a play request without rendered content do not. Breaks remain held until IMA setup succeeds or fails, then follow the normal scheduling rules. A zero or missing delay preserves the existing session-start request behavior.

This page shows the web API. GAM/DAI pod serving ships on the native Android and iOS SDKs too (over the platform IMA SDK). See Android and iOS / tvOS.

Roku GAM path

Roku's separate SceneGraph component uses IMA with the application-owned Video and adUiNode; the channel declares googleima3 and roku_ads_lib. Eligible single-format GAM breaks come only from the JSON break manifest. The runtime prepares pods and publishes them into its continuous local HLS output before they become visible to the player, rather than loading an overlay or changing Video sources at ad boundaries. Network break manifests remain signature-verified; explicit application mocks are a separate trusted seam.

Initial tune-in is content-first: it does not wait for GAM. A late or unready pod leaves original content in place and emits one terminal adbreakskipped, never a retroactive insertion. Multiple opportunities can be queued. Latest applicable parameter/channel updates govern future preparation while committed/active playback is protected; retired IMA/worker callbacks cannot revive old targeting. Missing completion metadata reports recovery/abandonment rather than fabricated adend, quartiles or beacons.

Clear TS/CMAF demuxed media and ABR graphs use byte-level timing validation and atomic rendition coordination. Coordinated deferred resume is enabled in the production media worker. alignmentToleranceSeconds accepts numeric values from 0.002 to 0.250 seconds (default 0.250), not arbitrary timestamp repair, incompatible topology or runtime creative cuts. Source-authored PDT is required. Redirected HLS masters and media playlists use the final response base for relative URLs. Full-segment EXT-X-SERVER-CONTROL metadata is accepted without advertising blocking/partial reload support in the local output; its HOLD-BACK keeps local publication, and therefore each break decision, at least that far behind the live edge (never less than two segments); actual parts, delta updates and preload hints remain unsupported. The packaged Roku example can therefore use a redirecting discovery URL without an application-side CDN URL workaround. Signed JSON-manifest verification is unchanged. Native Video.positionInfo UTC (epoch: 1), observed on an Ultra, is validated against published source spans and coherent generation/clip samples; an externally verified generation-scoped anchor remains a fallback.

When the manifest's delivery rule for tv selects ssai, Roku uses Google DAI full service instead of pod serving: it requests a live stream for the gam entry's ssai[0].assetKey (or top-level assetKey) and networkCode, returns the stitched URL in ready, and forwards every Video message to IMA for tracking. IMA ad callbacks surface as the usual ad events with deliveryMode: "ssai"; ad tag parameters (session, runtime and ssai[0].assetParameters, session macros) are updated through replaceAdTagParameters; the pod-serving dai-emsgv=0 override is not sent, because it stalled full-service CMAF playback on device. CMAF streams use the same presented-metadata bridge for Google emsg ID3 as the SGAI path. RAF ad measurement and interactive companions are enabled. Live HLS only; VOD, DVR and DASH are not supported in SSAI.

Roku now permits different ad/content quality ladders and compatible audio-language fallback, including reuse of an ad rendition. Selection stays within the source's published codec/frame-rate quality envelope. Audio fallback prefers matching language, then a compatible default or single available track; channel-layout changes are not authorized by language fallback. Constrained Baseline, Main and High AVC may differ within the persistent source profile/level envelope; the original content profile and init are restored afterward. Unknown/high-bit-depth profiles and configurations above that envelope remain refused. Input codec metadata stays explicit; the local master advertises avc1,mp4a.40.2 across the supported profile changes. Container/layout conversion is not enabled. An ad need not repeat the content origin's optional EXT-X-INDEPENDENT-SEGMENTS declaration. The stitched master omits that global promise rather than extending it to unproven future ad media. Existing media evidence, init-map, codec/rate, tracking and boundary checks remain required; a missing declaration is not a claim that arbitrary ad segments are independently decodable.

Roku requests Google's CMAF timed metadata using dai-emsgv=0 and a bound StreamRequest.videoObject, including after ad-parameter replacements. The SDK recognizes the standard Apple ID3 scheme and the existing AOMedia scheme inside validated version-zero emsg boxes. It still requires structured Google ID3 payloads, a valid timescale and bounded box geometry; arbitrary markers and unsupported versions are not accepted as tracking evidence. Metadata availability alone never counts as an ad start, impression or completion.

Nominal HLS FRAME-RATE must be present and equal (30 equals 30.000, not 29.970). AAC sample rates and channel configurations observed in ASC/ADTS metadata must also match. Unknown rates fail explicitly; segment duration is not used to guess FPS. Master-less content may play but ad preparation reports frame-rate-unverified. Different segment lengths remain allowed under the existing timing and target-duration guards. These policy changes have offline coverage. The mapper's nested native-array iteration and the missing-rate test fixture have been corrected. Native assertions and controlled packaged-SDK renderer tests now cover supported profile changes and restoration of content initialization. Those renderer fixtures use synthetic metadata, not IMA ad events. The real API-authored 30-second single-break gate now passes on the tested Roku, including correlated completion, break-end and advancing content without replay. Small CMAF duration rounding is corrected from verified sample clocks without cutting media. Already-presented native emsg metadata is normalized before IMA so its offset is not applied twice; genuine ID3 and timestamps are preserved, and no completion callback or larger deadline is fabricated.

For repeated Roku breaks, the SDK services IMA between pods with non-metadata player messages while keeping ad metadata gated by commitment. Recovery and shutdown fences remain enforced. Preparation pipelines up to three same-init segments per batch with full validation. Live preparation now inspects complete playlists and bounded startup/terminal segments, then refills a shared verified A/V prefix. Each wave retains the 15-second deadline instead of requiring the whole pod upfront; refills run 40 s ahead and network failures are retried up to three times. Return correction shifts only published PDT, not encoded bytes or original source time used for DVR: overlaps up to alignmentToleranceSeconds are absorbed, a newly introduced gap on another rendition stays within three samples, and a segment grid that shifted during the break resumes at the nearest boundary (see Roku). Published media must not overlap. A late failure terminates at verified media rather than replaying a frozen live window. Committed media remains retained while ending monetization and through parameter changes intended for future breaks. An ad segment that overlaps its predecessor by less than one frame continues the timeline without a discontinuity, even in the middle of a group of pictures. A decode clock that goes back by a whole frame can start an explicit, coordinated decode period: every video rendition must prove random access and audio must have a matching segment boundary. When dependency flags are unspecified, a complete first-sample AVC IDR can provide byte-level proof; malformed data, dependent slices and contradictory flags are not accepted. All preceding samples remain present; only unpublished boundaries and the proven terminal estimate change. Positive gaps and unsafe or unmatched resets are not accepted by increasing the general tolerance.

Long-running device sessions with repeated 30, 60 and 150 second GAM pods, demuxed CMAF with several video qualities, and full IMA tracking pass on the tested Roku devices. GAM can fill less than the requested slot; the SDK plays and reports what it receives.

DVR startup resume (reloadAfterSeek({ position, generation, resumeStrategy: "startup" }) after the app stops and detaches the same Video) stays experimental. The SDK validates the last coherent native clock and prepares GAM afresh before publishing; at ready the app sets ContentNode.playStart to resume.contentPlayStart unchanged and Video.seekMode = "accurate" before attaching and playing. Content-only reloads work; ads after a seek are not part of the supported scope, and a refusal or no-fill never counts as a played ad. Details are in Session Management; the Roku section covers integration, timing and limitations. The web setup and full-format placement table below do not extend Roku's scope.

Playback and event timing

On Web, THEOplayer metadata tracks are enabled as hidden so presented TXXX markers reach IMA. The SDK reports IMA's actual per-ad quartiles; it does not replace missing markers with percentages of the entire pod. The break-cut countdown starts on actual ad playback, so manifest loading and decoder startup do not shorten the playback allowance. A separate startup watchdog still returns to content if the ad never starts.

fMP4 pods with separate audio and video renditions are supported. If both renditions carry the same ad marker at the same time, it is passed to IMA once. The DA-GAM-DUPLICATE-METADATA diagnostic reports this once per stream session. When ShakaAdapter is used for an ad player, the SDK automatically enables Shaka's fMP4 emsg ID3 dispatch. The integrator's content player is not reconfigured.

Prerequisites

  1. A Google Ad Manager account with DAI Pod Serving enabled.
  2. A Network Code and a Custom Asset Key per channel.
  3. Include the IMA DAI SDK in your HTML before your application script:
<script src="https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js"></script>

Configuration

const sdk = new OptiViewAds({
  player: contentAdapter,
  container: document.getElementById('container'),
  playerContainer: document.getElementById('playerContainer'),
  createAdAdapter: (adVideo) => buildAdAdapter(adVideo),
  gam: {
    networkCode: '23285652104', // your GAM network code
  },
});

await sdk.startSession({
  manifestUrl: 'https://manifest.example.com/v1/your-org/channels/your-channel',
  customAssetKey: 'your-asset-key', // per-channel key
  assetParameters: {
    ott_placement: '0', // 0 = single / full-screen
    cust_params: 'region=eu', // custom targeting
  },
});

Asset parameters

Four sources can describe the parameters for one GAM asset, ordered by how specific they are. Later layers override earlier ones per key, so overriding one key never discards the rest:

  1. The session — SessionConfig.assetParameters, supplied at startSession().
  2. A live update — updateAssetParameters() or updateAssetParameterMacros().
  3. The manifest session — vendorConfiguration.gam.sgai[0].assetParameters.
  4. The asset — asset.assetParameters, the targeting the break author wrote for that specific asset.

The deprecated top-level customAssetKey and assetKey remain supported; nested sgai[0] and ssai[0] fields are preferred in manifest spec 1.4.0.

To change parameters during an active session (e.g. a content segment change):

sdk.updateAssetParameters({ cust_params: 'genre=basketball' });
sdk.updateAssetParameterMacros({ $CUSTOM_TEAM$: 'basketball' });

This calls IMA's StreamManager.replaceAdTagParameters() under the hood — no session restart needed. Two consequences follow from how that API behaves:

  • It applies to future breaks only. A break whose ad request has already gone out cannot be retargeted.
  • It replaces the whole map rather than merging, so the SDK always pushes the full effective map for the asset about to play, and pushes the session baseline back when the break ends. Without that restore one asset's targeting would leak into every later break.

Values that contain full $MACRO$ tokens are substituted before the map is pushed — see Asset-parameter macros on the Session page. A $ without a closing $ is left unchanged, and $APP$ and $APP_NAME$ never collide. The same four layers and macros also apply to vast assets, where the effective map is appended to the tag URL (not to inline data: tag URLs, which have no query component) (see VAST (CSAI)).

OTT placement values

Value Placement
0 Single (standard full-screen)
1 Pause screen
3 Picture-in-Picture / double box
4 L-banner
5 Overlay

How pod serving works

When a GAM break is detected in the manifest, the SDK:

  1. Uses the IMA StreamManager (initialized at startSession()) to build a pod manifest URL from the stream ID and pod ID.
  2. Loads that URL into the ad player (preloaded 5 seconds before break start).
  3. Pauses content and plays the ad overlay at break time.
  4. Forwards IMA metadata events for ad tracking (quartile beacons, etc.).

The pod stream carries its ad markers as ID3 timed metadata, and IMA only learns where each ad starts and ends — and only fires its tracking beacons — from the markers the SDK pushes to it. When the pod plays through the content player instead of the ad player (picture-in-picture on iOS and Safari, the shared-element and adaptive insertion modes on iPhone), the SDK pushes that player's markers for the duration of the break, so Google tracking and IMA's ad events continue. On iOS this also keeps the per-ad adbegin/adend expansion of a multi-ad pod; on the web the shared-element path still reports a pod as one ad.

This page describes SGAI (client-side) pod serving, where the player builds the pod URL and composites the ad. The same GAM pod serving can also run server-side via the SSAI Stitcher: the client still creates the DAI stream and tracks, but the server requests the pod and bakes it into the HLS stream (reusing the same pod-URL builder).

AI Assistance

Explain it like I'm 2. The SDK comes with a little robot helper. Type one magic line — npx dolby-ads-init-ai — and the robot drops helper notes inside your code editor. Now when you ask your editor's AI "help me connect my video player," it already knows exactly how. And when something breaks, you click Export Report, paste it to the AI, and the robot tells you what went wrong and how to fix it.

The SDK ships AI integration artifacts so your own IDE assistant (Claude Code, Windsurf, Copilot + AGENTS.md, …) can help you get started, implement a custom PlayerAdapter, and troubleshoot from SDK diagnostics. We ship the knowledge and tools — the LLM is your editor's own assistant. Nothing is sent to Dolby.

What you get

Artifact What it does Where it lives
Onboarding agent Tutor that explains the model step by step, shows where to start, then offers to bootstrap a demo. @dolby-optiview/ads-sdk → ai/agents/dolby-onboarding/AGENT.md
Quickstart skill Collects a few inputs and bootstraps a runnable single-file demo — with or without MCP. @dolby-optiview/ads-sdk → ai/skills/dolby-quickstart-demo/SKILL.md
Adapter skill Bounded instructions to scaffold + validate a PlayerAdapter. @dolby-optiview/ads-sdk → ai/skills/dolby-adapter-integration/SKILL.md
Troubleshooter agent Diagnostic-reasoning instructions for reading a report. @dolby-optiview/ads-sdk → ai/agents/dolby-troubleshooter/AGENT.md
Features overview DAI vs DAR, SGAI vs SSAI, VAST, pre-roll, break formats, adapters. ai/reference/features-overview.md
PlayerAdapter contract Machine-readable interface spec. ai/reference/playeradapter.contract.md
Error codes Generated table of every diagnostic code. ai/reference/error-codes.md
Knowledge base Code → cause → fix mapping. ai/reference/knowledge-base.md
Native overview Orientation for the Android/iOS SDKs and how they map to the web API. ai/reference/native-overview.md
MCP server (optional) Executable troubleshooting + scaffolding tools (@dolby-optiview/ads-sdk-mcp, installed from its artefact-host tarball — see Install). dolby-ads-mcp

Step 1 — Install the artifacts into your project

npx dolby-ads-init-ai            # copies into ./.dolby-ads/ai
npx dolby-ads-init-ai docs/ai    # or a directory you choose
npx dolby-ads-init-ai --force    # overwrite existing files

This copies the skill, agent, and reference files from the installed @dolby-optiview/ads-sdk package into your repo so your AI IDE can pick them up. Point your assistant at the copied folder (e.g. reference it from AGENTS.md, CLAUDE.md, or .github/copilot-instructions.md). Existing files are skipped unless you pass --force.

The same copy logic is exported programmatically as runInitAi(options) from @dolby-optiview/ads-sdk if you prefer to script it.

Step 2 — (Optional) Add the MCP server

The MCP server is optional. The shipped *.md artifacts are sufficient on their own — the MCP server is an accelerator that provides structured tools.

@dolby-optiview/ads-sdk-mcp is a Model Context Protocol stdio server. It runs locally; diagnostics never leave your machine. It is not published to npmjs: install its tarball from the artefact host (see the Install page, Web table) — npm install -g <tarball URL> puts the dolby-ads-mcp binary on your PATH — then register it with your MCP-capable client:

{
  "mcpServers": {
    "dolby-ads": {
      "command": "dolby-ads-mcp"
    }
  }
}

It exposes eight tools:

Tool Input Returns
analyze_diagnostics an exportDiagnostics() report severity tallies, ranked findings with remediation, timeline analysis, and a root-cause hint
lookup_error_code a code like DA-PDT-MISSING (+ the report's sdkVersion) category, severity, summary, remediation — unknown codes return a hint: check the spelling, or upgrade @dolby-optiview/ads-sdk-mcp when the report comes from a newer SDK than the bundled taxonomy snapshot
explain_event_timeline a report or event array the playback (DA-EVENT) sequence, session-level observations, and a per-break breakdown (breaks[]: lifecycle, ad counts, quartiles, anomalies)
validate_break_manifest a break manifest (object or raw JSON string) { valid, errors, warnings } with a JSON path per issue — spec violations the SDK rejects, plus authoring smells (overlapping breaks, unknown enum values, missing companions)
resolve_config a device userAgent plus adPreload / adInsertion / mode (all optional) { devices[], issues[] } — the deviceType, resolvedPreload, and resolvedInsertion that will actually run, with a reason per choice; omit userAgent for the full preset device matrix
scaffold_quickstart manifestUrl, player, contentUrl (+ optional environment, gam, mode, stitcherUrl) browser players: a self-contained index.html demo; React Native players (react-native-theoplayer, react-native-video): drop-in files for an existing new-architecture RN app (OptiViewAdsQuickstart.tsx + OPTIVIEW_ADS_SETUP.md); native players (android-media3, ios-avplayer): OptiViewAdsQuickstart.kt / .swift + OPTIVIEW_ADS_SETUP.md — plus notes and warnings
explain_concept a concept, feature or contract question (+ optional limit) { matches[], relatedCodes[], suggestions[] } — the matching sections of the SDK's conceptual reference verbatim, most relevant first, plus the diagnostic codes worth watching for that concept
decode_cue an in-stream cue: base64/hex SCTE-35, a pasted HLS tag line, a base64 ID3 tag or bare GEOB body, an emsg payload, or type=cue&pts=… (+ optional kind, schemeIdUri, manifestPts) the decoded cue — SCTE-35 command, PTS (pts_adjustment applied, 90 kHz → seconds), break duration, segmentation descriptors and CRC check; or the Anvato frame fields and payload params — plus a ptsCheck against the manifest break start (offset in ms vs the SDK's 5 ms tolerance and the verdict the scheduler would reach)

Step 3 — Bootstrap a demo

New to the SDK? Point your assistant at the onboarding agent (ai/agents/dolby-onboarding/AGENT.md). It walks you through the mental model (content player + PlayerAdapter, the SDK-managed ad overlay, manifest + programDateTime timebase, the session lifecycle, and the diagnostics timeline), shows where to start, then asks if you want to try it. If you say yes, it follows the quickstart skill — which includes a canonical template so it works without the MCP server. If the MCP server is installed, it may call scaffold_quickstart to auto-pin the SDK version. The generated index.html uses ESM CDN imports — open it directly or serve the folder.

You can also try it without an assistant using the Get started card below, which calls scaffold_quickstart fully client-side.

mode picks the insertion topology and defaults to sgai. With mode: 'ssai' the scaffold takes the full stitcherUrl (the stitcher master playlist, https://host/ssai/v1/{orgId}/{channelId}/master.m3u8) and wires startSession({ stitcherUrl, customAssetKey }) with mode: 'ssai' plus gam.networkCode — no break-manifest polling and no ad overlay, and the scaffold deliberately never loads the content itself, because the SDK creates the IMA DAI stream and loads the stitched master into your player. SSAI orchestration is web-only today, so asking for it with a React Native or native player scaffolds SGAI instead and says so in the warnings.

The native players emit a drop-in file for an existing app — a Media3 / ExoPlayer Activity or an AVPlayer UIViewController — plus a setup guide with dependencies, platform requirements, GAM wiring and teardown. The native package coordinates are still preview and not yet published, which the tool warns about.

Step 3b — Ask what a feature actually is

The conceptual reference (features overview, the PlayerAdapter contract, the native and React Native overviews) ships as files inside @dolby-optiview/ads-sdk/ai, so an assistant that only has the MCP server cannot read it. explain_concept embeds a snapshot of those documents and answers questions against it — "what is break chaining", "tune-in", "L-shape", "DAI vs DAR", "SGAI vs SSAI", "what must a custom PlayerAdapter implement", "which host players does React Native support".

Sections come back verbatim (most relevant first, limit defaults to 3), so the answer cannot drift from the docs, and vocabulary that is not a literal heading (chaining, l-shape, stitcher, custom player, DAR, CSAI, kotlin…) resolves through an alias table. Each answer also carries relatedCodes — the diagnostic codes worth watching for that concept, which you can feed straight into lookup_error_code. For a specific DA-* code, use lookup_error_code directly.

Step 3c — Decode an in-stream cue

When a break does not start on a cue-signalled stream, the question is always whether the in-stream cue and the manifest break agree on the media timeline. decode_cue decodes whatever you have in hand and answers it:

  • a SCTE-35 splice_info_section (base64 or hex) — command, the 33-bit PTS with pts_adjustment applied and converted from 90 kHz ticks to seconds, out-of-network / immediate / auto-return flags, break duration, segmentation descriptors (type name, UPID) and the CRC_32 check;
  • a pasted HLS tag line — #EXT-X-DATERANGE:…,SCTE35-OUT=0xFC30… has its binary section extracted and decoded; #EXT-X-CUE-OUT:38.4 carries only a duration, which the tool says rather than failing;
  • an Anvato ID3 GEOB cue, either a whole ID3 tag (hls.js) or the bare GEOB body (Shaka), an emsg identified by its schemeIdUri, or a bare type=cue&pts=1234.567 payload.

Add manifestPts (the break's start, in seconds) and the answer includes the offset in milliseconds against the SDK's 5 ms PTS matching tolerance plus the verdict the scheduler would reach — which is exactly what the DA-ANVATO-CUE-PENDING / -OBSERVED remediations ask you to compare. Malformed blobs come back as warnings, never as an error, and nothing is fetched: the decode is entirely local.

Step 4 — Troubleshoot

  1. Reproduce the issue with the SDK running.
  2. Capture a redacted report: const report = sdk.exportDiagnostics(); (no ad-tag-parameter values or secrets are ever included — see Diagnostics).
  3. Hand the report to your AI assistant ("analyze these OptiView Ads diagnostics") — with the MCP server registered it calls analyze_diagnostics; otherwise the pasted JSON plus the bundled knowledge base is enough.
  4. You get a root cause and concrete fix steps.
  5. If the report looks healthy but the ad behaved oddly on a specific device (a black frame on a CTV, an insertion mode that seems ignored), ask for resolve_config with that device's User-Agent and your adPreload / adInsertion / mode values: auto resolves per device and some explicit values are overridden, so the resolved modes are often the whole story.

You can try the exact same analysis, fully client-side, in the AI Troubleshooting card on the demo player — Export Report, AI Analyze, and Check Adapter.

Step 4b — File a bug report straight from the demo

The demo has a dedicated File a Bug page in the sidebar. As you use the Player page the SDK's redacted exportDiagnostics() report is captured automatically (kept in the tab's sessionStorage); the File a Bug page reads that snapshot, runs the analyze_diagnostics root-cause/findings over it, and lets you enter a title, what happened, and repro steps. Open Jira to file opens a pre-filled Create issue screen for the PLAYG project in a new tab — you review and click Create. It is client-only: no backend and no token, so no secrets ever leave the page. Because URLs are length-bounded, attach the full redacted report with Copy full report / Download JSON when the pre-filled diagnostics are trimmed.

Step 5 — Implement a custom adapter

Ask your assistant to follow the adapter skill, then prove the result with the shared conformance suite (@dolby-optiview/ads-sdk-adapter-test-kit) — see Validate your adapter. The contract the assistant follows is ai/reference/playeradapter.contract.md, mirroring the PlayerAdapter Interface.

Step 6 — Explore and implement features

Your assistant doesn't just explain concepts — it helps you put them into practice. Ask it anything and it will guide you through the relevant code, config, and trade-offs:

  • "Which ad insertion mode should I use?" — it walks you through SGAI (client-scheduled, the default) vs SSAI (server-stitched, single stream) vs DAR (dynamic ad replacement), and helps you pick the right one for your workflow.
  • "How do I add VAST ads?" — it explains how VAST / CSAI tags are fetched and played client-side via Google IMA, which break formats are supported (single, double, lshape_ad), and helps you wire up the IMA SDK.
  • "Can I schedule pre-roll, mid-roll, and post-roll?" — it shows you how break timing works with programDateTime, how the break manifest drives scheduling, and how to configure pre-roll vs mid-roll placement.
  • "What break formats are available?" — it explains single, double, lshape_ad, lshape_content, and overlay formats, their layout rules, and when to use each.
  • "Which player can I use?" — it helps you choose between HLS.js, Shaka, THEOplayer, native HLS (Safari/iOS), or a custom adapter, and can scaffold the integration for you (see Step 5).
  • "What about advanced behaviours?" — it can explain and help you implement tune-in (waiting for a live edge before playing ads), chaining (back-to-back breaks), and overlap suppression (preventing duplicate ad breaks at the same timecode).

The assistant reads ai/reference/features-overview.md for accurate, up-to-date answers — so you can ask in plain language and get SDK-specific guidance, not generic advice.

We intentionally ship knowledge and tools, not an LLM. Your IDE's own assistant does the reasoning, so your code and diagnostics stay with you.

SSAI Stitcher (server-side)

The OptiView Ads SDK supports two ad-insertion topologies:

  • SGAI (client-side, default): the player composites the ad over content using the SDK's insertion modes (overlay / shared-element / adaptive).
  • SSAI (server-side): the @dolby-optiview/ads-sdk-stitcher server bakes the ad into the HLS stream the player receives. The player just plays one stitched stream.

This page summarizes the stitcher. The authoritative contract is services/stitcher/CONTRACT.md; the design overview is docs/ssai-stitcher.md.

There are two SSAI entry points. This page covers explicit SSAI (mode: 'ssai' + startSession({ stitcherUrl }), using the @dolby-optiview/ads-sdk-stitcher service). The break manifest can also steer a session to SSAI via its delivery rules — that path plays the channel's full-service GAM DAI livestream (the gam vendor configuration's assetKey), needs no stitcher service, keeps polling the manifest and still renders event-triggered breaks (pause ads) client-side. See Delivery steering on the Break Manifest page. An explicit constructor mode always overrides manifest steering.
AirPlay: when the channel's manifest also carries a server-side beaconing (ssb) stream, a manifest-steered SSAI session follows the same AirPlay flow as SGAI: the SDK plays the ssb stream on the receiver while AirPlay is active (deliveryMode: 'ssb') and reopens the stitched stream when AirPlay stops, falling back to sgai when the stitched stream is unavailable. See Server-side beaconing stream (ssb) and the AirPlay guard on the Break Manifest page.

When to use SSAI

  • Devices/players where client-side compositing is hard or undesirable.
  • You want ads baked in at the CDN/edge and a thin client.
  • You only need fullscreen linear ads — SSAI always stitches a fullscreen single ad. By default it also stitches double and lshape_ad as fullscreen single (companion dropped); lshape_content and overlay need client compositing and are never stitched. See Supported formats below.

How it works (hybrid DAI)

The stitcher is a stateless HLS manifest transform — it rewrites playlists and references ad-segment URLs; it never proxies video bytes.

  1. The client creates the Google DAI stream (IMA PodStreamRequest) and gets a streamId, then plays the stitcher's master URL. The client's IMA SDK does ad tracking by reading the timed metadata the stitcher leaves in the stitched segments.
  2. The stitcher owns the break manifest (fetched server-side) and the content origin (per-channel preconfigured). For each eligible break it snaps to a segment boundary, builds the DAI pod URL with the same buildGamPodUrl the client SDKs use (passing the client's streamId), and splices the pod's segments in — wrapped in EXT-X-DISCONTINUITY.

Supported formats

Format Stitched?
single Always — fullscreen ad.
double By default (companion dropped). Disable with stitchCompositedAsSingle: false.
lshape_ad By default (companion dropped). Disable with stitchCompositedAsSingle: false.
lshape_content Never (backdrop image, no fullscreen ad video).
overlay Never (content keeps playing; needs client compositing).

stitchCompositedAsSingle is a per-channel server setting (server-wide default true), not a client/URL parameter. double and lshape_ad both carry a real fullscreen ad video, so they degrade cleanly to a fullscreen single splice with the companion discarded.

URL contract (summary)

GET /ssai/v1/{orgId}/{channelId}/master.m3u8?stream_id={sid}&max_bitrate={bps}
# (the stitcher's own route shape — the SDK takes the finished master URL as
#  startSession({ stitcherUrl }) and only appends stream_id/max_bitrate)
GET /ssai/v1/{orgId}/{channelId}/media/{variantId}.m3u8?stream_id={sid}
  • stream_id — the DAI session token from the client's IMA stream (required for gam breaks; absent → those breaks are skipped).
  • max_bitrate — optional (bits/sec, master only). Drops master variants whose BANDWIDTH exceeds it; fail-open keeps the lowest variant if none qualify.

Boundary snap policy

Breaks rarely line up exactly with a segment boundary, so the stitcher snaps each break to one according to a per-channel snapPolicy (server default nearest):

Policy Behavior
start Boundary at or before the break start (round down).
end Boundary at or after the break start (round up).
nearest Closest boundary; ties round down.

Resulting timing skew is at most one segment. It is an operator/per-channel setting, not a client/URL parameter.

Guarantees

  • Fail-open: if the break manifest, pod, or parameters are unusable, the player receives the unmodified content — playback never breaks.
  • Timebase: pts / mediatime (cumulative EXTINF) and wallclock (EXT-X-PROGRAM-DATE-TIME) are all supported.
  • Ad duration: the pod is trimmed to the break duration (whole-segment) and never overshoots into content.

Client SDK integration (SSAI mode)

Set mode: 'ssai' on the SDK config. In this mode the SDK does not poll a break manifest, schedule breaks, or run an ad-player overlay. Instead it creates the IMA DAI stream, builds the stitcher master URL, loads it into the content player, forwards in-stream timedmetadata to IMA, and re-emits the normal SDK ad-event stream.

import { OptiViewAds } from '@dolby-optiview/ads-sdk-core';
import { HlsJsAdapter } from '@dolby-optiview/ads-sdk-adapter-hlsjs';

const sdk = new OptiViewAds({
  mode: 'ssai',
  player: new HlsJsAdapter(hls, video), // must expose a videoElement (IMA binds to it)
  gam: { networkCode: '23285652104' },
  maxBitrate: 2000000, // optional → max_bitrate on the master URL (caps rendition bitrate)
  autoplay: true, // optional → SDK plays the stitched stream after load
});

// No content URL load by the app: startSession loads the stitched master itself.
// stitcherUrl is the stitcher's master-playlist route for this channel; the SDK
// appends stream_id (and max_bitrate) to it and never composes the path itself.
await sdk.startSession({
  stitcherUrl: 'https://stitch.example.com/ssai/v1/your-org/your-channel/master.m3u8',
  customAssetKey: 'asset-key',
});

Requirements and notes:

  • The content PlayerAdapter must expose videoElement (IMA DAI binds to a real <video>). HLS.js, Shaka, and the native-video adapter qualify.
  • mode: 'ssai' requires gam.networkCode; startSession requires stitcherUrl (the full master-playlist URL, in place of manifestUrl) and customAssetKey. The demo composes that URL from its Stitcher Base URL field plus the org/channel pickers.
  • customAssetKey/assetParameters come from startSession for explicit SSAI. Manifest-steered SSAI also takes ssai[0].assetParameters as the manifest session layer. The precedence is session < update < manifest; a manifest parameter cannot be overridden by updateAssetParameters().
  • Failures surface as DA-SSAI-SESSION-FAILED (startup) and DA-SSAI-IMA-ERROR (in-stream); ad lifecycle is emitted as the usual adbreakbegin / adbegin / quartiles / adend / adbreakend events.

Parity: the portable buildStitcherMasterUrl is locked across the TS, Kotlin, and Swift cores by the conformance harness. The SSAI orchestration (SsaiController) is currently web-only and tracked as a parity gap for the native cores (conformance/PENDING-PARITY.md).

Trying it in this demo

The demo's SDK Config card has an Ad Insertion Architecture toggle. The Session card (Org ID, Channel ID, Custom Asset Key, Content URL, Ad Tag Parameters) is shared by both modes. Pick SSAI (stitched) to reveal the SSAI Stitcher (dev) card, then:

  1. Click Start Stitcher — a Vite dev middleware spawns a local @dolby-optiview/ads-sdk-stitcher configured with a single channel built from the Org ID, Channel ID, GAM Network Code, and the Stitcher Origin URL (which defaults to the Session Content URL but can be set independently — some operators ingest a different origin for SSAI). The Stitcher Base URL is filled in for you.
  2. (optional) Set Max Bitrate to cap the rendition bitrate — the stitcher drops higher variants from the master playlist.
  3. Click Load — the SDK creates the IMA stream, loads the stitched master, and (with Autoplay on) plays it.
  4. Click Stop Stitcher when done to shut the dev server down.

Break Manifest Server

The @dolby-optiview/ads-sdk-break-manifest-server package provides a standalone, lightweight server that stores and serves static break manifests. It exposes a production-compatible URL schema so the SDK can poll manifests from it without modification.

Use Cases

  • Local development — test ad breaks without depending on the production API.
  • Demo / QA — reproduce specific break schedules with known manifests.
  • Integration tests — programmatically create and tear down manifest endpoints.

Quick Start

# Start the server with your org ID
npx dolby-ads-manifest-server --org-id <your-org-id> --port 4100

The server is now running at http://localhost:4100.

API

The URL schema mirrors the production OptiView Ads manifest API:

/manifest/v1/{org-id}/channels/{channel-id}

POST /manifest/v1/:orgId/channels

Create a new manifest endpoint.

Body: a valid BreakManifest JSON object (see the manifest spec).

Response (201):

{
  "channelId": "d7803a87-465a-4e43-b12e-6f479be119a1",
  "url": "http://localhost:4100/manifest/v1/0bda787b.../channels/d7803a87..."
}

The returned url can be used directly as the SDK manifest URL.

GET /manifest/v1/:orgId/channels/:channelId

Retrieve a stored break manifest. This is the URL the SDK polls.

GET /manifest/v1/:orgId/channels

List all stored channel IDs and their URLs.

DELETE /manifest/v1/:orgId/channels/:channelId

Remove a stored manifest endpoint.

GET /version

Returns the SDK version: { "version": "0.17.0" }.

CLI Options

Option Env var Default Description
--org-id ORG_ID — Required. The org ID to serve.
--port PORT 4100 Port to listen on.

Demo Page Integration

The demo page includes a Manifests section in the sidebar that provides a UI for managing manifest endpoints:

  1. Enter the server base URL and org ID.
  2. Click Start Server to launch the server via the Vite dev proxy.
  3. Paste a break manifest JSON and click Create Endpoint.
  4. The created URL is displayed and can be used in the player configuration.
  5. Existing endpoints are listed with delete buttons.

Programmatic Use

import { createBreakManifestApp } from '@dolby-optiview/ads-sdk-break-manifest-server';

const app = createBreakManifestApp({
  port: 4100,
});

app.listen(4100);

Installing the SDK

Public distribution

Releases use the OptiView name and a lockstep version. Web and Android packages publish to npm and THEOplayer Maven; iOS / tvOS SwiftPM uses binary targets from the published xcframeworks, CocoaPods uses the public-read THEOplayer Specs repo, and the Roku component is published as a signed component-library package:

Platform Registry Coordinates
Web npm (npmjs.com) npm install @dolby-optiview/ads-sdk hls.js — plus @dolby-optiview/ads-sdk-core and @dolby-optiview/ads-sdk-adapter-{hlsjs,shaka,theoplayer}. The adapter test kit and the MCP server are not on npmjs; install them from the artefact host tarballs below.
Android / Android TV THEOplayer Maven implementation("com.dolby.optiview:ads-sdk-runtime:1.6.0-dev.2628") — plus ads-sdk, ads-sdk-core, ads-sdk-adapter-theoplayer, ads-sdk-adapter-test-kit, ads-sdk-react-bridge
iOS / tvOS Swift Package Manager .binaryTarget(url:checksum:) per xcframework — see iOS / tvOS (Swift Package Manager) below — products OptiViewAdsRuntime / OptiViewAdsSDK / OptiViewAdsCore / OptiViewAdsReactBridge / OptiViewAdsAdapterTHEOplayer / OptiViewAdsAdapterTestKit (test targets only)
iOS / tvOS CocoaPods (public-read THEOplayer Specs repo) pods OptiViewAdsRuntime / OptiViewAdsSDK / OptiViewAdsCore / OptiViewAdsReactBridge / OptiViewAdsAdapterTHEOplayer / OptiViewAdsAdapterTestKit (test) — see the Podfile snippet below
Roku Signed component-library package (artefact host) optiview-ads-roku-1.6.0-dev.2628.pkg, loaded with a ComponentLibrary node, or the ZIP archive of the same files — see Roku (signed .pkg) below

Android (Gradle). Add the public THEOplayer Maven repository to settings.gradle.kts, keeping Google and Maven Central for third-party libraries:

dependencyResolutionManagement {
    repositories {
        maven { url = uri("https://maven.theoplayer.com/releases") }
        google()
        mavenCentral()
    }
}

In the app module's dependencies, add implementation("com.dolby.optiview:ads-sdk-runtime:<version>"), replacing <version> with the exact stable release. This also resolves ads-sdk and ads-sdk-core. The app needs JDK 17, compileSdk 34 or newer, and android.useAndroidX=true.

Develop/custom builds do not go to the THEOplayer repository; use the unchanged artifact-host Android flow below.

CocoaPods. The same binary xcframeworks are also published as pods to the publicly readable THEOplayer Specs repo (never CocoaPods trunk). Add it as a source next to the default CDN (which still serves the Google IMA dependency pods), then depend on the layer you want — OptiViewAdsRuntime pulls OptiViewAdsSDK, OptiViewAdsCore and the per-platform Google IMA pods automatically:
source 'https://github.com/THEOplayer/cocoapods-specs.git'
source 'https://github.com/Dolby-OptiView/cocoapods-specs.git'  # the Lens SDK pods
source 'https://cdn.cocoapods.org/'

target 'MyApp' do
  pod 'OptiViewAdsRuntime', '1.6.0-dev.2628'
end
Lens observability dependency. The SDK reports through the OptiView Lens SDK on every platform (always on, no configuration — see Diagnostics). On web, @dolby-optiview/ads-sdk-core declares the public @dolby-optiview/lens-sdk package as a peer dependency, pinned to the supported version 0.7.0; npm 7+ installs it for you from the public registry (with Yarn classic, pnpm without auto-installed peers, or --legacy-peer-deps, add @dolby-optiview/lens-sdk@0.7.0 yourself), and an app that also uses another Lens-based SDK shares that one copy. On Android, the SDK depends on the public com.dolby.optiview:lens-sdk and lens-sdk-context 0.7.0 from https://maven.theoplayer.com/releases (the repository the SDK is published to), so Gradle resolves one Lens copy shared with other Lens-based SDKs. On iOS/tvOS, the SDK links the public Lens framework (optiview-lens-sdk-swift 0.7.0, pod OptiViewLensSDK) without embedding it: SwiftPM resolves it automatically, and CocoaPods needs the https://github.com/Dolby-OptiView/cocoapods-specs.git source shown above. Lens requires Xcode 26.2 or newer. If you depend on Lens directly, use the same version. None of this needs private credentials.

The published packages are byte-identical to the artefacts below — the names (@dolby-optiview/ads-sdk*, com.dolby.optiview:ads-sdk*) are the same on the public registries and on the artefact host.

Artefact host

Direct distribution. Every build (including develop dev builds — versioned X.Y.Z-dev.N — and custom-branch builds, which never reach the public registries) is also hosted on the artefact host (https://ads-sdk.xagget.prudentgiraffe.com, one immutable <platform>/<branch>/<version>/ prefix per build) so you can install it with the standard package managers straight from an HTTP endpoint. Versions track the SDK release shown in the sidebar.

Web (npm)

Each web package — the SDK core, the entry SDK, the player adapters, and the AI helpers — is published as an npm pack tarball under /web/develop/1.6.0-dev.2628/. npm installs directly from a tarball URL, so no private registry is required:

# Entry SDK (defaults the ad player to HLS.js) + the HLS.js peer
npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-sdk-1.6.0-dev.2628.tgz hls.js

The internal @dolby-optiview/ads-sdk* dependencies inside each tarball are rewritten to point at the matching tarball URLs on the same version prefix, so npm resolves the whole graph from the domain automatically — you only install the package you need.

Available packages:

Package Install
@dolby-optiview/ads-sdk npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-sdk-1.6.0-dev.2628.tgz
@dolby-optiview/ads-sdk-core npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-core-1.6.0-dev.2628.tgz
@dolby-optiview/ads-sdk-adapter-hlsjs npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-adapter-hlsjs-1.6.0-dev.2628.tgz
@dolby-optiview/ads-sdk-adapter-shaka npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-adapter-shaka-1.6.0-dev.2628.tgz
@dolby-optiview/ads-sdk-adapter-theoplayer npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-adapter-theoplayer-1.6.0-dev.2628.tgz
@dolby-optiview/ads-sdk-adapter-test-kit npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-adapter-test-kit-1.6.0-dev.2628.tgz
@dolby-optiview/ads-sdk-mcp (AI helpers) npm install https://ads-sdk.xagget.prudentgiraffe.com/web/develop/1.6.0-dev.2628/dolby-ads-mcp-1.6.0-dev.2628.tgz

To pin a version, swap 1.6.0-dev.2628 for the version you want; the browsable index at /web/develop/1.6.0-dev.2628/ lists every tarball with its SHA-256, and manifest.json is the machine-readable index (versions, URLs, checksums, npm integrity hashes).

Bundler required. The web packages are ESM browser libraries (the same modules the demo consumes). Use them through a bundler (Vite, webpack, Rollup, esbuild, …) — they are not intended to be loaded directly by Node.

After installing, usage is identical to the registry flow — see Getting Started:

import Hls from 'hls.js';
import { OptiViewAds, HlsJsAdapter } from '@dolby-optiview/ads-sdk';

Android (Gradle)

The Android modules are published as a static Maven repository under /android/develop/1.6.0-dev.2628/ (group com.dolby.optiview). Add the repository, then the dependencies:

// settings.gradle.kts — dependencyResolutionManagement { repositories { … } }
maven { url = uri("https://ads-sdk.xagget.prudentgiraffe.com/android/develop/1.6.0-dev.2628") }
maven { url = uri("https://maven.theoplayer.com/releases") } // the public Lens SDK the Ads SDK depends on
google()
mavenCentral()
// app/build.gradle.kts — dependencies { … }
implementation("com.dolby.optiview:ads-sdk-runtime:1.6.0-dev.2628") // Android runtime (Media3/ExoPlayer + IMA)
// ads-sdk (orchestrator) and ads-sdk-core (portable brain) resolve transitively.
# gradle.properties — REQUIRED
# ads-sdk-runtime pulls in Media3, which is AndroidX. Without this the build fails
# at `checkDebugAarMetadata` ("contains AndroidX dependencies, but the
# android.useAndroidX property is not enabled").
android.useAndroidX=true

The consuming app needs JDK 17 and compileSdk 34 or newer.

Artifact Coordinate
Android runtime (ExoPlayer adapter, overlay renderer, GAM/IMA DAI) com.dolby.optiview:ads-sdk-runtime:1.6.0-dev.2628
Player-agnostic orchestrator com.dolby.optiview:ads-sdk:1.6.0-dev.2628
Portable brain com.dolby.optiview:ads-sdk-core:1.6.0-dev.2628
PlayerAdapter conformance kit (test) com.dolby.optiview:ads-sdk-adapter-test-kit:1.6.0-dev.2628
THEOplayer PlayerAdapter (host app provides THEOplayer Android SDK) com.dolby.optiview:ads-sdk-adapter-theoplayer:1.6.0-dev.2628
React Native bridge core (pulled by the RN package) com.dolby.optiview:ads-sdk-react-bridge:1.6.0-dev.2628

Transitive third-party deps (Media3, IMA, kotlinx-coroutines) resolve from google() / mavenCentral() as usual. Sources jars are published alongside each artifact. The repo's POMs reference the sibling com.dolby.optiview:ads-sdk* modules, so adding the one maven { … } repository resolves the whole graph. Browse /android/develop/1.6.0-dev.2628/.

iOS / tvOS (Swift Package Manager)

The Apple modules are published as zipped binary .xcframeworks under /ios/develop/1.6.0-dev.2628/, consumed via SwiftPM .binaryTarget(url:checksum:). Each is its own dynamic module, so add the layer you want plus the xcframeworks it depends on:

xcframework Layer Also add
OptiViewAdsRuntime.xcframework.zip AVPlayer adapter + UIKit overlay OptiViewAdsSDK + OptiViewAdsCore + the Google IMA package (…-ima-ads-ios for iOS, …-ima-ads-tvos for tvOS)
OptiViewAdsSDK.xcframework.zip Player-agnostic orchestrator OptiViewAdsCore
OptiViewAdsCore.xcframework.zip Portable brain — (standalone)
OptiViewAdsAdapterTHEOplayer.xcframework.zip THEOplayer PlayerAdapter OptiViewAdsCore + theoplayer-sdk-apple ≥ 11.15.0, products THEOplayerSDK and THEOplayerTHEOliveIntegration
OptiViewAdsReactBridge.xcframework.zip React Native bridge core OptiViewAdsSDK + OptiViewAdsCore
OptiViewAdsAdapterTestKit.xcframework.zip PlayerAdapter conformance suite (test) OptiViewAdsCore; test targets only
// Package.swift — full native runtime (AVPlayer + IMA)
dependencies: [
    // IMA ships per-platform — add the package(s) for the platforms you build for:
    .package(url: "https://github.com/googleads/swift-package-manager-google-interactive-media-ads-ios", from: "3.18.4"),
    .package(url: "https://github.com/googleads/swift-package-manager-google-interactive-media-ads-tvos", from: "4.2.0"),
],
targets: [
    .binaryTarget(name: "OptiViewAdsCore",
        url: "https://ads-sdk.xagget.prudentgiraffe.com/ios/develop/1.6.0-dev.2628/OptiViewAdsCore.xcframework.zip",
        checksum: "<see manifest.json>"),
    .binaryTarget(name: "OptiViewAdsSDK",
        url: "https://ads-sdk.xagget.prudentgiraffe.com/ios/develop/1.6.0-dev.2628/OptiViewAdsSDK.xcframework.zip",
        checksum: "<see manifest.json>"),
    .binaryTarget(name: "OptiViewAdsRuntime",
        url: "https://ads-sdk.xagget.prudentgiraffe.com/ios/develop/1.6.0-dev.2628/OptiViewAdsRuntime.xcframework.zip",
        checksum: "<see manifest.json>"),
    .target(name: "App", dependencies: [
        "OptiViewAdsRuntime", "OptiViewAdsSDK", "OptiViewAdsCore",
        .product(name: "GoogleInteractiveMediaAds", package: "swift-package-manager-google-interactive-media-ads-ios",
                 condition: .when(platforms: [.iOS])),
        .product(name: "GoogleInteractiveMediaAdsTvOS", package: "swift-package-manager-google-interactive-media-ads-tvos",
                 condition: .when(platforms: [.tvOS])),
    ]),
]
// Orchestrator only: OptiViewAdsSDK + OptiViewAdsCore.   Brain only: OptiViewAdsCore.
// THEOplayer adapter: OptiViewAdsAdapterTHEOplayer + OptiViewAdsCore, plus the theoplayer-sdk-apple package (products THEOplayerSDK and THEOplayerTHEOliveIntegration).
// Adapter test kit (test targets only): OptiViewAdsAdapterTestKit + OptiViewAdsCore.

Each release's exact url + SHA-256 checksum for every product is in manifest.json (mirrored as a copy-paste snippet at /ios/develop/1.6.0-dev.2628/) — paste each checksum into its .binaryTarget. Slices: iOS + tvOS, device and simulator — the same zips serve iPhone/iPad and Apple TV apps; SwiftPM picks the right slice from your target's platform.

React Native (npm tarball)

The React Native package is a pure-JavaScript npm tarball published under /react-native/develop/1.6.0-dev.2628/:

npm install https://ads-sdk.xagget.prudentgiraffe.com/react-native/develop/1.6.0-dev.2628/dolby-optiview-ads-sdk-react-native-1.6.0-dev.2628.tgz

The tarball includes the TypeScript/JavaScript facade and the native bridge sources, but not the native OptiView Ads binaries or host-player SDKs. Add the native prerequisites for the platform and host player you use:

  • Android: register both the OptiView Ads Maven repository and THEOplayer's Maven repository. For a plain Android app, use the settings.gradle.kts dependencyResolutionManagement form shown in the Android section above. For a React Native app, add the repositories to the root android/build.gradle project's allprojects block instead:

    allprojects {
        repositories {
            maven {
                url "https://ads-sdk.xagget.prudentgiraffe.com/android/develop/1.6.0-dev.2628"
                content {
                    includeModuleByRegex "com\\.dolby\\.optiview", "ads-sdk(-.*)?"
                }
            }
            maven { url "https://maven.theoplayer.com/releases" }
            google()
            mavenCentral()
        }
    }

    For tagged stable Android releases, omit the versioned artifact-host entry: the THEOplayer /releases repository above serves the same Ads coordinates.

    React Native's Gradle plugin populates project-level repositories, so a settings-level repository can be ignored during React Native dependency resolution. If the Dolby repository is only registered in settings.gradle.kts, the build can fail with Could not find com.dolby.optiview:.... Keep the content filter: without it, Gradle may probe this static repository for unrelated dependencies and receive 403 Forbidden, which can prevent fallback to the repositories that own them. The app also needs Java 17, desugaring, and the native OptiView Ads artifacts. react-native-theoplayer is optional; react-native-video v6 uses the bridge's Media3 lookup without a compile-time dependency on that package.

  • iOS: add the OptiViewAdsReactNative pod through React Native autolinking. Its podspec can declare the native OptiView Ads pods it needs — OptiViewAdsRuntime

    • OptiViewAdsReactBridge (and, only when the app also ships react-native-theoplayer, OptiViewAdsAdapterTHEOplayer) — so pod install pulls them (and transitively OptiViewAdsSDK / OptiViewAdsCore / Google IMA) from the THEOplayer Specs repo automatically; no host-side SwiftPM/Xcode wiring of the OptiView Ads packages is required. Opt-in for now: those pod dependencies activate only with OPTIVIEW_ADS_NATIVE_PODS=1 in the pod install environment, until the pods are published to the Specs repo (first release after PUBLISH_COCOAPODS_ENABLED goes live — without a resolvable source the dependency would fail every pod install). With the gate on, the host Podfile only needs the Specs-repo source line (next to the default CDN — see the CocoaPods snippet above). react-native-video v6 needs no THEOplayer package; when using react-native-theoplayer, add its normal pod dependencies as usual. The podspec supports iOS/tvOS 15.1 or newer. Autolinking (from the installed npm package) is the only supported CocoaPods path — installing the pod straight from the git repository (pod 'OptiViewAdsReactNative', :git => …) is not supported.
  • Both platforms: use React Native 0.76 or newer with the new architecture enabled (TurboModules + Fabric), and install at least one supported host player: react-native-theoplayer or react-native-video v6.

Roku (signed .pkg)

The Roku OptiViewAds SceneGraph component is published as a signed Roku component-library package, optiview-ads-roku-1.6.0-dev.2628.pkg, under /roku/develop/1.6.0-dev.2628/ (products[1] in manifest.json, with its SHA-256 and the SHA-256 of the ZIP it was signed from). Download it, compare its SHA-256 and add it to your channel:

curl -fLO https://ads-sdk.xagget.prudentgiraffe.com/roku/develop/1.6.0-dev.2628/optiview-ads-roku-1.6.0-dev.2628.pkg
shasum -a 256 optiview-ads-roku-1.6.0-dev.2628.pkg
cp optiview-ads-roku-1.6.0-dev.2628.pkg <your-channel-root>/components/OptiViewAds.pkg

Load it with a ComponentLibrary node; once its loadStatus is ready, create components as OptiViewAds:OptiViewAds:

<ComponentLibrary id="OptiViewAds" uri="pkg:/components/OptiViewAds.pkg" />

Declare the Roku libraries the SDK needs in the channel manifest:

bs_libs_required=googleima3,roku_ads_lib

The component inserts ads into clear live HLS streams that carry EXT-X-PROGRAM-DATE-TIME, through one application-owned Video node. DRM, VOD, low-latency HLS, pre-rolls, post-rolls and pause ads are not supported. Continue with Roku for integration. The browsable index at /roku/develop/1.6.0-dev.2628/ repeats the downloads, checksums and channel manifest line.

Roku (ZIP)

The same build is also published as a ZIP archive, optiview-ads-roku-1.6.0-dev.2628.zip, in the same prefix (products[0] in manifest.json). Use it when you prefer to compile the SDK into your channel instead of loading the package:

curl -fLO https://ads-sdk.xagget.prudentgiraffe.com/roku/develop/1.6.0-dev.2628/optiview-ads-roku-1.6.0-dev.2628.zip
shasum -a 256 optiview-ads-roku-1.6.0-dev.2628.zip
unzip optiview-ads-roku-1.6.0-dev.2628.zip -d <your-channel-root>

The archive is a component library, not a sideloadable channel. It adds components/OptiViewAds/, the Google IMA task under components/Player/, its BrightScript helpers under source/ and the manifest verification keys under manifest-keys/; keep your own files out of those paths. Components are then created as OptiViewAds, and the channel manifest needs the same bs_libs_required line as for the package.

Hosted services (SSAI stitcher + break-manifest server)

Two backend services run on the demo domain behind Traefik, routed by path prefix — useful for trying SGAI/SSAI without standing up your own:

Service Base URL Purpose
Break-manifest server (SGAI) https://ads-sdk.xnappet.live/manifest/v1/<orgId>/channels Store/serve break manifests; POST returns a channel url the SDK polls.
SSAI stitcher https://ads-sdk.xnappet.live/ssai/v1/<orgId>/<channelId>/master.m3u8 Server-side stitched HLS for configured channels.
# Store a break manifest, then poll the returned channel URL from the SDK
curl -X POST https://ads-sdk.xnappet.live/manifest/v1/<orgId>/channels \
  -H 'Content-Type: application/json' --data @manifest.json
# → { "channelId": "…", "url": "https://ads-sdk.xnappet.live/manifest/v1/<orgId>/channels/…" }

Both are Node/Express apps (@dolby-optiview/ads-sdk-stitcher, @dolby-optiview/ads-sdk-break-manifest-server) shipped as Docker containers; their compose + Traefik config live on the server under /srv/dolby-ads-config/ (canonical copy in the repo at deploy/services/).

VAST (CSAI)

The SDK can play VAST ad creatives client-side (CSAI — Client-Side Ad Insertion). A break asset of type vast carries a VAST ad-tag URL; the SDK fetches, parses, and renders it through the Google IMA SDK (ima3.js on web, the IMA Android/iOS SDKs on native) inside the SDK's overlay ad surface. This is the same IMA used for GAM DAI, but the client-side path (IMAAdsLoader / AdsRequest(adTagUrl:)) rather than the DAI pod-serving stream path.

VAST is SGAI-only — never SSAI. VAST assets are only honoured in client-side (SGAI) sessions. In a server-side (SSAI) session the server stitches the ad break and the client never reads the break manifest, so a vast asset there is rejected with a DA-VAST-SSAI-UNSUPPORTED diagnostic.

Supported formats (linear-only)

VAST describes a linear ad, so vast assets are only valid in the linear break formats. Non-linear placements are rejected (the creative would have nowhere to render as a linear ad):

Break format VAST asset?
single ✅ supported
double ✅ supported (ad + companion)
lshape_ad ✅ supported (ad + companion)
lshape_content ❌ rejected — DA-VAST-UNSUPPORTED-FORMAT
overlay ❌ rejected — DA-VAST-UNSUPPORTED-FORMAT

The format/SSAI guard (resolveVastAdmission) is part of the portable brain and is identical across the Web, Android, and iOS cores.

Asset shape

A vast asset sets type: "vast" and points uri at a VAST ad-tag URL. The response is XML, so mimeType is application/xml (or text/xml):

{
  "id": "ad-vast",
  "type": "vast",
  "mediaType": "video",
  "mimeType": "application/xml",
  "uri": "https://your-ad-server.example/vast?..."
}

See the full schema in the manifest spec.

Asset parameters on the tag URL

Since Break Manifest 1.4.0 a vast asset may carry assetParameters. The SDK merges them with SessionConfig.assetParameters, updateAssetParameters(), updateAssetParameterMacros(), and the manifest session layer (same per-key precedence as GAM), substitutes $MACRO$ values (see SessionConfig.assetParameterMacros on the Session page) and appends the result to the tag URL as query parameters — except inline data: tag URLs, which have no query component. Keys are sorted, encodeURIComponent-encoded, and inserted before any #fragment. The preloaded and the played tag URL are built the same way, so a warm tag stays reusable.

{
  "id": "ad-vast",
  "type": "vast",
  "mediaType": "video",
  "uri": "https://your-ad-server.example/vast?slot=preroll",
  "assetParameters": {
    "ua": "$OPTIVIEW_USER_AGENT$",
    "player_width": "$OPTIVIEW_PLAYER_WIDTH$",
    "player_height": "$OPTIVIEW_PLAYER_HEIGHT$",
    "pod_duration": "$OPTIVIEW_BREAK_DURATION_SECONDS$",
    "pub_macro": "$PUBLISHER_ID$"
  }
}

requests …/vast?slot=preroll&player_height=360&player_width=640&pod_duration=30&pub_macro=%24PUBLISHER_ID%24&ua=Mozilla%2F5.0… — the unknown non-OptiView $PUBLISHER_ID$ travels literally for the ad server to expand without a diagnostic, whereas an unknown $OPTIVIEW_* value is sent with its literal token and raises DA-ASSET-MACRO-UNKNOWN. A string macro value replaces its token. "", null, or a registered callback result of undefined omits the parameter, or only the affected pair of any value containing a literal &. An undefined map entry is not registered; an update entry of undefined unregisters it. An unresolved core-table value leaves the token literal and still sends the parameter. Empty omissions raise DA-ASSET-PARAMETER-OMITTED. A $ without a closing $ is left unchanged, and $APP$ and $APP_NAME$ never collide.

Preloading

VAST tags are resolved through IMA at break time. As with other ad assets, the SDK preloads against the next scheduled break per the manifest polling intervals. The web core uses a two-phase IMA lifecycle:

  1. VastAdManager.preloadVast(adTagUrl, options) runs when the break approaches (PRELOAD_AHEAD_SECONDS = 8). It fetches and parses the VAST tag and creates the IMA AdsManager, but does not start playback.
  2. VastAdManager.startPreloaded() runs at break start. Before it starts the held AdsManager, it calls resize() to re-read the ad <video> element's dimensions against the layout that is now applied (double / lshape_ad box, etc.). This corrects the slot size that preloadVast captured at arming time, before the box was laid out, preventing the ad from rendering too large or too small for its container.

If preload is skipped or fails, playVastAsset() requests the tag at break start. A single break uses the one-shot playVast() path, which still stamps the ad element to fill its box before IMA reads the dimensions. A double or lshape_ad break loads the tag first and starts it once it has loaded, as below.

In double and lshape_ad breaks the content moves into its box only once the VAST ad has loaded. A preloaded tag has loaded at break start, so the content moves at once. A tag that was not preloaded is requested while the content stays full screen, with its sound. When it loads, the box layout, the companion and the double-box mute apply, then the ad starts. When the request fails, nothing on screen changes. The SDK reports the wait as DA-BREAK-LAYOUT-DEFERRED, with outcome applied or skipped. The same applies on Android and iOS.

Error handling

VAST failures are non-fatal — content always recovers. On any of the following the SDK raises an aderror event and emits a coded diagnostic, then resumes content. A double or lshape_ad break whose tag fails before the ad loaded leaves the content full screen: no box animation, companion or ad surface. When the break goes on with another ad or the slate, the layout applies as that one starts:

Diagnostic When
DA-VAST-UNSUPPORTED-FORMAT vast asset in a non-linear break (overlay/lshape_content).
DA-VAST-SSAI-UNSUPPORTED vast asset in a server-side (SSAI) session.
DA-VAST-IMA-SDK-MISSING The IMA SDK (ima3.js / native IMA) is not available.
DA-VAST-IMA-ERROR IMA reported a load/parse/playback error for the tag.

Try it in the demo

The demo ships a dedicated VAST page (sidebar → VAST) that plays a sample VAST tag whose creative is the OptiView sample ad as an MP4 (no credentials) via Google IMA. The tag and MP4 are served from a public HTTPS host with CORS, not the demo origin: IMA fetches the tag cross-origin from its SDK iframe, and an HTTPS (secure-context) host also avoids Chrome's Private Network Access block that an HTTP-localhost page hits when an insecure IMA iframe tries to fetch a loopback resource. The creative is an MP4 (not HLS) because the IMA HTML5 SDK has no HLS engine — it plays the chosen MediaFile through the browser's native <video>, so an HLS-only creative fails off-Safari with VAST_LINEAR_ASSET_MISMATCH (VAST 403); MP4 plays in Chrome, Safari, and the rest:

  1. Open the VAST page (sidebar → VAST).
  2. Pick a content player (HLS.js / Shaka / THEOplayer / Native HLS) and an ad experience — the formats are limited to the VAST-admissible linear ones (single / double / lshape_ad).
  3. Choose Pre-roll (optionally Delayed 5 s) and/or Mid-roll (at least one). On the deployed demo the hosted manifest server (same origin, /manifest/v1) is used automatically; running locally (npm run dev) spins up the local manifest server for you.
  4. Click Run VAST demo. The page creates the break channel, starts an SGAI (CSAI) session, and IMA fetches/parses/plays the VAST creative at the selected break(s); the event log shows the adbreakbegin / adbegin / adbreakend flow.

You can also create a VAST channel manually from the Manifests page: choose the VAST — CSAI (IMA sample tag) preset, Create Manifest Endpoint, then play it on the Player page with the returned Org ID / Channel ID.

The VAST page (and index.html) loads the client-side IMA loader (ima3.js), so CSAI VAST plays out of the box on the dev server (npm run dev).

Pause ads

A pause ad is a full-screen image or video shown while the viewer pauses content playback, and dismissed when playback resumes. Unlike timebase-scheduled breaks, it is event-triggered: the SDK listens for the content player's pause event (via the PlayerAdapter) and renders the creative over the paused video; the player's playing event (resume) removes it. A video creative plays muted, once, and holds its last frame.

A pause ad never shows over another ad. A pause while an ad break plays (any format except overlay) does nothing, and a break that starts after a pause cancels a pause ad still waiting on its start.delay and hides one already shown (DA-PAUSE-AD-DISMISSED, reason break). Pauses the SDK makes itself (holding content for an immediate pre-roll) and pauses before content first played are ignored too.

It is signalled in the break manifest with an event-triggered start: start: { "type": "event", "event": "pause" }. The variant uses a standard format (single); the creative is the first image or video asset of the first variant that qualifies for the device.

Breaking change. The legacy form (position: "pause", break-level delay as the pause delay, format: "pause" / "pause_image") is no longer parsed. Migrate: replace position: "pause" with the start object above, move delay into start.delay, and change the variant format to single.

Pause ads are SGAI-only. They are a client-side overlay and are not served in SSAI mode (the server controls insertion and the client never reads the break manifest).

Creative sources

The single asset's mediaType (image/video) selects the creative kind and its type (static/vast) selects the source — four combinations:

Source Asset How the creative is obtained
Static image type: "static", mediaType: "image" uri is a direct image URL fetched with a plain GET.
VAST image type: "vast", mediaType: "image" uri is a VAST tag; image = CompanionAds StaticResource.
Static video type: "static", mediaType: "video" uri is a direct MP4 URL played muted on the pause-video surface.
VAST video type: "vast", mediaType: "video" uri is a VAST tag; MP4 = Linear progressive MediaFile.

For a VAST source the SDK parses the XML itself (no IMA needed): for an image it reads CompanionAds/Companion/StaticResource, fires the companion creativeView impression on display, and opens CompanionClickThrough on click; for a video it reads the Linear progressive MediaFile, fires the Impression beacons on display, and opens VideoClicks/ClickThrough on click. See the manifest spec's “Expected VAST CompanionAds shape” and “Expected VAST Linear MediaFile shape”.

Resume affordance

Because the SDK overlay covers the player surface (and a native <video>'s own controls cannot be undercut), the SDK renders its own resume (play) button and a close button on top of the pause ad so the viewer can always resume — either dismisses the ad and resumes playback. The rest of the creative is the click-through target.

When the controls appear (web): both controls are hidden until the SDK allows resume (DA-PAUSE-AD-RESUME-ALLOWED):

Break Resume (play) and close (✕) buttons
controls.skipOffset set After skipOffset seconds on screen
Image, no skipOffset Immediately (or after duration seconds if duration > 0)
Video, no skipOffset When the creative ends (also on playback error or autoplay rejection)

A play button drawn over a playing video creative covers the ad and invites the viewer to skip it, so for video the controls are held back until the creative finishes. If the player resumes content while resume is not yet allowed (for example through the native controls), the SDK pauses content again, keeps the ad up, and records DA-PAUSE-AD-RESUME-BLOCKED.

Where playback resumes. Normally exactly where the viewer paused, with no seek — pressing resume continues the stream from the pinned position. The one exception is a live stream whose DVR window moved past that position while the ad was up: the paused moment no longer exists to resume into, so playback re-anchors to the live edge and the SDK records DA-PAUSE-AD-DVR-EXPIRED. VOD never hits this branch (its seekable range starts at 0). The decision itself is the portable resolvePauseResumePoint, locked across cores by the pause-resume-point conformance fixture.

Android/iOS: resume and close controls start hidden and appear only when the controller permits resuming, using the same skip-offset / creative-completion rules as web. Native resume remains in place; the live-edge resume behavior is tracked separately in conformance/PENDING-PARITY.md.

Asset shape (static video)

{
  "id": "pause-1",
  "start": { "type": "event", "event": "pause", "delay": 3 },
  "duration": 0,
  "controls": { "skipOffset": 5 },
  "variant": {
    "format": "single",
    "assets": [
      {
        "id": "pause-static-video",
        "type": "static",
        "mediaType": "video",
        "uri": "https://cdn.example.com/ads/pause.mp4",
        "interaction": { "clickThrough": "https://example.com/landing" }
      }
    ]
  }
}

VAST tag timeouts. A type: "vast" pause asset is resolved by fetching its tag, and each fetch is bounded at 5s on all three platforms (web AUX_FETCH_TIMEOUT_MS, Kotlin HTTP_TIMEOUT_MS, iOS httpTimeoutSec) — the same bound applies to the companion/backdrop image reads. A tag host that accepts the connection and then never answers therefore yields no pause ad after 5s instead of leaving the pause unanswered indefinitely.

GAM / VAST pause creatives. Web, Android and iOS/tvOS follow up to five wrappers and select a NonLinear image or video first, then a Companion image, then a progressive Linear MP4. The resume gate waits for resolution and follows the resolved kind, even when it differs from the manifest's mediaType hint. The resolved kind selects the display surface; video stays muted and plays once. Impressions fire when displayed, click trackers when the viewer clicks through, close trackers once on dismissal, and video start/quartile/completion trackers once as playback advances. A failed or empty resolution shows nothing; DA-PAUSE-AD-NO-ASSET includes its reason.

Swap mediaType to "image" (and the uri to an image) for an image pause ad. duration: 0 keeps the creative on screen until the viewer resumes; a positive duration caps the on-screen time. start.delay (seconds, optional, >= 0) is how long the content must stay paused before the ad appears (default 0); a resume before the delay elapses cancels the pending ad. controls.skipOffset (seconds, optional) is how long the ad must stay on screen before the viewer may resume.

Rotation

A manifest may contain several pause breaks. The SDK shows them in manifest order, one per pause, and shows nothing once the rotation is exhausted (DA-PAUSE-AD-ROTATION-EXHAUSTED). A usable break is consumed only when an ad is actually shown: a pause that is resumed before start.delay elapses does not consume the break, and a break whose creative cannot be resolved (DA-PAUSE-AD-NO-ASSET) is skipped in favour of the next one.

Ordinary manifest updates preserve the forward-only numeric position, including empty or shorter lists; they do not restart consumed positions. Entries appended beyond that position remain eligible. The spec does not define a pause-rotation reset policy for ordinary updates, so this preserves progress rather than replaying ads on every poll.

Try it

The Pause ads demo page shows the bundled content-player versions, accepts any reachable HTTP(S) HLS content stream, and displays the stream's current program date time in ISO-8601 UTC (Unavailable until the adapter receives a valid EXT-X-PROGRAM-DATE-TIME). In Generated manifest mode it creates a channel with a pause ad for the selected source — one of four: image/video × static/VAST — and starts an SGAI session. In Custom URL mode it skips local channel creation and passes the supplied full, signed manifest URL directly to the SDK. The page loads the Google IMA client-side SDK (ima3.js) so a custom manifest can also contain VAST/CSAI assets; the built-in pause VAST sources still use the SDK's direct parser described above. Remote content and manifest servers must permit browser CORS requests. Use the always-visible player control to play and pause on every supported content player — the pause image or video appears with a resume button; resuming dismisses it. Three toggles in Generated mode exercise the other manifest fields: Delayed sets start.delay: 2, Resume allowed after 5 s sets controls.skipOffset: 5 (the resume button appears only after 5 s), and Rotate two pause breaks adds a second pause break so consecutive pauses alternate between two creatives. The VAST sources use same-origin sample tags (public/pause-companion-vast.xml for the image CompanionAds, public/pause-linear-vast.xml for the video Linear MediaFile) so the parsers are exercised without a third-party ad server.

Pause-ad lifecycle is surfaced as diagnostics: DA-PAUSE-AD-SHOWN, DA-PAUSE-AD-RESUME-ALLOWED, DA-PAUSE-AD-RESUME-BLOCKED, DA-PAUSE-AD-DISMISSED, and DA-PAUSE-AD-NO-ASSET (skipped when no usable creative is found).

Customer demos

The demo app ships a set of customer demo pages — public, self-contained pages that show the OptiView Ads SDK integrated for a specific customer's stream and branding — plus a portal that lists them all. Every other page in the demo, including the portal itself, sits behind a site-wide login (see "The portal" below and web/demo/src/site-gate.ts); only the customer demo pages themselves are public. This page is the guideline for building a new customer demo so every one shares the same look and feel.

Customer demos are deliberately separate from the internal SDK demo pages (Player, Pre-roll, VOD, …): they use a top status bar chrome instead of the internal left sidebar, and they carry the customer's branding.

Anatomy

Every customer demo has four parts:

  1. A registry entry in web/demo/src/customer-demo/registry.ts — the single source of truth for the portal tile and the page's branding.
  2. A demo page — <customer>.html + web/demo/src/<customer>.js, registered as a Vite input in web/demo/vite.config.mjs.
  3. The shared shell (web/demo/src/customer-demo/shell.ts) mounted at the top of the page.
  4. The shared "How it works" explainer (web/demo/src/customer-demo/explainer.ts) mounted below the working demo (see next section).

The portal (portal.html) is generated from the registry; you do not edit it to add a customer.

The status bar contract

Every customer demo shows the same status bar, rendered by the shell:

  • Top-left: the customer's logo (or, if no logo is supplied, the customer name in bold).
  • Top-right: the Dolby OptiView logo (rendered black on the white bar).

There is no on-screen status pill — status and diagnostics are printed to the browser console instead. Mount the shell once at page start:

import { mountCustomerShell } from './customer-demo/shell';

mountCustomerShell({
  customerName: "Bally's",
  brand: {
    accent: '#d11e28', // secondary / accent colour
    radius: '12px', // rounded corners
    logoUrl: 'https://.../bally_logo_red.svg',
  },
});

mountCustomerShell injects the shared stylesheet once, applies the brand tokens to the page root as CSS custom properties, and inserts the status bar (customer logo left, Dolby OptiView logo right). It returns null (no status pill).

Branding tokens

A customer's look is defined entirely by the brand object on its registry entry, applied as CSS custom properties so one stylesheet themes every customer:

Token CSS variable Meaning
accent --brand-accent Secondary / accent colour — buttons, active states, the bar's bottom border. May be a CSS gradient.
radius --brand-radius Corner radius for cards, tiles, and the video frame.
surface --brand-surface Main background colour. Defaults to white when omitted.
text --brand-text Body text colour. Defaults to the dark ink #1a1a2e; set light for a dark surface.
statusbarBg --brand-statusbar-bg Status-bar background. Defaults to white; set dark for a dark-surface brand.
cardBg --brand-card-bg Card/panel background. Defaults to white; set to a dark elevated colour for a dark brand.
cardBorder --brand-card-border Card/panel border colour.
optiviewLogoFilter --brand-optiview-filter CSS filter for the (white) OptiView logo. Defaults to brightness(0) (black on a light bar); none keeps it white on a dark bar.
logoUrl — Customer logo shown top-left; falls back to the name as text.

Reserve the accent colour (or gradient) for accents — buttons, active states, the status-bar stripe — rather than large fills, so pages stay legible.

Light vs dark surfaces

The shell defaults to a light surface: any brand that sets only accent, radius (and optionally surface/logoUrl) renders exactly as before. For a dark brand (e.g. GloboPlay's black surface with an orange→red gradient accent), set the dark-theming tokens together so text and the OptiView logo stay legible:

mountCustomerShell({
  customerName: 'GloboPlay',
  brand: {
    accent: 'linear-gradient(90deg, #ff6a00, #ee0979)', // orange → red
    radius: '14px',
    surface: '#000000',
    text: '#f2f2f2',
    statusbarBg: '#0a0a0a',
    cardBg: '#141414',
    cardBorder: '#2a2a2a',
    optiviewLogoFilter: 'none', // keep the white OptiView logo white on black
    logoUrl: 'https://.../Globoplay-logo.png',
  },
});

The accent stripe under the status bar is painted on the bar's border-box layer, so a gradient accent shows there too (not only on buttons).

Choosing the content player

A customer demo can let the viewer pick the content player (for example HLS.js or Shaka) using the shared player picker (web/demo/src/customer-demo/player-picker.ts). It renders one logo button per player from CUSTOMER_PLAYER_CHOICES (logos are self-hosted under public/players/, never hotlinked) and maps the choice to a player-factory library id:

import { mountPlayerPicker, playerChoiceToLib } from './customer-demo/player-picker';
import { createContentPlayer } from './player-factory';

const picker = mountPlayerPicker(document.getElementById('playerPicker'), {
  onChange: () => {
    /* rebuild the player on the next Start */
  },
});
// later, when (re)creating the SDK:
const lib = playerChoiceToLib(picker.getSelected()); // 'hlsjs' | 'shaka'
createContentPlayer({ lib, video });

The picker only offers players; the existing resolveContentPlayerLib (player-select.ts) still applies the no-MSE → native fallback for the default hlsjs choice.

Client-side ad-break manifest (no backend)

A customer demo can generate its ad-break manifest in the browser, with no ad-manifest backend, using the SDK's interceptManifestRequest hook. When the hook returns a body object, the SDK skips the network entirely and uses that body as the manifest (parsed and validated normally, on the initial fetch and every poll):

const sdk = new OptiViewAds({
  // …
  interceptManifestRequest: async () => ({ body: await buildManifestFromStream() }),
});

This is how a demo can turn a stream's own ad markers (for example HLS #EXT-X-CUE-OUT cues) into break manifests without any server. See the Bally's demo for a worked example.

Injecting pre-roll / pause on a live backend

A customer demo can instead get its mid-rolls from a real ad-manifest endpoint (configure manifestBaseUrl + startSession({ channelId })) and still demo a pre-roll and a pause ad by injecting them into the manifest the SDK has already fetched, via interceptManifestResponse. The reusable helpers in web/demo/src/customer-demo/inject-ads.ts do this — the caller supplies the creatives, so each customer uses its own artwork/tags:

import { injectPreRoll, injectPause } from './customer-demo/inject-ads';

const sdk = new OptiViewAds({
  // …
  manifestBaseUrl: 'https://…/manifest/v1',
  interceptManifestResponse: (manifest) => {
    let m = manifest; // server mid-rolls
    if (preRollOn) m = injectPreRoll(m, { format: 'single', adUri: AD_TAG, delaySeconds: 0 });
    if (pauseOn) m = injectPause(m, { type: 'image', uri: PAUSE_IMAGE, delaySeconds: 0 });
    return m;
  },
});

injectPreRoll prepends a position: 'pre' break and injectPause appends an event-triggered break (start: { type: 'event', event: 'pause' }, single variant). Both are idempotent — the hook runs on the initial fetch and every poll, and each helper is keyed by its injected break id, so re-injecting never duplicates the break — they never mutate the input, and the server's mid-roll breaks are preserved. This is how the GloboPlay demo layers a pre-roll and a pause ad on top of its server-punched mid-rolls.

Both helpers accept an optional delaySeconds (default 0). For the pre-roll it maps to the break's delay: the seconds of content playback before the pre-roll fires. For the pause ad it maps to start.delay: the seconds the content must stay paused before the pause ad appears. injectPause also accepts skipOffsetSeconds, which maps to controls.skipOffset (the viewer may resume only after that many seconds). The Bally's and GloboPlay pages expose both delays as number inputs next to the pre-roll and pause controls.

The "How it works" explainer (PLAYG-294)

Every customer demo page mounts a shared, brand-themed explainer band below the working demo — one scrollable page tells the whole story: end-to-end architecture, how the SDK wraps a third-party player plus a copy-pasteable minimal web setup snippet, the AI onboarding tooling, and a capabilities matrix. Copy leads with the Dolby OptiView Ads brand name and the approved messaging ("turns your video stream into a monetized experience while keeping your origin, CDN, and streaming workflow unchanged … Everything else is managed by Dolby."), every section follows a Title → explaining paragraph → image order, and the copy is plain-language only — no "Under the hood"/"For developers" layer, no dash punctuation in the rendered prose, and no cross page links (the copy is self-contained). All four sections sit on the same Dolby-style dark purple gradient panel (brand independent), the whole band sits in one rounded, bordered container (.cd-explain, 24px radius, soft shadow) that follows the page's brand theme — a light card on a light brand (Bally's), a dark card on a dark brand (GloboPlay) — so it stands out as a single unit without clashing with the page, and each section carries just a headline, no eyebrow labels — the band's single title is the glowing labelled divider (cd-explain-divider, "How it works") that, together with a large top margin, separates the Dolby story from the differently styled demo above; the old four-link anchor nav was dropped as low-value. See the design proposal on PLAYG-297 for the full rationale and draft copy.

import { mountExplainer } from './customer-demo/explainer';

mountExplainer();

mountExplainer() is the only thing a new customer demo page needs to call — every section (diagram, code snippet, AI-tooling blurb, capabilities matrix) is fixed, shared content with no per-customer facts (web/demo/src/customer-demo/explainer.ts). The pure renderer (renderExplainer) is unit-tested directly in web/demo/src/__tests__/explainer.test.ts.

The diagram (web/demo/src/customer-demo/explainer-diagrams.ts, renderArchitectureDiagram) is a single inline SVG — architecture and integration touchpoints combined, deliberately simplified rather than a 1:1 rebuild of the original epic mockups:

  • Three ownership lanes, kept to a plain one-word legend — red = Customer (Origin — no "(3rd-Party)" qualifier — and Player; no CDN node), black = Dolby (Dashboard, Ads API, Ads SDK), green = Ad Provider (never named as a specific vendor), consolidated into a single Ad Server node. The Dashboard sits alone on the top row; Origin, Ads API and Ad Server share the middle row; Player and Ads SDK share the bottom row — so every cross-lane arrow (break detection, Notify, Ad Insertion) plus the vertical Content arrow is one straight line. The Ads SDK's Ad call arrow still enters the green block from the bottom-centre so the two ad-provider touchpoints read as clearly different — no stitcher/SSAI/EABN terminology.
  • No flow list under the diagram — the labelled arrows speak for themselves; the three numbered touchpoints render as a vertical ordered list (cd-explain-steps), not one inline sentence.
  • No standalone "Operations" node. The Dashboard configures and schedules breaks directly on the Ads API (Configure & schedule); the break-detection link is drawn dashed, labelled Break detection, from the Ads API to the Origin (PLAYG-303 — the service reads the stream's own SCTE markers — optional/dashed; customers can create breaks via the Dashboard/Ads API instead).
  • Three numbered touchpoint badges sit directly on the nodes a customer touches — 1 Dashboard (configure), 2 Origin (connect your stream), 3 Player (add the SDK) — so there is no separate dimmed "integration" diagram to keep in sync with the architecture one.

The diagram renders inside a fixed light .cd-diagram-panel, independent of the page's own brand theme, so the semantic colours read correctly on both a light brand (Bally's) and a dark brand (GloboPlay).

The Ads SDK section explains the adapter approach (a thin translation layer; the snippet names only HLS.js as the example player) and the AI section explains the AI enablement in full: local knowledge installed by npx optiview-ads-init-ai, troubleshooting from a diagnostic report, and a player adapter skill for building a custom adapter for an uncovered player. The code snippet uses a small hand-rolled JS/TS tokenizer (highlightJs in explainer.ts) for real keyword/string/number/ function-call syntax highlighting (VS Code Dark+-style palette) instead of only colouring comments.

The capabilities matrix groups (CAPABILITY_GROUPS) each carry their own accent/tint colour pair instead of one flat grey pill — plain text pills, no player logos. Seven groups: Features (incl. a Delayed pre-roll pill — the break delay capability the demo pages expose — and Pause ads split into "(video)" and "(image)" pills), Ad formats (incl. L-Shape Content, the backdrop-only lshape_content format), Break scheduling (SCTE-35, EXT-X-CUE, EXT-X-DATERANGE, API, Dashboard), Ad controls (Countdown, Number of ads, Skippable, Snapback), Players (the actual players — Media3 / ExoPlayer, AVPlayer), Streaming (HLS, MPEG-DASH, HESP, Live, DVR, VOD), and Insertion (DAI, DAR, VAST) — shown as tags without prose explanation. The Players and Streaming groups each end with a muted grey "Any" pill (cd-explain-tag--muted), signalling an open-ended list rather than a fixed set.

Worked example: Bally's (/ballys.html)

The Bally's demo (web/demo/src/ballys.js) is a live DVR demo built on THEOplayer:

  • Player. THEOplayer, because the stream is HLS with TS segments and THEOplayer transmuxes TS in the browser. TS transmux loads worker/wasm files from THEOplayer's libraryLocation, which must match the exact THEOplayer build actually running (see THEO_LIBRARY_LOCATION in web/demo/src/player-factory.js) — if it points at a different version, transmux fails silently. Keep the configured library location and the installed theoplayer package version in lockstep.
  • Client-side manifest. Scte35Client (web/demo/src/customer-demo/scte35-client.ts) fetches the stream's playlist (following one master → variant hop), parses its #EXT-X-CUE-OUT:DURATION= markers with the shared @dolby-optiview/ads-sdk-scte35-bridge parser, and returns a wallclock break manifest. Bally's carries no SCTE-35 binary payload and no EXT-X-DATERANGE, so the break start comes from the nearest #EXT-X-PROGRAM-DATE-TIME and the duration from the DURATION value. The manifest is handed to the SDK via interceptManifestRequest returning { body }, so there is no ad-manifest backend.
  • Ad format + generated Publica ad request. A mid-roll ad-format selector (single / double / L-Shape — VAST is linear-only) fills every detected break with a VAST ad. The tag is generated per break in the browser by buildPublicaVastTag() in web/demo/src/customer-demo/publica-tag.ts, against Bally's Publica endpoint https://pbs.getpublica.com/v1/s2s-hb. Because that endpoint is server-to-server, the request must carry the viewer's context explicitly: their public IP (resolved once per session by fetchPublicIp(); omitted if the lookup fails), ua from navigator.userAgent, a stable session_id/did, a fresh cb cache-buster per request, and pod_duration — the break's length in milliseconds — so Publica sizes the pod to the break. GAM's pmnd/pmxd pod params are not used here (Publica ignores them); vast-pod.ts still serves the GloboPlay and Bell Media pages.
  • Pre-roll and pause ads. The whole manifest is assembled client-side by the pure web/demo/src/customer-demo/ballys-manifest.ts (unit-tested) and returned from interceptManifestRequest; it takes a buildVastTag(durationSec) factory rather than a fixed tag, which is what lets each break mint its own ad request. The page exposes: an optional pre-roll with its own format selector — single / double / L-Shape (VAST) or an image overlay of the Bally's logo (non-linear, no VAST); and an optional static pause ad (image — the Bally Sports still — or an MP4 video), shown when the viewer pauses. The pre-roll break is 30s (BALLYS_PREROLL_DURATION_SECONDS) because Publica serves 30s creatives and a break's duration is a hard window — a 15s pre-roll had the SDK cut the ad at its midpoint. Pre-roll uses position: 'pre', pause uses start: { type: 'event', event: 'pause' } with a single variant. Each of the pre-roll and pause controls has a delay (seconds) input — the pre-roll delay (delay) is playback time before the pre-roll fires; the pause delay (start.delay) is time paused before the pause ad shows (both default to 0).
  • Detected-breaks list + seek-back. The mid-roll breaks from the latest client-built manifest are shown as a clickable list; clicking one seeks the player to 5s before that break's wallclock start (via the adapter's programDateTime, using the shared clampSeekTarget helper) so you can watch the break fire — the same DVR seek-back demo as the built-in DVR page.
  • Player UI + muted autoplay. Start mutes the THEOplayer and autoplays the stream (muted autoplay is never blocked by the browser). A basic control bar — play/pause, mute/unmute, a DVR seek slider over the seekable window, and a time readout — sits under the player. Muted autoplay also matters for correctness: until playback progresses THEOplayer does not expose EXT-X-PROGRAM-DATE-TIME, so the SDK logs the non-fatal DA-PDT-MISSING (wallclock breaks fall back to the system clock); once the stream is playing, PDT is available and the warning stops.
  • THEOplayer library must be same-origin for TS streams. The Bally stream is HLS/TS; THEOplayer transmuxes it via a worker + helper iframe.html loaded from libraryLocation. A cross-origin libraryLocation (e.g. a public CDN) makes that worker/iframe messaging stall silently — segments download but nothing is appended to the MediaSource, so you get a permanent black screen with no error. The demo therefore self-hosts the library on our own origin (THEO_LIBRARY_LOCATION = '/theoplayer/'; vite.config.mjs stages the installed build into public/theoplayer/, gitignored). fMP4 streams don't hit this (no transmux), which is why the built-in DVR demo never exposed it.
  • One ad per session_id/did — so the demo mints a new id per break. Measured against the live endpoint: Publica serves a single ad per device/session. With one id per viewer (as in Bally's reference script) the pre-roll filled and every later break of that session returned an empty <VAST version="3.0"></VAST> — which looked exactly like "DVR mid-rolls never get ads". Proven by isolation: the same mid-roll request (pod_duration=90000) fills when it is the session's first request, and server-side probes fill for every pod_duration (30000/90000/150000) and for stale IPs, so neither the pod length nor the ip was the cause. nextSessionId() therefore issues a fresh session_id/did per break (sharing one monotonic counter with cb, so no two minted ids can collide), which makes every break fill. Production should keep a stable device id — that cap is what makes an advertiser's frequency capping work; this is a deliberate demo-only deviation, and the page states it in the disclaimer band (below).
  • Page-level caveats live in one collapsed disclaimer band, not in the config panel. src/customer-demo/disclaimer.ts (renderDisclaimer / mountDisclaimer, styled by DISCLAIMER_CSS) renders a <details> band under the player: one always-visible line plus the notes on demand (US-only, the generated ad tag, the one-ad-per-session cap, and "an unfilled break is a no-fill"). These are properties of the stream and the ad server rather than help for any one control, and as .hint paragraphs in the Configuration panel they crowded out the controls and stopped being read. Notes are passed in by the page, so other customer demos can reuse the component; title and summary are escaped, bodyHtml is trusted in-repo markup (<code>, <strong>).
  • An empty VAST is a no-fill, not an SDK error. Publica answers 200 with <VAST version="3.0"></VAST> when it has no ad for the request; Google IMA then reports "empty VAST response" / "unable to find ad", which surfaces as DA-VAST-IMA-ERROR + aderror. The break still ends cleanly and content resumes. The page recognises that message and surfaces it two ways so it is not misread as a playback bug: a NO AD FILL notice toast over the player (amber badge, below the break-countdown pill, auto-hiding after 8s) and a NO AD FILL — … warning in the event log/console quoting IMA's own message. Check the US VPN and the ad server's targeting first. The generated request URL is printed in the event log on every manifest refresh, so it can be replayed with curl. Fill is bid-dependent: identical requests can fill on one break and return nothing on the next.
  • Embedded Xagget agent (dormant). The page embeds a Xagget device agent (customer-demo/xagget-agent.js) that stays inert unless opened with the Xagget bootstrap querystring vars (?deviceId=&broker=); when driven it exposes start/stop/seek/setConfig/getState/getLog. Note the broker needs the office VPN while the stream needs a US VPN, so live on-device runs of this stream aren't currently possible; local Playwright (US VPN, no broker) is the practical check.
  • Prerequisites. The stream is US-only, so enable a US VPN before starting. The in-browser playlist fetch also needs the stream to allow cross-origin reads; if it is blocked by CORS, add a dev-only Vite proxy for local runs.

Worked example: GloboPlay (/globoplay.html)

The GloboPlay demo (web/demo/src/globoplay.js) shows the same SDK against a low-latency HLS stream with a live ad-manifest backend and a viewer-selected player — a useful contrast to Bally's THEOplayer + no-backend design:

  • Selectable player. The page mounts the shared player picker (HLS.js or Shaka, with logos) and builds the content player for the choice via player-factory. Both play the low-latency HLS stream https://ll-hls.softvelum.com/sldp/bbloop/playlist.m3u8.

  • Mid-rolls from a real endpoint (server-side breaks). Unlike Bally's, the break manifest is not built in the browser. The SDK is configured with manifestBaseUrl pointing at the staging ad-manifest service and started with the channel id, so it fetches and polls the channel over the network. Breaks are punched server-side into that channel.

  • Client-injected pre-roll + pause. On top of those server mid-rolls, the page layers an optional pre-roll and pause ad using the reusable injectPreRoll / injectPause helpers (see "Injecting pre-roll / pause on a live backend" above) via interceptManifestResponse. Both have a delay (seconds) input, so you can demo a pre-roll that fires after N seconds of playback or a pause ad that appears only after the content has been paused for N seconds. The pause ad uses a GloboPlay still:

    GloboPlay pause ad

  • Dark branding. GloboPlay is a dark brand: a black surface with an orange→red gradient accent and the GloboPlay logo, using the shell's dark-surface theming tokens (see "Light vs dark surfaces" above).

  • Embedded Xagget agent (dormant). Like Bally's, the page embeds the dormant Xagget device agent so it can be driven on a lab browser when opened with the Xagget bootstrap querystring; it stays inert in normal use.

  • Prerequisites. The content stream and the staging ad-manifest endpoint must be reachable from the browser (CORS); if a fetch is blocked, add a dev-only Vite proxy for local runs.

Worked example: Bell Media (/bellmedia.html)

The Bell Media demo (web/demo/src/bellmedia.js) follows the same server-side-mid-rolls + client-injected-pre-roll/pause pattern as GloboPlay, with Bell Media's own stream, ad-manifest channel, and artwork:

  • Selectable player. Same player picker as GloboPlay (HLS.js or Shaka), playing Bell Media's stream (https://discovery.theo.live/v2/distributions/demo/hls/main.m3u8).
  • Mid-rolls from a real endpoint (server-side breaks). The SDK is configured with manifestBaseUrl pointing at the same staging ad-manifest service GloboPlay uses, started with Bell Media's own channel id, so mid-roll breaks are punched server-side.
  • Client-injected pre-roll + pause, with format-specific companions. The page layers an optional pre-roll and pause ad on top via injectPreRoll / injectPause. The linear formats (Single/Double/L-Shape) fill from the same VAST pod tag as GloboPlay/Bally's (pmnd/pmxd sized to the 15s pre-roll); unlike GloboPlay's single backdrop image, Bell Media's Double and L-Shape formats each additionally carry their own companion artwork — bell-doublebox.png for Double, bell-lbar.png for L-Shape — matching the format they are shown on. Overlay is a non-linear Bell Media logo image (no VAST), and the pause ad uses a Bell Media still (or an MP4 for the video option). Companion images apply to the pre-roll only; server mid-rolls play as delivered.
  • Light branding. Bell Media is a light brand (white surface, Bell blue #0065a4 accent, sampled from the Bell Media logo), using the same light defaults as Bally's.
  • Embedded Xagget agent (dormant). Same dormant Xagget device agent pattern as Bally's/GloboPlay.

Worked example: NBA (/nba.html)

The NBA demo (web/demo/src/nba.js) adds two things the other customer demos don't have — a source selector and a three-way player picker:

  • Source selector: LL-HLS (live) | VOD. The page's headline feature is low-latency HLS, called out in a highlight band above the controls. The LL-HLS source plays the demo LL-HLS stream against a monetized staging ad-manifest channel (mid-rolls punched server-side, fetched over the network — the GloboPlay/Bell Media pattern). The VOD source plays the NBA VOD asset and requires the viewer to paste the asset's own ad-break manifest URL — Start refuses without it.
  • Pasted manifest URL → SDK config. The pure helper web/demo/src/customer-demo/manifest-url.ts (parseManifestUrl, unit-tested) splits a standard <base>/<orgId>/channels/<channelId> URL back into the SDK's manifestBaseUrl + orgId + startSession({ channelId }) parts, so polling works exactly as if the page had been configured with them. A URL with any other shape falls back to interceptManifestRequest: the page fetches the URL verbatim on the initial fetch and every poll and returns { body }.
  • Selectable player, now including THEOplayer. The shared player picker gained a third choice (theo, self-hosted logo public/players/theo.svg), so the viewer picks HLS.js, Shaka, or THEOplayer; the page passes theoPlayerEl to createContentPlayer the way the internal Player page does.
  • Generated NBA backdrop artwork on Double / L-Shape. The pre-roll's Double and L-Shape formats carry NBA-branded companions generated for this demo — public/nba/nba-doublebox.png and public/nba/nba-lbar.png (1920×1080; SVG masters under docs/nba/). Both are designed around the SDK's exact layout geometry (Double: boxes at 1.04–48.96% / 51.04–98.96% horizontally, 26.04–73.96% vertically; L-Shape: pip inset top/left 5%, right/bottom 30%), so the branding lands in the visible margins/L and never under the video boxes. The same files are the hand-off artwork for server-side mid-roll companions on the real channel.
  • Pre-roll + pause ads. Same client-injected pattern as Bell Media (injectPreRoll / injectPause via interceptManifestResponse): linear formats fill from the shared GAM VAST pod tag sized to the 15s pre-roll, Overlay is a non-linear NBA logo image, and the pause ad is a generated NBA still (public/nba/nba-pause.png) or an MP4.
  • Dark branding. NBA is a dark brand: deep navy surface (#05070f/#0a1024), a blue→red gradient accent (#1d428a → #c8102e), light text, and the NBA logo (self-hosted public/nba/nba-logo.png), using the shell's dark-surface theming tokens.
  • Embedded Xagget agent (dormant). Same dormant device-agent pattern as the other customer demos; setConfig additionally accepts { source: 'llhls' | 'vod', vodManifestUrl }.

Adding a new customer demo

  1. Add a CustomerDemo entry to CUSTOMER_DEMOS in web/demo/src/customer-demo/registry.ts (id, name, description, href, brand). The portal tile appears automatically, with the name shown in uppercase.
  2. Create <customer>.html and web/demo/src/<customer>.js; mount the shell and wire the SDK for the customer's stream.
  3. Mount the shared explainer (mountExplainer from ./customer-demo/explainer, see above) below the demo markup, with the customer's customerName and wiredBullets.
  4. Register the page as a Vite input in web/demo/vite.config.mjs.
  5. Add unit tests for any pure logic (manifest building, parameter helpers) and update this page and add a changelog/ entry (npm run changelog:entry).

The portal

portal.html is the overview page listing the customer demos — one tile per registry entry (uppercase customer name + a short description). It used to have its own independent password check; that's gone now (PLAYG-295) — the portal is just another page behind the site-wide login described below, no gate logic lives in portal.js anymore.

Every page in the demo except the customer demo pages themselves — the root demo, docs, the portal, and the internal non-customer-specific pages (Pre-roll, VAST, VOD, Pause, DVR, Manifests, Preset Builder, Bug Report, …) — sits behind a site-wide login (login.html, credentials optiview / bumba), enforced by the siteGatePlugin Vite plugin (vite.config.mjs) via a head-time inline redirect on every page except the ones in its public-file allowlist (login.html and the customer demo pages). Credentials are checked client-side (web/demo/src/site-gate.ts) and the unlock is remembered in localStorage (da-site-unlocked), so a visitor only signs in once per browser. ?e2e=1 bypasses the gate for the demo's own automated tooling. Because the demo is a static site this is a soft, client-side gate, not real authentication — for a deployed site, enforce access with HTTP basic authentication at the reverse proxy too.

Ad Break Status & Countdown

adbreakstatus is the single source of truth for rendering ad-break UI — pre-break warnings, the "ad break in progress" badge, the seconds-remaining countdown, and the "ad N of M" counter. The SDK owns the timebase and the playback-gated ticking flag; your application just renders the snapshot it receives.

What it is

The SDK emits an adbreakstatus event whenever the break state or countdown changes, and exposes the current snapshot synchronously via sdk.getAdBreakStatus(). Both carry the same AdBreakStatus object:

Field Type Description
phase 'idle' | 'upcoming' | 'active' | 'complete' Current lifecycle phase of the break.
break Break | null The break this status describes; null while idle.
format BreakFormat Declared format of the selected variant, when known (single, double, lshape_ad, …).
secondsUntilBreak number Seconds until the break starts. Populated for upcoming warnings.
breakRemainingSec number Estimated seconds left in the active break, in the break's media time. For a GAM DAI pod (Web) this is the pod's single media timeline, so it counts down continuously across the pod's ads. While the manifest slate plays it is the wall time left to the break's scheduled end, whatever the slate's start-up, stalls or loops do (it may step down once when the slate starts, by the time the ads lost, never up), and reaches 0 at adbreakend. undefined until it can be derived from playback progress.
adIndex number 0-based index of the ad currently playing. For a multi-ad GAM pod (Web) this counts the pod's real creatives, not the pod itself.
totalAds number Total ads in the break, when known. Reflects the pod's real composition for a multi-ad GAM pod on Web.
adsRemaining number Ads remaining: includes the one playing while an ad plays; after an adend, the ads still to come (0 after the last ad).
ticking boolean true only while the ad is rendered and playback is progressing; false while buffering or before a held pre-roll's first frame.
warningSec number The configured warning threshold that was crossed (only on upcoming warnings).
externalPlaybackAllowed boolean Whether the content player may start AirPlay right now: false during a break and in the seconds before one, and always true while deliveryMode is ssb. Present only when the SDK manages the AirPlay gate (the manifest carries an ssb stream and the adapter can gate external playback); absent otherwise. An adbreakstatus is emitted whenever it changes.
deliveryMode 'sgai' | 'ssai' | 'ssb' Delivery mode of the active session; ssb while AirPlay plays the channel's server-side beaconing stream. Absent between sessions. An adbreakstatus is emitted when it changes.

Phases

  • idle — no break active or upcoming. Hide all break UI.
  • upcoming — a pre-break warning fired (see Configuration). secondsUntilBreak is the live countdown to the break.
  • active — a break is playing. Show the badge; render the countdown from breakRemainingSec and the counter from adIndex / totalAds.
  • complete — an active break ended, including an early cut or error. Dismiss the break UI; this does not mean every ad was watched.

On web, Android, iOS/tvOS and React Native, the end order is adbreakstatus(complete) → adbreakstatus(idle) → adbreakend. The SDK emits one complete notification per ending active break, carrying the ending break and its format, with ticking: false, breakRemainingSec: 0 and adsRemaining: 0. Ad counters (adIndex, totalAds), warning fields and the upcoming countdown are absent. Zero means no playback remains in this ended break, not that all scheduled ads played successfully.

getAdBreakStatus() returns complete during its notification and idle after cleanup; completion is an event, not a state to wait for by polling. The following idle status clears the break reference. Session teardown and breaks skipped before starting do not emit complete. A warning for a later break does not suppress the ending active break's completion. Chained breaks each have their own terminal notification before the next break becomes active. Handle idle as well as complete when hiding UI, since teardown can go directly to idle. Do not count both statuses as two completed breaks.

How to use

Subscribe for live updates, and/or read the current status on demand:

import type { AdBreakStatusEvent } from '@dolby-optiview/ads-sdk-core';

// Live updates — fires on every state/countdown change.
sdk.addEventListener('adbreakstatus', (e: AdBreakStatusEvent) => {
  const { status } = e;

  if (status.phase === 'upcoming') {
    showToast(`Ad break in ${status.secondsUntilBreak}s`);
    return;
  }

  if (status.phase === 'active') {
    const counter =
      status.totalAds != null ? ` · Ad ${(status.adIndex ?? 0) + 1} of ${status.totalAds}` : '';
    if (status.ticking && status.breakRemainingSec != null) {
      showToast(`Ad break${counter} · ${Math.ceil(status.breakRemainingSec)}s remaining`);
    } else {
      showToast(`Ad break${counter}`);
    }
    return;
  }

  // 'idle' | 'complete'
  hideToast();
});

// On-demand — e.g. when (re)building your controls.
const current = sdk.getAdBreakStatus();
Drive your countdown from breakRemainingSec — do not run your own timer. The SDK gates the countdown on real playback progress (ticking), so it stays correct through buffering, tune-in (join-in-progress), and held pre-rolls, and it advances monotonically without flicker.

How it can be configured

adbreakstatus requires no configuration for the active / complete / idle phases — those are always emitted. The one configurable piece is the pre-break warning (phase: 'upcoming'), controlled by the breakWarnings option passed at construction:

const sdk = new OptiViewAds({
  manifestUrl,
  playerAdapter,
  // Fire an `adbreakstatus` (phase: 'upcoming') 10s and 5s before each break.
  breakWarnings: { seconds: [10, 5] },
});
Option Type Default Notes
breakWarnings.seconds number[] [] Seconds before a break at which to fire an upcoming warning. Normalised to positive integers, deduplicated, sorted ascending.
  • Each threshold fires once per break.
  • Warnings are skipped for pre-rolls — there is no content playback before a pre-roll, so a "break in Ns" warning has nothing to count down against.
  • With the default ([]), no upcoming warnings fire; you still get the full active countdown.

Using it for pre-roll

Pre-rolls are the most common place to show a countdown, and they need no special handling — subscribe once and render on phase === 'active':

  • No upcoming warning — a pre-roll has no pre-break content, so the first status you see for it is phase: 'active'.

  • ticking gates the first frame — for a held/first-frame-gated pre-roll, the status is emitted with ticking: false until the ad's first frame renders. Render a static "Ad break" badge while ticking is false, and switch to the live breakRemainingSec countdown once it flips to true. This avoids showing a countdown against a frame that has not started.

  • Monotonic countdown — once ticking, breakRemainingSec counts down smoothly to 0 (including CSAI/VAST pre-rolls, which advance from IMA ad progress). It never rewinds. While a slate plays, ticking follows whether the slate is on screen.

  • Dismiss on complete / adbreakend — hide the badge when phase becomes complete (or on the adbreakend event).

  • A short, healthy pre-roll can complete extremely fast. startSession() starts the break scheduler's 250ms tick and returns; a delay: 0 pre-roll can fire on that very first tick, and if the creative loads quickly the whole lifecycle (adbreakbegin → adbegin → adend → adbreakend) can complete in well under a second — potentially before your app resumes from await sdk.startSession(...) and gets around to attaching listeners or polling sdk.getAdBreakStatus(). Register adbreakstatus/ad-event listeners before calling startSession, not after, so you never race a fast pre-roll:

    sdk.addEventListener('adbreakstatus', onStatus);
    sdk.addEventListener('adbreakbegin', onBreakBegin);
    // … then start the session
    await sdk.startSession({ manifestUrl });
sdk.addEventListener('adbreakstatus', ({ status }) => {
  if (status.phase !== 'active') {
    breakToast.classList.toggle('visible', false);
    return;
  }
  breakToast.classList.add('visible');
  toastText.textContent =
    status.ticking && status.breakRemainingSec != null
      ? `Ad · ${Math.ceil(status.breakRemainingSec)}s`
      : 'Ad break';
});

See the Pre-roll concept page for how to schedule a pre-roll break, and the Events page for the surrounding ad-break lifecycle events (adbreakbegin, adbegin, adend, adbreakend).

React Native

Scheduled scrubber markers

Call await connector.getScheduledBreaks() or listen for scheduledbreakschange and read its { breaks } payload. The exported ScheduledBreak type matches the web SDK: id, pre/mid/post position, nullable content seconds and ISO wallclock date, manifest duration, and played state. Only viewer-playable opportunities are returned; bookmark-skipped pre-rolls and overlap skips are excluded. Earlier bookmark mid-rolls stay unplayed. Played flips after break-begin and survives rewind; session end clears the list. Native events are discrete, not coalesced, and their newest snapshot survives bounded-buffer overflow.

VOD bookmark startup

See Start VOD from a bookmark for the RN host player contract and native/web positioning instructions.

VOD snapback

Use connector.seek(time) for viewer seeks: the native bridge routes it through the Android or iOS/tvOS SDK's seek policy; RN web delegates to the web SDK. An unplayed, playable mediatime-scheduled client-side break with controls.snapback: true plays from elapsed time zero. After a forward seek crossing the break start (regardless of ad duration), content-pausing Single and L-Shape Ad return to the requested position; Double Box, L-Shape Content and Overlay play on without a seek. Fullscreen fallbacks at break start count as Single. Backward seeks and seeks entirely after a scheduled start do not force that break, regardless of its declared ad duration. A landing within an inclusive 0.5 seconds of the planned viewer target belongs to the same seek. Bookmark re-earning and VOD rewind re-arming require going below the scheduled start; VOD does not late tune in after a missed start. The last crossed snapback break is the only candidate; if it is already played or unplayable, all crossed breaks are skipped without fallback. Other crossed breaks cannot tune in or chain during that seek and remain unplayed for later viewer seeks. A break that has started does not cause snapback again in the session. Live, PTS/wallclock, event-triggered, SSAI and SSB breaks are excluded.

Both THEOplayer and react-native-video native hosts share this policy. Android and THEOplayer forward player seek completion; react-native-video on iOS/tvOS detects host-control seeks through scheduler position jumps greater than two seconds. Prefer connector seeking for arbitrary small seeks. RN web uses THEOplayer and excludes TV-web profiles.

liveStartPushback uses the same five-target-duration startup policy on native Android, iOS/tvOS and RN Web: off by default for every ptsSource, on only with { enabled: true }. It is passed unchanged through the bridge; an omitted enabled or { enabled: false } keeps it off. Supply { enabled: true, targetDurationSeconds: 10 } using the actual stream TD when the host cannot expose declared metadata. Observe DA-LIVE-START-PUSHBACK and DA-LIVE-START-PUSHBACK-LANDED for requested/measured offsets in seconds and TD multiples. Later ad resumes do not repeat the startup adjustment.

The OptiView Ads SDK supports React Native (@dolby-optiview/ads-sdk-react-native) by bridging the existing native Android, iOS, and tvOS SDKs — a typed JS facade plus a TurboModule delegate to the native OptiViewAds orchestrator, which owns the PlayerAdapter, overlay rendering, and IMA. On web (react-native-web), the facade delegates to the web SDK.

RN app (JS)
  └─ @dolby-optiview/ads-sdk-react-native        typed facade: config, startSession(), events,
       │                            muted/volume, diagnostics, interceptors
       └─ TurboModule (bridge)
            └─ native OptiViewAds orchestrator (ads-sdk / OptiViewAdsSDK)
                 ├─ PlayerAdapter           wraps the *native* player instance
                 ├─ OverlayAdRenderer       native view above the player view
                 └─ GamStreamManager / VastAdManager (native IMA)

Event and diagnostic reporting follows the active React Native host SDK. Use the shared event API and diagnostics subscription from the connector.

All timing-sensitive logic — manifest polling, cue matching, break scheduling, ad progression, insertion — runs natively, so ad insertion keeps working while the RN JS thread is paused or throttled (Picture-in-Picture, background). Events are buffered natively and delivered when JS resumes.

On Android, bridge operations that access the host player are dispatched on the React Native UI queue before reaching the native player adapter. This includes session teardown, mute and volume controls, ad-break status, diagnostics, and the other instance-scoped bridge calls.

For Android THEOplayer facade builds, set usePlayerFacade: true at player creation. The SDK registers a native integration with its own Ads API. As on Web, full-surface single and lshape_ad breaks own playback and the clock across creative gaps; active-break SDK progress is forwarded unchanged, including whole-pod GAM time. Content playback notifications are hidden during takeover while source changes and destruction remain visible. SDK pause/seek notifications drain without reaching facade listeners, audio and skip route to the SDK, and session end clears ad state. The scheduler keeps reading the raw content engine. This registration is optional and does not add a THEOplayer dependency to apps using only react-native-video.

On iOS and tvOS no app setting is needed: the bridge installs the same kind of integration on the native THEOplayer, so player.muted and player.volume also route to the SDK there, and a viewer mute during a double break is kept after it.

Supported players and bindings

The native bridge resolves the mounted React view from its native view tag, then asks the platform binding to wrap the underlying player in the matching native adapter. The rn-binding scenarios exercise the two native host-player bindings; they do not apply to the in-process web connector.

On Android, both bindings retain the React-managed wrapper as the overlay host and pass the host player's nested content surface separately for two-box geometry. The native bridge uses a self-measuring backdrop host below content and an ad host above it. Companion artwork is positioned on the painted picture rect in that host's coordinate space, while the backdrop host remains opaque over letterbox bars.

On iOS/tvOS, moving a retained player between inline and expanded containers keeps its ad-overlay controller owned by the destination screen. The bridge updates native containment synchronously without destroying the ads session. No extra JavaScript callback is required; host UIKit moves must run on the main thread. The simulator regression suite covers repeated moves, controller ownership, overlay placement and cleanup.

Host player / entry Android iOS tvOS Web
react-native-theoplayer Supported. React tag → ReactTHEOplayerView → native THEOplayerAdapter. Covered by rn-android (rn-binding-theo). Supported. React tag → THEOplayerRCTView → native THEOplayerAdapter. Covered by rn-ios (rn-binding-theo). Supported. The same Apple view-tag binding runs through the native tvOS adapter; covered by rn-tvos (rn-binding-theo). Supported through the RN web facade. The web nativeHandle is a THEOplayer ChromelessPlayer, wrapped by the existing web THEOplayerAdapter; covered by rn-web (rn-ads). No native rn-binding scenario applies.
react-native-video v6 Supported. React tag → ReactExoplayerView subtree → Media3 ExoPlayerAdapter; the typed useReactVideoHandle() / getReactVideoViewTag() helper supplies the tag. Covered by rn-android (rn-binding-video). Supported. React tag → RCTVideo layer tree → AVPlayerAdapter; use the same typed view-tag helper. Covered by rn-ios (rn-binding-video). Supported. The tvOS RCTVideo layer is wrapped by the same AVPlayerAdapter; covered by rn-tvos (rn-binding-video). Not supported by the demo web host. Its web handle stub does not yield a player, and createVideoDemoConnector() rejects this path.
react-native-web entry Not applicable. This is the browser entry, not a native host-player binding. Not applicable. Not applicable. Supported. The same facade is backed by the in-process WebOptiViewAdsConnector; rn-web (rn-ads) covers it.

Getting Started

Requirements

  • React Native ≥ 0.76 with the new architecture enabled (TurboModules + Fabric). Apple TV apps use the matching react-native-tvos release through the npm alias "react-native": "npm:react-native-tvos@<matching-version>".
  • A supported host player: react-native-theoplayer or react-native-video (v6) — the latter binds onto the existing Media3/AVPlayer adapters. On iOS/tvOS either host may be installed independently. Android automatically includes THEOplayer-specific code and dependencies only when its Gradle project is autolinked; no SDK host-selection flag is required. Combining native players still requires compatible Media3 dependencies.
  • The minimum react-native-theoplayer version is 11.7.0 on Android and Web for the experimental PlayerFacade API. Android uses a normal project dependency and typed API calls, without version or source-file probes. Web assumes a supported wrapper is installed, without runtime version checks. iOS/tvOS do not use PlayerFacade and may keep older wrappers. The optional npm peer range remains unrestricted for those Apple hosts.
  • Android: the native SDK artifacts (com.dolby.optiview:ads-sdk*) at the matching package version, from THEOplayer Maven for releases or the artifact host for develop/custom builds; Java 17, desugaring enabled.
  • iOS/tvOS: the OptiViewAdsSDK Swift package / pods, Xcode 16+, and one platform target per Podfile. Keep separate native project directories when one app ships both Apple platforms.

When the React Native package version changes or a native dependency is added or removed, refresh the independent Apple lockfiles on a Mac: cd react-native/demo/ios && bundle install && bundle exec pod install and cd react-native/demo/tvos && bundle install && bundle exec pod install, then commit both lockfiles. The Linux podfile:check gate checks direct dependency bookkeeping, while macOS CI verifies that the demo's pods resolve and integrate from a clean checkout. React Native podspecs are evaluated at install time and depend on the environment, so the committed lock is not expected to be byte-reproducible across machines.

Installation from public npm

Install the wrapper from public npm:

npm install @dolby-optiview/ads-sdk-react-native

For reproducible native setup, pin an exact published wrapper version with --save-exact; all OptiView native artifacts must match it. Keep either supported host player installed; neither optional peer requires the other. This adds only the RN wrapper to npm, not separate native packages. If your .npmrc already overrides the @dolby-optiview scope to a different registry, point that scope at https://registry.npmjs.org/ for this consumer. No override is needed with the default public registry.

Android: add the following repositories to your app's Gradle repository configuration. The bridge selects native dependencies at the installed wrapper version; keep Google/Maven Central for third-party dependencies.

// android/build.gradle — repositories used by the React Native projects
allprojects {
    repositories {
        maven { url "https://maven.theoplayer.com/releases" }
        google()
        mavenCentral()
    }
}

React Native's Gradle plugin may ignore settings-level-only repositories; ensure the repositories are available to the RN projects. Keep Java 17 and enable core library desugaring in android/app/build.gradle:

android {
    compileOptions { coreLibraryDesugaringEnabled true }
}
dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
}

For a react-native-video host, add to android/gradle.properties:

RNVideo_useExoplayerIMA=true

The Android binding is selected automatically from autolinked Gradle projects. THEOplayer present means its typed integration is compiled; absent means its sources and dependencies are excluded. No version, source-file or method probes are performed, and no SDK host-selection flag or JavaScript API change is required. The demo's OPTIVIEW_HOST_PLAYER flag still selects which player is autolinked so its single-host APKs avoid Media3 conflicts.

The THEOplayer binding compiles against the THEOplayer Android SDK version set by the THEOplayer_sdk property, the same one react-native-theoplayer reads. Pin it in android/gradle.properties so both build against one version:

THEOplayer_sdk=11.15.1

Without the property, the newest available 11.x version (11.5.0 or newer) is used.

This selects the real IMA integration rather than stub classes that conflict with the OptiView runtime's IMA SDK. Existing demo/test apps already set it.

iOS/tvOS: add both sources to each platform's Podfile alongside the normal React Native autolinking setup, then run bundle exec pod install there:

source 'https://github.com/THEOplayer/cocoapods-specs.git'
source 'https://github.com/Dolby-OptiView/cocoapods-specs.git'  # the Lens SDK pods
source 'https://cdn.cocoapods.org/'

The Specs repo is publicly readable over HTTPS and is not CocoaPods trunk; CI's SSH push keys are not consumer credentials. The npm variant's bundled OptiViewAdsReactNative.podspec defaults to OptiViewAdsRuntime and OptiViewAdsReactBridge at exactly the wrapper version. Core/SDK are transitive; OptiViewAdsAdapterTHEOplayer is added at that version only for THEOplayer hosts. The wrapper pod is autolinked from node_modules, not fetched from Specs.

Optional THEOplayer compatibility step: for react-native-theoplayer 11.5.0/11.6.0 with RN 0.87.0 or RN-tvOS 0.87.0-0 on Apple, the wrapper imports an absent React header. After installing dependencies and before running pod install, explicitly remove only this unused line from node_modules/react-native-theoplayer/ios/Theoplayer-Bridging-Header.h:

#import <React/RCTRootContentView.h>

Keep the other imports and persist this one-line change through the host app's dependency-patch process. Other versions require a compatibility review; prefer an upstream fixed wrapper when available. The SDK does not apply this workaround automatically. Existing apps and published SDK binaries are unchanged.

Set OPTIVIEW_ADS_NATIVE_PODS=0 at pod install to opt out and supply native dependencies yourself. OPTIVIEW_ADS_LOCAL_SWIFTPM=1 always wins and skips native pods. These npm defaults apply only to the staged public package marked optiviewAdsNativeDistribution: "cocoapods"; existing source/hosted/local packages and SwiftPM demos are unchanged. Web-only consumers use the browser entry and do not need native repository setup.

Existing hosted/source installations

The hosted tarball and local-store paths remain supported. Unmarked source, hosted and local tarballs keep their host-supplied SwiftPM default and existing OPTIVIEW_ADS_NATIVE_PODS=1 CocoaPods opt-in with unchanged constraints. OPTIVIEW_ADS_LOCAL_SWIFTPM=1 still suppresses native pods in these paths.

For current package installation and repository setup, follow the OptiView Ads SDK getting-started guide.

For stable Android releases, use the published dependencies documented in the getting-started guide. Retain google() and mavenCentral() for third-party libraries.

Quick start (react-native-theoplayer)

import { THEOplayerView } from 'react-native-theoplayer';
import { createOptiViewAds } from '@dolby-optiview/ads-sdk-react-native';

const onPlayerReady = async (player) => {
  const ads = createOptiViewAds(player, {});
  player.source = { sources: [{ src: CONTENT_URL, type: 'application/x-mpegurl' }] };
  ads.addEventListener('adbreakbegin', (e) => console.log('break', e.break.id));
  await ads.startSession({ manifestUrl: MANIFEST_URL });
};

<THEOplayerView config={{ license: THEOPLAYER_LICENSE }} onPlayerReady={onPlayerReady} />;

With a THEOlive source on Android or web, pass manifestUrlDiscovery: true, create the connector before you set the source and omit manifestUrl: the SDK uses the ads manifest URL from the THEOlive discovery response (see Ads manifest from THEOlive discovery). iOS still needs manifestUrl.

const ads = createOptiViewAds(player, { manifestUrlDiscovery: true });
player.source = { sources: [{ type: 'theolive', src: DISTRIBUTION_ID }] };
await ads.startSession({});

Quick start (react-native-video)

With react-native-video the view tag comes from the useReactVideoHandle() helper (its event payloads carry the tag at runtime; findNodeHandle on the v6 ref throws):

import Video from 'react-native-video';
import { createOptiViewAds, useReactVideoHandle } from '@dolby-optiview/ads-sdk-react-native';

const { player, onVideoEvent } = useReactVideoHandle();

useEffect(() => {
  if (!player) return;
  const ads = createOptiViewAds(player, {});
  void ads.startSession({ manifestUrl: MANIFEST_URL });
  return () => void ads.destroy();
}, [player]);

<Video
  source={{ uri: CONTENT_URL }}
  disableFocus
  onLoad={onVideoEvent}
/>;

On Android, disableFocus is required for react-native-video hosts. The native SDK overlay owns permanent media focus while the ad is audible and either content is paused by the SDK or the ad is the voice of a double break (content muted). Silent ads, lshape_content, overlay, continue-playout and doubleBoxAudio: 'content' breaks leave focus with the content player, including on ad unmute. If the host requests AUDIOFOCUS_GAIN again when content resumes, Android permanently removes focus from the overlay and the ad can remain paused until the break timer ends. The SDK reports DA-AD-FOCUS-GRANTED, DA-AD-FOCUS-DENIED, and DA-AD-FOCUS-ABANDONED for the Android-only focus lifecycle, carrying breakId and cause so a host or QA harness can observe the whole break. DA-AD-FOCUS-LOST remains the negative signal and now carries breakId; when progress remains stopped, the SDK also reports DA-AD-STALLED with reason: "permanent-focus-loss".

For non-hook code, getReactVideoViewTag(event) extracts the tag (or undefined) from any react-native-video event payload.

React Native on the web

The package's platform-split src/index.web.ts entry exports createOptiViewAds and WebOptiViewAdsConnector from src/web/WebOptiViewAdsConnector.ts. This entry delegates directly to the in-process web @dolby-optiview/ads-sdk and existing web adapters: there is no TurboModule, native view-tag lookup, or bridge serialization.

For react-native-theoplayer, use the same call on native and web, with the player received by onPlayerReady and OptiViewAdsReactNativeConfig:

const ads = createOptiViewAds(player, config);

On web, the SDK unwraps player.nativeHandle, creates THEOplayerAdapter, and uses the browser player's element as its overlay container. The connector releases its adapter listeners on destruction, but never destroys the host player. A missing browser player or element throws; wait for onPlayerReady. Native targets validate the numeric view tag before calling the bridge.

The existing createOptiViewAds(webConfig) overload still accepts an explicit web adapter and container for custom integration; those remain caller-owned. The package's browser and default conditions select the web entry; an explicit import from @dolby-optiview/ads-sdk-react-native/web also works. The web-safe default supports Next.js server-side rendering of client components without SDK-specific resolver aliases. Metro still selects the native entry through react-native. Player creation and SDK sessions belong in the browser, after the player is mounted, not during server rendering. The demo's Vite setup aliases react-native to react-native-web and selects .web.* modules.

To expose Dolby ads through THEOplayer's normal ad event and analytics surface, use a facade-capable RN THEOplayer build with usePlayerFacade: true. The shared factory automatically registers AdsSDKIntegration, forwarding break/ad starts and ends, quartiles, matching ad errors and clicks (adclicked). Web ad and break models use THEOplayer's supported integration: 'csai' kind so unmodified Bitmovin collectors classify them as client-side ads. Dolby identity remains available as customData.provider: 'optiview-ads'; this does not impersonate Google IMA. Analytics must observe the facade. The RN wrapper must accept and forward adclicked for web click reporting.

On iOS and tvOS, the native bridge registers its integration directly on the resolved THEOplayer instance. It dispatches the SDK's break/ad lifecycle, quartiles, errors, playing, waiting and sampled progress through THEOplayer's native Ads and player APIs. Full-surface ad playback exposes the sampled ad-local clock while the backing content is paused. The internal pause and resume-alignment seek sequence is absorbed until the seek settles; from adbreakend on, currentTime is the backing content player's own (it shows the resume target as soon as the SDK seeks), as on Android. The SDK's own adapter follows the backing content player rather than this integration, so the resume anchor and scheduler position are never the ad-local clock. The current native mapping reports the Google IMA integration kind because the creatives use GAM/IMA and supported analytics collectors classify that kind as client-side. Hosts other than THEOplayer do not install this integration. The bridge gives the overlay a persistent child view controller and passes that controller to GAM/VAST IMA. React Native fullscreen and native floating-player moves reparent the controller before the overlay view, preserving UIKit containment.

AdsSDKIntegration owns pause suppression. When the facade supports interceptPlayerEvent, the integration observes content pause events and consumes those expected from its own pauseContent() operations, plus any content pause while a content-replacing break owns playback. It handles queued events, repeated pauses, and failed or no-op calls; the facade contains no pause policy. This includes preroll holds before adbreakbegin. Raw content listeners and ordinary content pauses remain unchanged. Older facade builds fall back to raw pauses. With player-event dispatch support, ad playing, waiting and progress events reach facade consumers while full-surface ads own playback. paused is false during these ads, including buffering and creative gaps. Public play/pause commands are consumed during these ads: the SDK does not yet support pausing or resuming the ad itself. Overlay, double-box and content-backdrop formats retain content playback state and controls.

With interceptPlayerEvents, the integration filters every raw content playback event during single and lshape_ad breaks, not just a fixed list. Source changes and destruction remain visible. Break ownership lasts through adbreakend, even when the SDK has already started its content-resume work. Actual SDK content time writes arm seek suppression before the engine can emit events; delayed seeking / seeked stay hidden until completion, including adapter-deferred resume writes. The public seeking getter stays false during takeover and pending background seeks. Facade and connector viewer seeks after handoff release that background ownership. Raw SDK subscriptions still receive all events for scheduling and resume handling. Older facade builds without catch-all interception retain limited per-event filtering.

The integration provides its own Ads API object, including event subscriptions. playing remains true for the active break, including gaps between individual ads. The same ad and break objects remain available during their terminal callbacks and are cleared afterward. Scheduled lists are empty; ads.skip() delegates to the SDK's skip policy. Direct scheduling, target-position break skipping and server-side integration registration are unsupported and throw explicit errors.

Facade mute and volume delegate to the SDK's effective audio owner. Existing SDK synchronization preserves user audio settings across content/ad handoffs and respects double-box audio focus. The integration deduplicates volumechange notifications from the SDK and backing player.

Throughout single and lshape_ad breaks, the facade owns the clock, starting at zero and retaining the last SDK sample across creative gaps. Active-break adtimeupdate samples update the clock and forward player timeupdate unchanged, including whole-pod GAM time during individual creatives and slate. Other formats retain content time. The SDK's scheduler always reads the raw content player, never this ad clock. Session end clears break state; destruction also removes event subscriptions and registration. No skip, impression or completion reason is inferred. Plain browser players still work without facade integration.

Because this runtime is in-process, scheduling and insertion run on the browser main thread. The native bridge's guarantees about scheduling while the RN JS thread is paused in PiP or background, and native event buffering during that pause, do not apply. react-native-video has no supported web host in this demo; use the web THEOplayer path or a normal web SDK integration.

API notes

For RN-web THEOplayer, install useTHEOplayerAdsBinding when the player is created, even while ads are disabled, and pass its ready/destroy handlers to the view. Preparation precedes the application's ready callback and its first source assignment. Later ads activation and SDK replacement borrow the same player-owned presentation hierarchy, preserving the fullscreen containment and content DOM. Final SDK cleanup releases ad-owned resources; presentation cleanup follows actual player disposal. A playing, unprepared player is rejected without late wrapping. The hook's ownership and real configuration dependencies are unchanged. Native fullscreen controller containment and PiP source-swap behavior are unaffected.

  • createOptiViewAds(playerHandle, config) returns a OptiViewAdsConnector with startSession / endSession, addEventListener / removeEventListener, seek(time) (routed through the SDK's seek policy — suppressed during breaks with controls.snapback; prefer it over seeking the host player directly, which bypasses the policy), getMuted / setMuted, getVolume / setVolume, getAdBreakStatus(), skipAd(), clickAd(), exportDiagnostics(), getPresentationState(), notePictureInPicture(active), manifest request/response interceptors, and destroy().

  • adchannelchange reports both polled channel changes and live event boundaries. At an event boundary, reason is event-boundary and eventId identifies the event now in effect (or is null when playback leaves an event). Subscribe with connector.addEventListener('adchannelchange', handler).

  • skipAd() is asynchronous and resolves to true only when the active break's controls.skipOffset policy permits the skip. clickAd() resolves to the click-through URL (or null); it never navigates. The host application can use the returned URL with its own navigation policy.

  • The config is the web OptiViewAdsConfig minus its DOM/function members; events reuse the web OptiViewAdsEventMap verbatim, and live diagnostics reuse the web DiagnosticEvent shape:

    connector.onDiagnostic((diagnostic) => {
      console.log(diagnostic.code, diagnostic.message, diagnostic.context);
    });

    Remove a handler with offDiagnostic(handler). Native diagnostics are buffered while the JS thread is paused; exportDiagnostics() remains the snapshot API.

  • Getter-style APIs are async (Promise-returning) because they cross the bridge.

  • Asset parameters (SessionConfig.assetParameters, updateAssetParameters(), the manifest session layer vendorConfiguration.gam.sgai[0].assetParameters or ssai[0].assetParameters, and assetParameters on GAM and VAST assets; later layers win per key) and the built-in $OPTIVIEW_* macros work through the native SDKs unchanged. A changed manifest session layer is pushed to the live IMA session on the next manifest poll, without re-creating the IMA session. Customer macros use the same SessionConfig.assetParameterMacros map as web, no native code needed:

    import { OPTIVIEW_ASSET_PARAMETER_MACROS } from '@dolby-optiview/ads-sdk-react-native';
    
    const assetParameterMacros = {
      $SEGMENT$: 'sports',                                         // fixed value
      $CUSTOM_TEAM$: () => currentTeam(),                          // evaluated on every ad request
      $CUSTOM_USER_ID$: () => user?.id,                            // undefined -> empty when the user id is unavailable
      [OPTIVIEW_ASSET_PARAMETER_MACROS.USER_AGENT]: 'MyApp/2.1',   // override a built-in
    };
    
    const assetParameters = {
      dimensions: '$OPTIVIEW_PLAYER_WIDTH$x$OPTIVIEW_PLAYER_HEIGHT#x27;, // macros inside a value -> "1920x1080"
    };
    
    await ads.startSession({ ...config, assetParameterMacros, assetParameters });

    Values and callbacks stay in JS; only the macro names cross the bridge. A string replaces the token; "", null, or a callback result of undefined marks it empty. An undefined initial map entry is not registered, and an update entry of undefined unregisters. While the native SDK builds an ad request, and before it pushes a changed manifest session layer to IMA, it asks JS for all values in one bounded (500 ms), fail-open round-trip. An unanswered or throwing callback counts as unresolved: the macro stays literal and the parameter is still sent; $OPTIVIEW_* and registered customer macros raise DA-ASSET-MACRO-UNKNOWN once per parameter key and macro, other names stay literal without a diagnostic. An empty macro omits its parameter, or only the affected pair of any literal-& value for GAM, VAST, and static assets; the key is omitted if no pair remains. This raises DA-ASSET-PARAMETER-OMITTED. updateAssetParameterMacros(macros) merges names during playback; null or "" marks a name empty and undefined unregisters it so the built-in macro applies again, and new values apply to the next ad request. RN values are strings or callbacks like assetParameterMacros. A macro is the full $NAME$ token; a $ without a closing $ is left unchanged, and $APP$ and $APP_NAME$ never collide. Session macros are cleared by endSession().

  • OptiViewAdsExternalVendors exposes the provider getter and change events without requiring a player handle. Create it with a manifest URL, await start(), read the parameters before playback, and call stop() or destroy() when finished. The web package uses the Web implementation; native packages use player-free TurboModule methods.

  • External provider configurations are available through the async getExternalVendorConfiguration() overloads: no argument resolves every provider in manifest order, while an exact name such as mediakind resolves one provider. The native TurboModule uses separate list and provider methods to keep codegen signatures unambiguous. Values use the current application parameters and JS-backed macros; read them immediately before calling the external system. externalvendorconfigurationchange fires for each added, removed, or template-changed provider when a manifest is adopted, including the first manifest. Macro-value changes alone do not emit the event. vizbee is another example provider name.

  • Manifest interceptors run in JS with a bounded timeout (default 2000 ms) and fail open: if JS is paused or slow, the original request/response proceeds.

  • On iOS and Android the response interceptor receives the manifest in the manifest-spec shape (breaks[].variant, slate, vendorConfiguration, ...), rebuilt from what the SDK parsed, so fields the SDK does not use are not included. The manifest it returns is validated again before the SDK uses it; returning the manifest unchanged keeps every break as it was.

  • Ad insertion modes: manifest-steered ssai (the channel's full-service DAI livestream, assetKey) resolves on the native bridges like on the other platforms; the stitcher-URL flavour of an explicit mode: 'ssai' is web-only. SessionConfig.adInsertionType selects DAR (replacement) or DAI (insertion).

Demo app

A committed demo host lives at react-native/demo/ in the repository: configuration screen (host player — react-native-theoplayer or react-native-video — org, manifest base URL, channel, content URL, SGAI/SSAI mode, DAR/DAI insertion type, debug), player screen with event log and live ad-break status line, mute control, and diagnostics export to the OS share sheet. The react-native-video option uses the useReactVideoHandle() helper exactly as in the quick start above. See react-native/demo/README.md for build/run instructions (THEOplayer license required for the THEOplayer option only, never committed).

On Android the demo opts in to picture-in-picture: MainActivity declares android:supportsPictureInPicture and auto-enters PiP when the user (or a test host sending KEYCODE_HOME) leaves the app — setAutoEnterEnabled(true) on Android 12+, an onUserLeaveHint() fallback on API 26–30. Automated Android scenarios can exercise host-driven PiP. iPhone simulators have no host-driveable PiP entry, so the iOS rn-pip cell is device-only.

On iOS, an app whose viewers use picture-in-picture with DAR needs three things (all shown in the demo): the Audio, AirPlay, and Picture in Picture background capability (UIBackgroundModes: [audio] in Info.plist — without it AVKit silently refuses to start PiP, and backgroundAudioConfiguration is ignored); player.pipConfiguration = { retainPipOnSourceChange: true } on react-native-theoplayer — during a break in PiP the SDK plays the ad through the content player (the PiP window presents that layer and nothing else), which is a source swap, and the library's default exits PiP on any new source, closing the window the moment an ad begins; and a React Native SDK version that preserves host-entered PiP.

On iOS, react-native-video's allowsExternalPlayback prop and the SDK's external-playback gate (setExternalPlaybackAllowed) write the same AVPlayer property, so a host re-render that re-applies the prop can reopen a gate the SDK closed. With react-native-theoplayer the bridge's THEOplayerAdapter reports player.cast.airPlay and gates through THEOplayer's allowsExternalPlayback; start AirPlay from the system route picker or player.cast.airplay.start(). Both hosts take externalPlayback: { blockBeforeBreakSec } in the connector config and follow the SSB switch described under Break Manifest → Server-side beaconing stream; Android never reports.

PiP with the react-native-video host needs one extra wire: connector.notePictureInPicture. The SDK learns about PiP from the host player's presentation-mode events — but react-native-video has no such event surface the bridge can observe, so without help the SDK keeps the declared break layout while the app is pinned. The integrator forwards the view's own status event (the demo's PlayerScreen shows this):

<Video onPictureInPictureStatusChanged={(e) => connector.notePictureInPicture(e.isActive)} … />

The call is state-only — the SDK forces multi-surface breaks to single while pinned but never opens or closes the window itself — and it is ignored on hosts the bridge already observes (react-native-theoplayer), so wiring it unconditionally is harmless. On Android it resolves without acting: the Kotlin runtime watches activity-level PiP natively — reaching the Activity through the overlay's view ancestors, since React Native's ThemedReactContext unwraps to the application Context (a DA-PIP-AUTODETECT-UNAVAILABLE diagnostic means it found neither, and only then does the host have to report PiP itself).

Reading what the viewer actually sees: connector.getPresentationState(). While pinned, a forced-single ad plays through the content player (the PiP window presents that layer and nothing else) — so the player's own clock reports the ad's progress, and any UI or harness reading it directly would conclude content kept playing through a paid break. The SDK owns that truth, and the RN connector mirrors the web OptiViewAds.getPresentationState():

const { pictureInPicture, showing, insertion } = await connector.getPresentationState();
// showing: 'ad' | 'content' — which media owns the surface right now
// insertion (iOS): 'overlay' | 'shared-element' — how the ad reaches the screen

Consult showing/insertion before interpreting the host player's position or presenting "now playing" UI during breaks.

Troubleshooting

  • OptiViewAds TurboModule not found — the new architecture is disabled or RN < 0.76. Enable newArchEnabled=true (Android gradle.properties) / RCT_NEW_ARCH_ENABLED=1 (iOS pod install).
  • RN 0.87 iOS fails on React/RCTRootContentView.h from react-native-theoplayer — versions 11.5/11.6 still import this removed old-architecture header even though they do not use the type. The committed demo applies scripts/patch-react-native-theoplayer-ios.cjs during postinstall; consumer apps on the same versions need an equivalent install-time patch until an upstream release removes the import.
  • Cannot find module '@dolby-optiview/ads-sdk-react-native' at runtime — when consuming the package via a file: link inside the monorepo, Metro must watch the package folder; see react-native/demo/metro.config.js for the reference configuration.
  • Android dependency resolution fails — register THEOplayer /releases for stable versions; develop/custom builds also need their versioned artifact-host repository. Use allprojects.repositories as above, keep google() / mavenCentral(), and enable desugaring.
  • Player never resolves — createOptiViewAds needs the view tag of the mounted player view: player.nativeHandle from onPlayerReady for react-native-theoplayer (not before mount), or the useReactVideoHandle() helper for react-native-video.
  • No events while backgrounded — expected: events are buffered natively while the JS thread is paused and flushed on resume; insertion itself continues natively.

Roku

The Roku SDK is a BrightScript/SceneGraph component, OptiViewAds, that inserts ads from the OptiView Ads break manifest into clear live HLS on Roku. It is a separate implementation, not one of the three conformance-complete cores (web, Android, iOS/tvOS).

Unlike the web overlay, Roku uses one application-owned Video node and never changes that node's source at an ad boundary:

  • SGAI (client-side stitching) — the component runs a local HLS proxy. It republishes the content a little behind the live edge and replaces content segments with the Google Ad Manager (GAM) pod segments at the break times in the signed break manifest. The player sees one continuous playlist. Ad events come from Google IMA pod serving.
  • SSAI (Google DAI full service) — when the break manifest's delivery rule for tv selects ssai, the component requests a Google DAI live stream for the channel and returns its URL instead. See Break Manifest (Delivery steering) for the manifest side.

Requirements

Area Requirement
Devices Tested on Roku Ultra (Roku OS 15.3 and 16.0) and Roku Premiere+.
Channel bs_libs_required=googleima3,roku_ads_lib in the channel manifest.
Content (SGAI) Clear live HLS with EXT-X-PROGRAM-DATE-TIME; TS or CMAF; muxed or demuxed; up to eight renditions; in-band CEA-608/708 closed captions stay available on content (ads carry none). A source the SDK cannot stitch still plays, without ads.
Ads (SGAI) GAM pods whose renditions are compatible with the content (codec family, frame rate, audio sample rate).
Break manifest timebase: "wallclock", signed (detached signature), with a gam entry in vendorConfiguration.
Not supported DRM, VOD, low-latency HLS parts, pre-/post-roll, pause ads, VAST, non-linear formats, break-to-break chaining, and SGAI on streams without Program Date Time.

Install

Each release is a signed Roku component-library package, optiview-ads-roku-<version>.pkg, published together with a ZIP archive of the same files (download and checksums: Install / Distribution, Roku sections). Add the package to your channel and load it with a ComponentLibrary node:

<ComponentLibrary id="OptiViewAds" uri="pkg:/components/OptiViewAds.pkg" />

Once the library's loadStatus is ready, create the component as OptiViewAds:OptiViewAds.

To compile the SDK into your channel instead, extract the ZIP at your channel root and create the component as OptiViewAds. The archive is a component library, not a stand-alone channel: it adds components/OptiViewAds/, the Google IMA task IMASDKTask under components/Player/, helpers under source/ and the manifest verification keys under manifest-keys/; keep your own files out of those paths.

Integrate

Create the component (OptiViewAds:OptiViewAds from the package, OptiViewAds from the ZIP), bind your Video (and a node for IMA's ad UI), register event listeners, then start a session. Listeners work like the Web SDK's addEventListener: the owner is your SceneGraph node (m.top) and the listener is one of its interface <function>s, which the SDK invokes with the event as its only argument. m.ads.events holds the event type constants.

<interface>
  <function name="OnAdsOperation" />
  <function name="OnAdsEvent" />
  <function name="OnAdsDiagnostic" />
  <function name="OnAdsGateway" />
</interface>
m.ads = CreateObject("roSGNode", "OptiViewAds:OptiViewAds")
m.top.AppendChild(m.ads)
m.ads.videoNode = m.top.FindNode("video")
m.ads.adUiNode = m.top.FindNode("adUi")
events = m.ads.events
m.ads.CallFunc("addEventListener", events.operationresult, m.top, "OnAdsOperation")
m.ads.CallFunc("addEventListener", events.diagnostic, m.top, "OnAdsDiagnostic")
m.ads.CallFunc("addEventListener", events.gatewayrequest, m.top, "OnAdsGateway")
m.ads.CallFunc("addEventListener", events.adbreakbegin, m.top, "OnAdsEvent")
m.ads.CallFunc("addEventListener", events.adbreakend, m.top, "OnAdsEvent")
m.ads.CallFunc("addEventListener", events.adtimeupdate, m.top, "OnAdsEvent")
m.startOperation = m.ads.CallFunc("startSession", {
    contentUrl: "https://content.example.com/live/master.m3u8"
    manifestUrl: "https://manifest.example.com/v1/org/channels/channel"
})
  1. startSession(config) returns an operation ID. Results arrive as operationresult events (operationId, operation, generation, status, optional reason).
  2. On the matching status: "ready", load its playbackUrl into a ContentNode (streamFormat: "hls") on the bound Video and play. ready carries deliveryMode ("sgai" or "ssai"). The SDK never sets the Video source itself. If the first manifest fails, the session continues content-first in SGAI.
  3. A player that owns its Video (for example THEOplayer) binds that node and loads playbackUrl through its own source API.
  4. To stop: call endSession, stop and detach playback, then destroy. While playback is still attached, endSession reports draining / playback-detach-required and destroy refuses.

Keep generation and operation correlation: results of an older session must not update the current UI or tracking.

Start configuration

Key Type Description
contentUrl string (required) Live HLS master playlist.
manifestUrl string (required) Break manifest URL. Network manifests must carry a valid signature.
contentHeaders object HTTP headers sent with content playlist and segment requests.
assetParameters object Ad tag parameters added to GAM requests (merged with the manifest's parameters).
assetParameterMacros object Macro values keyed by the full $NAME$ token. Built-in macros: $OPTIVIEW_USER_AGENT$, $OPTIVIEW_PLAYER_WIDTH$, $OPTIVIEW_PLAYER_HEIGHT$, $OPTIVIEW_BREAK_DURATION_SECONDS$, $OPTIVIEW_BREAK_DURATION_MS$.
userAgent, playerWidth, playerHeight string, integer Values for the built-in macros above.
requestInterceptor, responseInterceptor, macroResolver boolean Route manifest requests, manifest responses or macro values through gatewayrequest events; answer each with resolveGateway within two seconds.
alignmentToleranceSeconds number Allowed alignment difference between renditions and at the return to content. 0.002–0.250, default 0.250.
mode "sgai" / "ssai" Overrides the manifest's delivery rules.
raf object SSAI only: { contentId, contentGenre, kidsContent, contentLength } for Roku Advertising Framework measurement (also updateRafMetadata).
streamActivityMonitorId string SSAI only: passed to the Google DAI stream request.
proxyPort integer SGAI local proxy port, 1024–65535, default 8889.

Invalid input fails the start with a named reason: missing-session-url, invalid-configuration, invalid-video-binding, invalid-alignment-tolerance, invalid-delivery-mode, invalid-raf-metadata, invalid-stream-activity-monitor-id, playback-detach-required or unsupported-state.

Methods and fields

Name Kind Purpose
videoNode, adUiNode field The app's Video and the node IMA draws its ad UI into. Bind before startSession.
events field Read-only event type constants for addEventListener (m.ads.events.adbreakbegin).
playerClockAnchor field Optional, externally verified clock anchor when native UTC is unavailable.
addEventListener, removeEventListener function (eventType, listenerOwner, listenerName): subscribe a node's interface function.
startSession, endSession, destroy function Session lifecycle.
updateAssetParameters function Replace the runtime ad parameters for future breaks.
updateAssetParameterMacros function { set: { "$NAMEquot;: value }, remove: ["$NAMEquot;] }; keys are full $NAME$ tokens.
updateRafMetadata function RAF content metadata (SSAI).
getAdBreakStatus, isSessionActive, getSessionInfo, getCapabilities function Snapshots of break, session and capability state.
reloadAfterSeek function Experimental DVR reload after a viewer seek (see Session Management).

Events

Event types for addEventListener (also available as m.ads.events.<type>). The shared types follow the Events contract; the last three are Roku-only and stand in for the Web SDK's promises, onDiagnostic and interceptor callbacks. Tracking events come only from genuine IMA callbacks; none are fabricated when a session ends mid-break.

Type Emitted when Interface
adbreakbegin A break starts playing at its actual splice point. AdBreakBeginEvent
adbegin An ad in the pod starts (from a genuine IMA callback). AdBeginEvent
adfirstquartile The current ad passes 25%. AdFirstQuartileEvent
admidpoint The current ad passes 50%. AdMidpointEvent
adthirdquartile The current ad passes 75%. AdThirdQuartileEvent
adend The current ad completes. AdEndEvent
adtimeupdate About every 0.25 seconds while playback progresses, not while paused, stalled or seeking. SGAI reports the manifest pod asset; SSAI reports the current ad asset and deliveryMode: "ssai". currentTime and duration are seconds; an unknown SSAI duration is 0. timestamp is epoch milliseconds with millisecond precision. AdTimeupdateEvent
adbreakend The break completes and content resumes. AdBreakEndEvent
adbreakskipped A break was refused before anything was shown and content kept playing. Emitted once per occurrence. AdBreakSkippedEvent
aderror An ad or break failed. After publication it also sets recoveryRequired; start a new session. AdErrorEvent
adbreakstatus The break state or countdown changed (same shape as getAdBreakStatus()). AdBreakStatusEvent
adchannelchange A polled manifest moved the session to another ads channel or playback crossed an event boundary. Same-event updates are ordinary manifest updates; reason: "event-boundary" marks only an active event ID change. AdChannelChangeEvent
playbackreloadrequired Playback must be restarted in a new session: a viewer seek fenced tracking, the delivery mode changed, or the SSAI stream changed. PlaybackReloadRequiredEvent
adinteractiveexit SSAI only: the viewer left a Roku Advertising Framework interactive ad; stop playback and restore focus. AdInteractiveExitEvent
operationresult An asynchronous call (startSession, endSession, destroy, updateAssetParameters, updateAssetParameterMacros, updateRafMetadata, reloadAfterSeek) reports a status. Possibly several per call. OperationResultEvent
diagnostic The SDK records a ROKU-* or DA-* diagnostic (see Diagnostics below). DiagnosticEvent
gatewayrequest requestInterceptor, responseInterceptor or macroResolver is enabled and the SDK needs the app's answer; reply with resolveGateway within two seconds. GatewayRequestEvent

Break/ad events carry eventId when their break belongs to a channel event. getSessionInfo() includes eventId only while an event applies.

Wallclock manifest events replace ad delay, delivery and vendor configuration inside their [start, end) interval. Up to 30 seconds before a boundary, OptiView Ads may prepare the next event's GAM/IMA session when no unfinished break for the current configuration starts before it. The public eventId, adchannelchange, getSessionInfo(), ad-start delay and delivery switch only when playback reaches the boundary. A newly announced current-configuration break in that lookahead window is skipped with reason: "not-ready" and reasonDetail: "event-boundary-preparation". SGAI event timing follows playback PDT and holds the last known position while PDT is temporarily unavailable; SGAI retains one IMA session. SSAI event timing uses the device clock because Roku's DAI stream does not provide source PDT. During an active SSAI stitched break, an event switch waits until break end or until the break's duration plus 30 seconds has elapsed. An SSAI event boundary that requires a different stitched stream emits playbackreloadrequired; stop and detach playback before starting the new session. Event switches retain terminal break history within one session; a seek reload follows the existing reload behavior.

adbreakskipped is a terminal pre-presentation outcome, not a viewer skip and not an adbreakend for an ad that never began. Its reason is one of late, not-ready, preparation-failed, unsupported, overlap, start-delay, removed, insufficient-remaining or resource-limit; reasonDetail names the specific cause when it differs.

Event interfaces

Events are associative arrays. The interfaces below are declared in the SDK's Events.bs for BrighterScript consumers; a ? marks an optional member. Where a member matches the Web SDK, its meaning is the one in Events.

Interface Extends Members
OptiViewAdsEvent — type (string), generation (integer): the session generation that emitted the event; sequence? (integer): monotonic within a generation, present on ad, break, status and diagnostic events; timestamp? (epoch milliseconds with millisecond precision); date? (ISO 8601 dispatch time).
AdBreakEvent OptiViewAdsEvent break (Break object from the manifest), occurrence (string): Roku's per-playback key for the break, also used by getAdBreakStatus().breaks[]; format? (single); deliveryMode? (sgai / ssai).
AdBreakBeginEvent AdBreakEvent elapsedSec, remainingSec (seconds into the break and left in it when the viewer joined).
AdBreakEndEvent AdBreakEvent No further members.
AdBreakSkippedEvent AdBreakEvent reason (see above), reasonDetail?, podEvidence? / preparationEvidence? (objects describing the pod or preparation failure when available).
AdEvent AdBreakEvent asset (the pod asset, or <podAssetId>-ad-<n> for one ad of a GAM pod), adIndex? (0-based), totalAds?, adId? / creativeId? (IMA's ids).
AdBeginEvent AdEvent No further members.
AdFirstQuartileEvent AdEvent No further members.
AdMidpointEvent AdEvent No further members.
AdThirdQuartileEvent AdEvent No further members.
AdEndEvent AdEvent No further members.
AdTimeupdateEvent AdBreakEvent asset, currentTime, duration (current ad playback time and total duration, in seconds).
AdErrorEvent OptiViewAdsEvent error ({ message, ... }), break?, asset?, recoveryRequired? (true when the failure happened after publication).
AdBreakStatusEvent OptiViewAdsEvent status: the AdBreakStatus snapshot plus Roku's state, generation, breaks[] (breakId, occurrence, state, reason, reasonDetail; covers the breaks the manifest lists plus breaks that ended less than 30 s ago), deliveryMode and, when a restart is needed, recoveryRequired, reloadRequired, reloadReason, bookmark.
AdChannelChangeEvent OptiViewAdsEvent previousChannelId, channelId (string or invalid), reason, manifestUrl, previousDeliveryMode, deliveryMode.
PlaybackReloadRequiredEvent OptiViewAdsEvent reason (for example ad-refill-requires-reload, delivery-mode-changed, ssai-stream-changed), reloadRequired (true), playbackEpoch?, bookmark? ({ generation, position, sourcePdt, verified } for reloadAfterSeek), previousDeliveryMode?, deliveryMode?.
AdInteractiveExitEvent OptiViewAdsEvent reason (interactive-ad-exit), deliveryMode (ssai).
OperationResultEvent OptiViewAdsEvent operationId (the integer the call returned), operation (the function name), status (see Session Management for the per-call statuses), reason?, playbackEpoch?; on ready: playbackUrl, streamFormat (hls), deliveryMode, ssaiStream? ({ vendor, assetKey, networkCode, streamId }); for reloadAfterSeek: previousGeneration?, resume?.
DiagnosticEvent OptiViewAdsEvent code (ROKU-* or DA-*), reason?, plus the code-specific context members listed under Diagnostics below (for example shiftSeconds, attempt, boundaryEvidence).
GatewayRequestEvent OptiViewAdsEvent requestId (integer to echo in resolveGateway), kind (manifest-request / manifest-response / asset-parameter-macros), value (the request { url }, the parsed manifest, or the macro scope), context ({ url } of the break manifest).

Break timing (SGAI)

  • Content first. Playback never waits for ads. A break whose start is already published without a ready pod is skipped once (late or not-ready), never inserted later.
  • Preparation time. Publication stays at least the stream's HOLD-BACK (and two segments) behind the live edge, so a break that reaches the manifest shortly after its start still has time to be prepared. If the pod is still preparing when its start is due, publication waits up to 5 s while at least 20 s of published media remains ahead of the player (ROKU-BREAK-HELD).
  • Off-grid starts. A break that starts between segment boundaries starts at the nearest boundary instead of being skipped. At most half a segment of content is replaced early or played longer (ROKU-BREAK-START-SHIFTED). adbreakbegin and the countdown follow the actual start.
  • Pod length. A pod up to alignmentToleranceSeconds longer than its break plays; the difference delays content slightly at the return.
  • Return to content. Small overlaps are absorbed. If the stream's segment grid shifted during the break, content resumes at the nearest boundary, delayed or advanced by at most half a segment (ROKU-RESUME-SHIFTED).
  • Long pods. Ad media is verified progressively, 40 s ahead of playback; a download that fails on the network is retried up to three times (ROKU-PREPARATION-RETRY).
  • Failure after publication. If a break fails after its ads were published, the SDK reports aderror and recoveryRequired, publishes the end of the stream and stops; start a new session to continue.

Diagnostics

diagnostic events carry the shared DA-* codes listed in Diagnostics that apply to Roku (for example DA-MANIFEST-POLLED, DA-DELIVERY-MODE-RESOLVED, DA-MANIFEST-CHANNEL-CHANGED, DA-SSAI-SESSION-FAILED) and these Roku-only codes.

Code Meaning
ROKU-BREAK-START-SHIFTED A break's start moved to a segment boundary. reason (earlier/later), signed shiftSeconds, requestedStart, spliceStart.
ROKU-RESUME-SHIFTED The return to content moved content by more than 1 ms. reason (delayed/advanced), signed shiftSeconds, nearestBoundary.
ROKU-BREAK-HELD Publication waited for a preparing pod. reason (pod-ready/skipped), heldSeconds.
ROKU-PREPARATION-RETRY A failed pod download is being retried. reason, attempt.
ROKU-PREPARATION-FAILED A pod could not be prepared; the break is skipped, or ends if already published. reason, optional evidence.
ROKU-MEDIA-FAILED Content or ad publication failed. Before startup completes it fails the start; after publication it ends playback.
ROKU-PUBLICATION-FAILED The local playlist snapshot was invalid.
ROKU-PROXY-ERROR The local HLS proxy failed or did not stop in time.
ROKU-SOURCE-EVIDENCE Informational: content verification is waiting for evidence (for example a slow segment). Playback continues.
ROKU-MANIFEST-FAILED A break manifest request failed.
ROKU-MANIFEST-INVALID A break manifest failed validation; it is not used and is polled again after 5 s.
ROKU-MANIFEST-UNSUPPORTED The manifest cannot be used for Roku insertion (for example not wallclock).
ROKU-POLLING-INVALID The manifest's polling instructions were invalid; the manifest is polled again after 5 s.
ROKU-RESOURCE-LIMIT Too many breaks: a manifest over the limit is not used; more than 512 breaks listed or in progress at once stops ad insertion.
ROKU-IMA-FAILED IMA pod serving could not be set up; it is retried after 10 s and breaks due meanwhile are skipped.
ROKU-IMA-STOP-TIMEOUT, ROKU-DAI-STOP-TIMEOUT The IMA task did not stop in time during cleanup.
ROKU-PARAMETERS-FAILED Updating the ad tag parameters failed or timed out; the break is skipped.
ROKU-SSAI-PARAMETERS-FAILED SSAI: updating the DAI ad tag parameters failed or timed out.
ROKU-SSAI-CLIENT-BREAKS-IGNORED SSAI: event-triggered manifest breaks are not rendered.
ROKU-MACRO-FAILED The application's macro resolver failed or timed out; registered values are used.
ROKU-PLAYER-CLOCK-INVALID A supplied playerClockAnchor was rejected; it needs a verified source Program Date Time.
ROKU-PLAYBACK-EPOCH-CHANGED Playback jumped (for example a viewer seek); old tracking is fenced and a reload is required.
ROKU-VIDEO-BINDING-CHANGED videoNode changed during a session; start a new session.
ROKU-SEEK-RESUME-FAILED, ROKU-SEEK-REFILL-NOT-READY Experimental DVR reload could not resume, or its ads were not prepared in time.

Capabilities

getCapabilities() describes the installed version, for example deliveryModes: ["sgai", "ssai"], sourceProgramDateTimeRequired: true, appOwnedVideo: true, cmaf, demuxed, abr, maxRenditions: 8, drm: false, lowLatencyParts: false, sourceHoldBack: true, unalignedBreakStart: "nearest-segment-boundary" and alignmentToleranceSeconds: 0.25. Check it instead of assuming a feature.

Limitations

  • A break that fails after publication ends playback; the app must start a new session.
  • DVR (reloadAfterSeek, startup resume) is experimental and not covered by the supported scope.
  • GAM can return less advertising than the break requests; the SDK plays what it receives and reports the shortfall.
  • Only compatible content/ad rendition topologies are stitched; an incompatible pod is skipped before anything is shown.
  • The SSAI path supports Google DAI full-service live HLS only (no DVR, VOD, DASH or client-side breaks).

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Pending changes live as one file per change under changelog/ and are merged into [Unreleased] when a version is cut.

[Unreleased]

[1.6.0] - 2026-11-12

Added

  • A new opt-in manifestUrlDiscovery setting starts THEOlive ads sessions from the player-discovered manifest URL on web, Android and iOS, with THEOplayer 11.15.0 or later required on iOS.
  • OptiView Ads for Roku now switches to an event's ad configuration (ad delay, delivery and GAM settings) when playback crosses the event's start or end. SGAI event timing follows playback PDT, and an SSAI event switch waits for the current stitched break to end.
  • L-shape breaks can place the video box in any corner of the picture with the manifest anchor field.
  • On the web, an ad break that its ads do not fill entirely now shows the slate from the break manifest for the rest of the break, and ends exactly at the break end.
  • On single-surface devices such as iPhone Safari, a video slate now also fills the part of a break that the ad leaves uncovered.
  • On Android, an ad break that its ads do not fill entirely now shows the slate from the break manifest for the rest of the break, and ends exactly at the break end.
  • On iOS and tvOS, an ad break that its ads do not fill entirely now shows the slate from the break manifest for the rest of the break, and ends exactly at the break end.
  • Companions, backdrops, image ads and pause images now play animated GIF and WebP images on Android, iOS and tvOS.
  • Roku apps receive the adtimeupdate event with the current time and duration of the playing ad, for SGAI and SSAI.
  • Starting VOD playback from a saved position skips the pre-roll and earlier ad breaks; a break at the saved position plays.
  • Support Google Ad Manager pause creatives with wrapper resolution and click, close and video tracking.
  • Apps can read the scheduled ad breaks for this viewer and get notified when they change, to draw ad markers on the scrubber.

Changed

  • VAST ads on Android and iOS now prefer the HLS rendition when the VAST response offers one, falling back to MP4.
  • Roku event timestamps now include millisecond precision.
  • Stop showing pause ads after the rotation is exhausted instead of repeating earlier ads.
  • Content keeps playing after seek-over snapback breaks using Overlay, Double Box, or L-Shape Content.
  • VOD seeks across multiple ad breaks now play only the last crossed snapback break, with no fallback if it was already played or cannot play.

Fixed

  • Starting AirPlay at the end of an ad break now switches the receiver to the server-side beaconing stream without the break's content resume interfering, and ending AirPlay resumes content right away.
  • On the web, the ad seconds of a break are now counted exactly for a multi-ad VAST response, an ad that ended naturally and an ad that failed partway, so content resumes at the right position after the break.
  • On Android, the ad seconds of a break are now counted exactly for a multi-ad VAST response and an ad that ended naturally, so content resumes at the right position after the break.
  • On iOS and tvOS, the ad seconds of a break are now counted exactly for a multi-ad VAST response and an ad that ended naturally, so content resumes at the right position after the break.
  • Android: reusing backdrop or companion artwork across breaks no longer crashes playback.
  • Android: in double and L-shape breaks, the player's black bars no longer cover the backdrop around the content box.
  • On the web, an image slate is now shown over the player instead of below it, where the last ad's video pushed it out of view.
  • On the web, an ad that fails to show a picture no longer reports a missing picture while the slate is on screen.
  • Post-roll ads now start when VOD playback reaches its end even if the player omits the ended event.
  • Avoid starting post-rolls when content is paused just before its end.
  • Report known live status in the iOS THEOplayer and AVPlayer adapters and require explicit VOD status for inferred post-rolls.
  • Prepare VOD post-roll ads before content ends, including post-rolls with no delay.
  • Pause-ad resume controls now follow the resolved VAST creative type.
  • Pause ads now allow playback to resume when an image cannot load.
  • Pause ads now send impressions only for the selected creative and its wrappers.
  • An ad break the viewer already watched no longer plays again when the viewer rewinds and then seeks into it.
  • Ad break status now reports completion before returning to idle on web, Android and iOS, including React Native.
  • Ads that fail before playback no longer report an ad end on Web, Android or iOS.
  • On web, an HLS video slate now plays after a break of HLS ads instead of failing and returning to content early.
  • On React Native for iOS and Android, registering a manifest response interceptor no longer drops every ad break.
  • Android no longer crashes when an L-shape or double break shows an image backdrop on some screen sizes.
  • On Android, content now glides smoothly back to full screen when a double box or L-shape break ends, instead of jumping to the centre first.
  • On React Native for iOS and Android, the slate from the break manifest now fills the part of an ad break that no ad covers.
  • Fixed Android ads not starting after seeking to a break while its companion image is loading.
  • On Android, content no longer stays paused after L-shape content and overlay breaks when the app's player handles audio focus.
  • VOD snapback now returns to the requested content position after a content-pausing break when seeking across its start, regardless of ad duration.
  • Prevent stale content positions from triggering earlier ads after a snapback return seek.
  • VOD seeking no longer forces ads based on their declared duration or repeats a seek after the player lands near its target.
  • Video ad breaks are no longer missed during fast-forward or sparse playback updates.
  • Viewer seeks and fast-forward playback resume from the correct content position after video ads.
  • On iOS and tvOS, an image slate or image ad shown after a video ad no longer shows that ad's last frame beside the image.
  • On Android and iOS, a full-screen ad break now hides everything the content player draws outside its picture, such as subtitles in the letterbox bars.
  • On React Native iOS, clickAd() now resolves null instead of undefined when there is no click-through URL.
  • On Android and React Native, the aderror for a slate that cannot play and the adclick on a slate now carry the slate asset.
  • AirPlay picked during an ad break on iOS no longer stalls the ad: the ad plays on the receiver while the request waits and the server-side beaconing stream takes over at the end of the break, and an ad paused by an audio-session interruption now resumes.
  • On web, a looping video slate no longer ends the ad break early with an aderror while it is still playing.
  • On iOS and tvOS, an ad whose media fails at once no longer reports progress or quartiles afterwards, and the slate then fills the rest of the break.
  • On Android, iOS and tvOS, an ad that never starts playing no longer ends the break: the next ad or the slate plays.
  • The break countdown in the ad break status now counts down while the slate plays, on web, Android, iOS and React Native.
  • On web, Android, iOS and React Native, an ad break that shows the slate now ends at its scheduled end, even when an ad failed or the slate was slow to start, stalled or looped.
  • On web, Android, iOS and React Native, the break countdown now keeps counting down to the break end while the slate plays.
  • Content no longer freezes on Android after a live ad break that ends before its scheduled end; it resumes at the live edge.

[1.5.1] - 2026-11-05

[1.5.0] - 2026-11-05

Added

  • VOD seeks into or over an unplayed snapback break now play the full break before returning to the appropriate content position, for every playable ad format: Single, Double Box, both L-Shape variants and Overlay. Seek-over restores the requested position even when the format keeps content playing.

Fixed

  • On Android, the second and later VAST ads in a session, and the ads that follow them, are now visible from their first frame instead of staying hidden while they play.

  • Prevent content from advancing while an immediate pre-roll loads on Android, React Native Android, and iOS; pause immediate pre-rolls and VAST breaks at break begin while retaining deferred pauses for static mid-rolls and delayed pre-rolls.

    Android VAST mid-rolls now pause content at break start, keeping a frozen content frame behind the overlay until IMA's first frame, matching iOS.

  • Android and iOS ad diagnostics now identify the playing break correctly when multiple breaks share an asset.

[1.4.0] - 2026-11-04

Added

  • The React Native package exports the ChannelEvent, ExternalPlaybackConfig, ExternalVendorConfiguration, ExternalVendorConfigurationChangeEvent and LiveStartPushbackConfig types, and the web package exports ExternalVendorConfigurationEntry and ExternalVendorConfigurationChangeEvent.
  • The web SDK now reports DA-AD-SURFACE-REVEALED when an ad first has a picture on screen, like Android and iOS, including how long the ad surface was visible without one.

Fixed

  • Fixed an issue where ad playback could show a black screen during picture-in-picture transitions on iOS.
  • On iOS and tvOS, a VAST ad that starts a break is now visible from its first frame instead of only after 10 seconds.
  • On the web, the ad no longer goes silent in the last 30 seconds of a live break or in a chained break that follows it, content no longer stays muted when a session ends during a continueContentDuringBreak break, and an IMA ad unmuted with sdk.muted keeps the viewer's volume.
  • React Native: changing only the targeting macros in the THEOplayer binding's session configuration now updates the running ads session instead of restarting it.

[1.3.0] - 2026-10-28

Added

  • Static ads, companions and pause ads now carry asset parameters from the break manifest and the app, with macros filled in, on their resource URL.
  • Player adapters report AirPlay (external playback) state to the SDK and can block it on request.
  • Ad configuration now follows channel events: the SDK switches to an event's ad configuration when playback crosses the event's start or end, and adchannelchange reports the event with reason event-boundary and eventId.
  • A DA-BREAK-CHAIN diagnostic summarises each chain of back-to-back ad breaks, and break-to-break transitions now report how the next ad was loaded.
  • AirPlay cannot start during an ad break or in the seconds before one when the channel provides a server-side beaconing stream.
  • The Roku SDK is also published as a signed component-library package (.pkg) next to the ZIP, listed in the hosted manifest and landing page.
  • When AirPlay starts on a channel with a server-side beaconing stream, the SDK plays that stream on the receiver and returns to the original content when AirPlay stops.

Changed

  • Asset-parameter macros that return an empty string, null or undefined now omit their parameter, and only the affected pair of a parameter list with & is dropped.
  • On Android, the next back-to-back ad break's first ad is buffered while the previous ad plays, so static ad breaks switch without a visible gap.
  • The adchannelchange event and the ad-break status report the delivery mode as sgai, ssai or ssb; on Android and iOS the field type is now SessionDeliveryMode.
  • On iOS, the next back-to-back ad break's first ad is buffered while the previous ad plays, so static ad breaks switch without a visible gap.
  • On web, the next ad is buffered while the current ad plays, inside a multi-ad break and between back-to-back breaks, so static HLS ads played by the default ad player switch without a visible gap.
  • Live start pushback now applies only when liveStartPushback.enabled is true; Anvato cue signaling no longer turns it on by default.
  • The Roku OptiViewAds node now emits events through addEventListener and removeEventListener instead of the operationResult, sdkEvent, diagnosticEvent and gatewayRequest fields.
  • Roku SDK releases are published as a signed component-library package together with a ZIP archive.
  • On Safari, THEOplayer's AirPlay state is held for 500 ms before the SDK treats the route as ended, as the other web adapters already do.

Fixed

  • Back-to-back ad breaks published while an earlier break is playing now join the chain, and changes to the next break are applied before it plays.
  • On iOS and Android, the next back-to-back ad break now plays when the previous break is cut short at its end time, instead of being skipped.
  • On iOS, live content now resumes at the end of a chain of back-to-back ad breaks instead of at the end of the first break.
  • A failed AirPlay switch to the server-side beaconing stream no longer emits an unmatched adchannelchange, the AirPlay availability flag stays true while that stream plays, and route changes during the switch no longer log stray gate diagnostics.
  • The SDK no longer warns about an ignored delivery-mode change on every manifest poll while AirPlay plays the server-side beaconing stream.
  • On Safari, the switch to the server-side beaconing stream no longer cancels itself when Safari re-establishes the AirPlay route, and Safari's transient connecting reports no longer trigger repeat switches or stray gate diagnostics.
  • On web, the second of two back-to-back ad breaks no longer ends right after it starts when its ad was not buffered in time.
  • AirPlay now switches to the server-side beaconing stream when the player reports the connection without a connecting step.
  • On iOS, THEOplayer-based apps no longer play the server-side beaconing stream on the phone when the viewer starts screen mirroring; mirroring now falls back to the local ad experience like the other players.
  • On Safari, THEOplayer-based web apps no longer end the content AirPlay route when a client-side ad break starts; the ad plays on the device while the receiver keeps the content.

[1.2.1] - 2026-10-23

Added

  • The Roku SDK selects delivery mode, break variant and asset by platform, OS and OS version.

Changed

  • The Roku SDK is no longer experimental.

Fixed

  • Prevent Apple React Native players from crashing when moving between inline and expanded screens.
  • Fixed gray frames and buffering indicators during picture-in-picture ad transitions on Apple platforms when empty spare players are present.

[1.2.0] - 2026-10-22

Added

  • Add an adbreakskipped event for scheduled ad breaks that cannot begin.
  • Add an experimental Roku SDK: a SceneGraph OptiViewAds component that inserts Google Ad Manager ad pods into clear live HLS streams with program date time through one app-owned Video, or plays the channel's Google DAI live stream when the break manifest selects server-side ad insertion for TV devices.
  • Read resolved external vendor parameters and listen for template changes.
  • Added a player-free API for reading external provider parameters before playback.
  • Roku ad breaks that cannot play report the specific skip reason, and Roku diagnostics report how break starts and returns to content were aligned.
  • Target ad content by platform, operating system, and OS version.
  • Ad targeting can now select Vizio TVs and Xbox consoles in web players with the os values vizio and xbox, and game consoles with the deviceType console.
  • The experimental Roku SDK is available on npm as @dolby-optiview/ads-sdk-roku and installs with ropm or by copying its files into a channel.

Changed

  • The SDK now recognizes and validates external vendor configuration entries from manifest spec 1.6.0 and reports invalid or duplicate entries.
  • The switch between content and an ad is now a cut on web, Android, iOS and tvOS: no cross-fade in or out; the transition setting only times the two-box layout reflow.
  • External vendor configuration keeps unresolved break-duration macros as literal text.
  • GAM session parameters that use a break-duration macro are now sent with the macro as literal text, instead of being left out.
  • With an ad start delay, the ad stream is now requested only after the viewer has watched the ad-free start.
  • In web players, linux, windows and android targeting no longer matches Vizio TVs and Xbox consoles, and tv targeting no longer matches Xbox consoles.

Fixed

  • Companion images no longer stay on screen after back-to-back ad breaks.
  • The content no longer covers a full-screen ad that directly follows a double-box or L-shape ad break.
  • Ads now transition smoothly to and from content in iOS picture-in-picture, without a grey placeholder or spinner.
  • On hls.js, Shaka and the browser's own video player, an ad that cannot be loaded now reports DA-AD-MEDIA-LOAD-FAILED and an ad that is not playable media reports DA-AD-MEDIA-UNSUPPORTED, instead of the generic DA-AD-PLAYBACK-ERROR. A failing ad now reports one aderror.
  • Replacement breaks on wallclock manifests now resume exactly at the break's start plus duration on the stream's Program Date Time, whatever the ad's first frame took, and report a late cut and the resume landing.
  • On iOS and tvOS the ad's first frame is now on screen at the break start: the break preparation warms the ad up to its first frame on the ad player instead of starting it cold at the cut.
  • On iOS and tvOS a wallclock break is now triggered on the exact program-date-time instant instead of up to a player-snapshot refresh late.
  • GAM pod streams with separate fMP4 audio and video no longer report every ad event twice.
  • Shaka Player ad playback now reports quartile and per-ad events for Google Ad Manager pods delivered as fMP4.
  • Vizio SmartCast TVs are now recognised as TV devices for delivery steering and asset targeting.
  • Fixed playback of ad variants targeted by platform, operating system, and operating-system version.
  • When the ad stream cannot be set up, its breaks are now skipped instead of starting and failing.
  • On iOS, the ad session failure diagnostic now includes the reason reported by Google IMA.
  • Web players on Samsung TVs whose User-Agent has no Tizen version now report the os tizen instead of linux.

[1.1.1] - 2026-10-14

Changed

  • The resume landing diagnostic now also reports how far content resumed from the intended resume point when the live window shortened the resume seek.

Fixed

  • On iOS and tvOS with ptsSource anvatoCue, live content resumes at the break end the stream signals, so it no longer resumes inside the stream's own break.
  • On iOS and tvOS with ptsSource anvatoCue, live content resumes on the stream's own clock when the stream carries Anvato beacons, so a player timeline shift during the break no longer moves the resume point.
  • On the web with ptsSource anvatoCue, live content resumes at the stream's own break end, on the stream's own clock when the stream carries Anvato beacons.
  • On Android, live breaks on Anvato-signaled streams now return to content where the stream ends the break, without showing the end of the slate or pausing to rebuffer.
  • On Android with THEOplayer, long sessions on Anvato-signaled streams no longer slow the app down as in-stream markers accumulate.

[1.1.0] - 2026-10-12

Added

  • The iOS THEOplayer adapter, React Native bridge and PlayerAdapter conformance test kit are now documented as SwiftPM binary targets, and the test kit is now published as an xcframework and a CocoaPod.
  • A new diagnostic reports the real playable duration of a break's ad media as soon as it is prepared, before the first ad frame.

Changed

  • Ad break end events now report the available and requested ad seconds alongside the filled and watched seconds.
  • Ad error events now report a specific error code in CMCD (for example no fill, media load failure or start timeout) instead of a generic playback error, on web, Android and iOS.
  • Analytics reports to Lens are now bundled, up to 10 events or 60 seconds per request, instead of one request per event.
  • Live playback with Anvato cue signaling now starts at least five target durations behind the live edge by default when timing information and the playback window allow it; other live streams can opt in with liveStartPushback.enabled.

Fixed

  • Ad creatives played through hls.js on Safari now end on time, so multi-ad breaks play every ad instead of stopping after the first.
  • Content now resumes inside the Safari picture-in-picture window after a shared-element break instead of closing it.
  • Content resumes after a picture-in-picture ad break on Safari with Shaka Player instead of staying paused.
  • Content resumes at the start of the live window instead of landing seconds late when the resume position has already left the DVR window after a live pre-roll.
  • An ad load that stalls with no media progress is retried once before the break is ended with an ad load timeout.
  • On iOS, content after a live ad break now resumes as close to the live edge as the stream allows.
  • Fixed ad controls remaining over content after an ad break ends on Android.
  • Preserve React Native web content when ads sessions are replaced.
  • On iOS and tvOS, content after a live ad break no longer resumes slightly before the intended point.
  • Fixed React Native SDK imports during Next.js server-side rendering without application-specific resolver aliases.
  • Content now resumes on the correct live position after an ad break on iOS and tvOS.
  • Android React Native ads now resize immediately when entering or leaving fullscreen during playback.
  • Content now resumes at the correct point after an ad break watched in picture-in-picture on iOS and tvOS.
  • THEOplayer: a failed ad creative load now reports DA-AD-MEDIA-LOAD-FAILED or DA-AD-MEDIA-UNSUPPORTED instead of the generic DA-AD-PLAYBACK-ERROR, matching the other web adapters.
  • The ad break countdown (adbreakstatus breakRemainingSec) no longer jumps back up when an ad reports playback progress before it begins (GAM pods on THEOplayer, preloaded iOS midrolls).
  • Fixed an empty VAST response being reported as a failed ad request instead of no fill on iOS.
  • Content now resumes at the correct position after a live ad break on Android.
  • Lens analytics now report the start of pre-roll, pause and post-roll ad breaks as start, pause or end, and timed ad break starts in milliseconds.
  • Lens analytics now report the filled seconds of a VAST ad from the creative duration the ad player resolved, so a short creative in a longer ad slot no longer counts as filling the whole slot.
  • Content now resumes on the published live window after an ad break instead of being pulled back by the player's preferred live latency.
  • On iOS and tvOS, content no longer downloads video segments while an ad break is playing.
  • Live DASH ad breaks signaled in-stream now start and resume at the signaled time on THEOplayer (web and Android) and Shaka, instead of up to one segment early.
  • GAM multi-ad pods now report every ad when Google IMA ends the ad break before the pod's last ad.
  • On iOS, live content now resumes at the right point and quality after long ad breaks when using AVPlayer.

[1.0.0] - 2026-09-24

Added

  • The Android SDK's public API now carries KDoc documentation, visible in the IDE and rendered as an HTML API reference.
  • The web API reference now covers the hls.js, Shaka Player and THEOplayer adapter packages, and their TypeScript declarations carry full documentation.
  • The React Native SDK's exported API now carries full TypeScript documentation, rendered as an HTML API reference.
  • React Native THEOplayer integrations can use the same player setup on native and web.
  • React Native web THEOplayer integrations now expose ad events and ad playback time through the player facade.
  • React Native iOS and tvOS THEOplayer hosts now expose Dolby ad lifecycle, playback state and sampled progress through THEOplayer's native player and Ads APIs.
  • React Native apps can retain ads sessions across UI handoffs or let a React hook manage their lifetime.
  • Prepare missing browser compatibility support automatically during session startup without changing the SDK integration or replacing native APIs.
  • On iOS, content is pre-positioned or catches up behind a live break so the resume lands on the policy target.
  • React Native integrations can reuse player binding and optional ad debugging hooks without coupling playback to application UI.

Changed

  • The DA-RESUME-SEEK diagnostic now also reports what live resume alignment did during the break.
  • The React Native package now declares the OptiView terms-of-service license instead of MIT.
  • Android SDK internals that were public by accident are now marked @OptiViewInternalApi or made internal; an app that used them gets a compiler warning or error and should move to the public API.
  • The Apple SDK's internal scheduling, sequencing and parsing types are no longer part of the supported public API or the DocC reference.
  • Android React Native integration now uses typed THEOplayer APIs and requires react-native-theoplayer 11.7.0 or newer as a project dependency.
  • Quartile, click and ad error telemetry now carry the same creative and pod position dimensions as ad start and end.
  • Ending a session during an ad break now reports the partial ad watched and filled durations to Lens.

Fixed

  • An ad break whose ad fails to load no longer skips part of the content after the break.
  • Content resumes reliably after a picture-in-picture or shared-element ad break on Safari with Shaka Player, instead of staying paused.
  • GAM pod ad breaks now report the requested, filled and watched ad seconds in CMCD telemetry.
  • Prevent content decoder contention during ad transitions on single-decoder TVs and fully release native ad media before returning to content.
  • GAM pod ads that play through the content player (picture-in-picture on iOS and Safari, iPhone playback) are now reported to Google, so tracking beacons fire and, on iOS, each ad in the pod is reported separately.
  • After a break played through the content player on iOS, content that resumed normally is no longer reported as stalled or nudged with an extra play().
  • Ad stall and resume events (waiting and playing with source ad) are now emitted on iOS, and on the web when the ad plays through the content player; the break countdown pauses while an ad buffers.
  • Android: an immediate pre-roll now waits for content to be ready before starting and is cancelled when the content fails to load.
  • Fixed React Native web ad initialization with THEOplayer methods that cannot be reassigned.
  • Prevented internal content pauses from reaching React Native web player facade consumers during ad handoff.
  • Reported React Native web ad breaks as client-side ads for analytics while preserving Dolby provider metadata.
  • React Native web players now expose Dolby ad playback state and route mute and volume through the active audio owner.
  • React Native web playback no longer exposes background content events during content-replacing ads or internal seek notifications during the return to content.
  • Automatically exclude optional THEOplayer integration from Android apps using only react-native-video.
  • Include Android player bindings in the React Native npm package so clean app builds compile successfully.
  • React Native iOS fullscreen playback now preserves valid Google IMA view-controller containment when an ad break starts.
  • Content now resumes after an ad break on VIZIO SmartCast TVs by rebuilding the content player's media pipeline before resuming.
  • Preserve ad playback time during startup on Web, Android, iOS and React Native, and enable web THEOplayer metadata for ad tracking.
  • Improve ad playback compatibility on older Chromium-based devices.
  • The ad break countdown no longer reaches zero early during multi-ad pods, and the remaining-ads count is correct after each ad.
  • React Native apps can now select which side keeps audio during a double-box break via doubleBoxAudio.
  • On Android, a double-box break with content audio focus no longer pauses a content player that reacts to audio-focus loss.
  • Fix session startup on older Chromium devices when requests have no custom headers.
  • React Native iOS apps using THEOplayer now resume content at the correct position after a break.
  • A completed ad break no longer replays right after it ends when live content resumes on iOS or Android.
  • Keep iOS ad breaks working when captions change in THEOplayer.
  • Allow video ads up to ten seconds to start on Android and iOS, matching the web GAM pod timeout.

[1.0.0-beta.6] - 2026-09-11

Added

  • The React Native SDK can now be installed from the public npm registry.

[1.0.0-beta.5] - 2026-09-11

[1.0.0-beta.4] - 2026-09-11

Added

  • Asset parameter macros can resolve to null to omit the parameter (or, for GAM, the containing cust_params pair) from the ad request.
  • Android asset-parameter macros can return an empty value so the parameter that contains the macro is left out of the ad request.
  • On iOS, asset parameter macros can now return AssetParameterMacroValue.empty so the parameter that contains the macro is not sent to the ad server.

Changed

  • Android SDK releases are now available from the THEOplayer Maven repository.

Fixed

  • Ads now play the correct creative when picture-in-picture changes the selected variant after preloading.
  • Content restoration after shared-element ads now stops retrying and reports failures when the player does not respond.

[1.0.0-beta.3] - 2026-09-10

[1.0.0-beta.2] - 2026-09-10

Added

  • Asset-parameter macros can now be updated during playback with updateAssetParameterMacros(); the new values apply to the next ad request.
  • Android and iOS: asset-parameter macros can now be updated during playback with updateAssetParameterMacros(); the new values apply to the next ad request.
  • React Native: asset-parameter macros can now be updated during playback with updateAssetParameterMacros(); the new values apply to the next ad request.
  • Post-roll ad breaks (event-triggered on content end) now play on Android, iOS, tvOS and React Native.

Fixed

  • THEOplayer no longer ends an ad early when the previous ad's end event arrives after the next ad has started loading.
  • A pending pre-roll no longer begins when the content fails to load.
  • Shaka Player content load failures are now reported to the SDK as content errors.
  • Wallclock-scheduled live ad breaks now start reliably on Safari native HLS playback.
  • Ad pods that were preloaded now load every ad in the pod, not only the first one.
  • GAM pod ad tracking on Shaka Player and THEOplayer now receives ID3 markers when the playhead reaches them, so per-ad reporting is correct.
  • THEOplayer no longer reports the first ad's quartiles twice when a GAM pod starts.
  • React Native: a manifest interceptor that returns the mock manifest as an object is now applied on iOS instead of falling back to the network.
  • Android: adbegin and adend events for ads in a GAM pod now include the ad asset.
  • The npm packages now show the correct Dolby license and OptiView Ads SDK homepage.
  • Ads ended by the break-cut timer now report the CMCD end reason a (aborted) instead of c (completed).
  • React Native Android now reports a null channel id in the adchannelchange event when the switched channel has no id.
  • Asset parameters are no longer appended to inline data: VAST tag URLs, which made the ad response unparsable on Firefox.
  • Handle deferred picture-in-picture entry and prevent ad breaks replaying when content resumes on iOS.
  • THEOplayer on Safari now applies a seek made while the player is still seeking, so seeking back over a finished ad break re-arms it.
  • iOS: OptiViewAds and the renderer callback protocols are now main-actor isolated, fixing data races (crashes) when session, ticker, and renderer work overlapped on different threads.
  • Multi-ad Google Ad Manager pods now report one ad per creative even when the player starts the pod slowly or IMA reports the first ad early.
  • iOS: adbegin, adend and quartile events for the ads of a GAM pod now carry the per-ad asset, so React Native iOS receives these events instead of dropping them.

[1.0.0-beta.1] - 2026-09-08

Added

  • Pre-roll breaks now use the manifest specification event trigger (start: { type: "event", event: "start", delay }). The delay counts played content time only and starts when content playback begins.
  • Pause ads use the manifest specification event trigger: a pause ad is a break whose start is { "type": "event", "event": "pause", "delay": <seconds> } with a standard variant (for example single) holding an image or video asset. Several pause breaks rotate in manifest order, one per pause, and wrap to the first when exhausted; start.delay is the time the content must stay paused before the creative appears; controls.skipOffset keeps the resume and close controls hidden until the offset has elapsed (DA-PAUSE-AD-RESUME-ALLOWED / DA-PAUSE-AD-RESUME-BLOCKED). Web, Android, iOS and React Native.
  • Break manifests can use the mediatime timebase for VOD assets: break start is seconds from the start of the asset.
  • Post-roll breaks: a break with an end event trigger plays when content playback ends (web).
  • Android: when a polled break manifest switches to another ads channel, the SDK re-aligns its ad setup to the new channel and emits an adchannelchange event.
  • The SDK follows a manifest-driven ads-channel switch inside the running session and emits an adchannelchange event.
  • The break manifest server can serve a channel through a stable alias URL that can be re-pointed to another channel.
  • The SSAI stitcher accepts the mediatime timebase for VOD break manifests.

Changed

  • NFL live timeline reporting now uses the runner callout channel, allowing live NFL cells to run with the hosted MCP driver.
  • An ads-channel switch detected during an ad break now takes effect after the break has finished, and a switch before playback starts adopts the new manifest's ad start delay.
  • Demo presets and test manifests declare the mediatime timebase for VOD breaks instead of pts.
  • When the ads channel switches, the delivery mode (sgai or ssai) is resolved again from the new manifest and the player switches mode when it differs; the adchannelchange event now reports previousDeliveryMode and deliveryMode.
  • Session-level asset parameters from the break manifest now override the application's asset parameters and are applied when the manifest changes.
  • Asset-parameter macros now end with a closing dollar sign, for example $OPTIVIEW_USER_AGENT$, so a macro name that is a prefix of another name is never replaced by mistake.
  • An asset parameter whose macro has no value is now sent with the macro kept as its literal text instead of being dropped.

Removed

  • Legacy pause-ad manifest syntax. position: "pause", a break-level delay used as the pause delay, and the variant formats pause and pause_image are no longer recognised; BreakPosition is now only "pre". Migrate to start: { "type": "event", "event": "pause", "delay": <seconds> } with a single variant; the MCP validate_manifest tool reports the old fields and shows the new syntax.

Fixed

  • Seeking on Safari while the player is still completing a previous seek now lands at the new position instead of being ignored.
  • Pause ads now show when content is paused in Safari native HLS playback.
  • Ads no longer fail to start on Samsung Tizen TVs when the TV briefly pauses the ad element while playback is starting.
  • iOS/tvOS E2E agents now read brokerUser/brokerPass from xagget deep links.
  • The iOS SDK now reads manifest numbers with the value 0 or 1, such as a pre-roll start delay of 0, instead of ignoring them.
  • React Native: JavaScript asset-parameter macros are refreshed before a changed manifest session layer is pushed to the ad server, so the pushed values are no longer stale or literal.

[0.53.0] - 2026-09-05

Added

  • Generated API reference for the public web SDK surface (OptiViewAds, configuration and session types, events, diagnostics, and PlayerAdapter) under docs/api/.

[0.52.0] - 2026-09-04

Changed

  • BREAKING: useAnvatoID3 is replaced by ptsSource. Use ptsSource: 'anvatoCue' on web, PtsSource.ANVATO_CUE on Android, .anvatoCue on iOS/tvOS, or "ptsSource": "anvatoCue" in React Native for Anvato cue signaling; the default mediaTime keeps the previous behavior.
  • Diagnostic reports expose config.ptsSource instead of config.useAnvatoID3.

[0.51.0] - 2026-09-04

Not published: the release pipeline failed. The content below ships with the next release.

Added

  • Web and Android: opt-in continueContentDuringBreak keeps content playing hidden and muted behind eligible replacement breaks (default false).
  • Break Manifest 1.3.0 asset parameters: vast assets can carry assetParameters, $OPTIVIEW_* macros are expanded, and SessionConfig.assetParameterMacros registers custom macros (web, Android, iOS, React Native).
  • Break manifest signature verification on all platforms; an unsigned or invalid manifest is rejected with DA-MANIFEST-SIGNATURE-INVALID and schedules no breaks.
  • Manifest-driven delivery steering: the manifest's delivery rules choose the ad-insertion architecture per session on web, Android, and iOS/tvOS.
  • Ad-free session start via the manifest's adStartDelay, counted in played media time.
  • Anvato break signaling over DASH emsg on all DASH-capable platforms.
  • Break-variant selection with device targeting and format fallbacks on all platforms.
  • Lens observability is built into the SDK on every platform; CMCD ad events are reported through Lens.
  • GAM identity diagnostics DA-GAM-CONFIG-RESOLVED, DA-GAM-CONFIG-MISSING, and DA-GAM-POD-IDENTITY-MISMATCH.
  • Android and iOS/tvOS: AdScaling (fit or fill) controls how ad creatives fill the ad surface.
  • Android: audio-focus diagnostics DA-AD-FOCUS-GRANTED, DA-AD-FOCUS-DENIED, and DA-AD-FOCUS-ABANDONED.
  • Android: Lens reports carry the device class and a persistent user ID.
  • React Native: connector.seek(time), connector.getPresentationState(), and connector.notePictureInPicture(active).
  • React Native tvOS support.
  • CocoaPods distribution of the iOS/tvOS pods through a private Specs repository.
  • MCP: decode_cue, explain_concept, resolve_config, and validate_break_manifest tools; scaffold_quickstart covers SSAI and native platforms; explain_event_timeline reports per break.

Changed

  • BREAKING: npm packages renamed to @dolby-optiview/ads-sdk and @dolby-optiview/ads-sdk-<name>, Maven coordinates to com.dolby.optiview:ads-sdk*, and the SwiftPM package to optiview-ads-sdk. No compatibility aliases.
  • BREAKING: PlayerAdapter.liveSyncPosition renamed to maxLiveSeekPosition in all cores and adapters.
  • BREAKING: GAM is activated by the break manifest's vendorConfiguration; GamConfig.enabled is an explicit opt-out.
  • BREAKING: the break manifest decides where content resumes after a break on live and VOD; the SDK no longer defaults adInsertionType.
  • adPreload defaults to 'auto', and VIZIO SmartCast TVs are recognized as single-decoder devices.
  • CMCD adpos reports the 1-based position within the pod, platform and device-class tokens are abbreviated, and the manifest's organizationId is reported as adoid.
  • The Lens SDK is bundled into the published artifacts; installing the SDK needs no private registry.
  • A break variant with an unknown or missing format is skipped and reported.
  • A break with nothing to play no longer emits an empty adbreakbegin/adbreakend pair.
  • Android and iOS/tvOS: fullscreen ad surfaces and break layouts follow the visible content picture.
  • Published web packages are minified without source maps, Android artifacts are shrunk with R8, and iOS/tvOS frameworks are stripped.

Removed

  • BREAKING: gam.networkCode and SessionConfig.customAssetKey; the GAM stream identity comes from the break manifest.

Fixed

  • GAM pod ads on Shaka and THEOplayer pre-rolls no longer time out; cold GAM pods get a 10-second startup budget.
  • A viewer seek-back after a break re-arms DVR playback on all platforms.
  • CMCD ad telemetry sends brf, adast, and ader as bare tokens and reports correct timing, duration, and vendor error codes.
  • Every network read is bounded by a timeout on all platforms.
  • destroy() or endSession() during an in-flight startSession() no longer revives manifest polling.
  • A transient backward position blip no longer replays the just-completed break.
  • Anvato ID3 breaks preload as soon as the manifest arrives.
  • A healthy monetized tune-in remainder is no longer aborted by the wallclock window check.
  • Snapback enforcement no longer reacts to its own corrective seek.
  • Web: GAM-only breaks are skipped before adbreakbegin when the IMA stream session is unavailable.
  • Web: destroy() silences late diagnostics.
  • Web: the Shaka adapter reports programDateTime as null for live streams without EXT-X-PROGRAM-DATE-TIME.
  • Web: content resume after a break no longer races the ad decoder on single-decoder TVs.
  • Web: a stalled tune-in break can no longer run silent and replay in full.
  • Web: content returns when a break that adopted picture-in-picture mid-ad ends (Safari).
  • Web: a shared-element restore that never advances content is reported and repaired once.
  • Web: the ad stage follows the content media aspect ratio.
  • Web: the THEOplayer adapter no longer misses the ID3 track after a late attach.
  • Android: content stays paused when the host player auto-resumes during a break.
  • Android: content pauses when an ad starts before its first frame renders.
  • Android: picture-in-picture is detected under React Native.
  • Android: Maven artifacts are consumable from Kotlin 2.1.
  • Android: a break deleted from the manifest while playing returns to content instead of crashing.
  • Android: a cadence flip or session end no longer reports a false manifest poll failure.
  • Android (React Native): two-box break formats render as designed, companion artwork stays visible, and THEOplayer content-surface discovery works again.
  • iOS/tvOS: the ad surface tracks a mid-break resize.
  • iOS: entering picture-in-picture mid-ad no longer loses part of the creative, a window opened between sessions is recognized, and picture-in-picture closes at break entry on THEOplayer content.
  • iOS: an in-flight ad resumes after the app returns to the foreground.
  • iOS: concurrent diagnostics recording and manifest polling no longer crash.
  • React Native (iOS): endSession() no longer aborts the app while a GAM session is open; double, L-shape, and overlay layouts no longer collapse.
  • React Native (Android): GAM breaks open.
  • MCP: validate_break_manifest reports accurate results.
  • Demo: SSAI sessions start again.

[0.50.0] - 2026-08-17

Added

  • React Native: skipAd() and clickAd() viewer controls.

Changed

  • BREAKING: DolbyAds is renamed to OptiViewAds across every platform, with no compatibility aliases.
  • BREAKING: SessionConfig.manifestUrl is the only manifest input and is fetched verbatim; orgId, manifestBaseUrl, and channelId are removed.
  • BREAKING: assetParameters and updateAssetParameters() replace adTagParameters and updateAdTagParameters(); per-asset manifest parameters are applied and restored at break end.
  • BREAKING: SSAI sessions pass startSession({ stitcherUrl }); stitcherBaseUrl is removed.
  • The diagnostics report renames gam.hasAdTagParameters to gam.hasAssetParameters and reports manifestOrigin instead of orgId/manifestBaseUrl.
  • MCP scaffold_quickstart takes manifestUrl instead of orgId and channelId.

Fixed

  • React Native: ad click events reach JavaScript listeners.
  • Tune-in rules apply to joins that land inside the start tolerance.
  • A break that already ended when the playhead lands inside the start tolerance is skipped, and every break runs with a cut timer.
  • Instantly failing content-covering breaks announce content playback.
  • Web: double breaks degrade to a single fullscreen ad on phones and tablets, including modern iPadOS.
  • Web: content resumes after a shared-element break even when the restore stumbles; a second failure is reported as DA-SHARED-ELEMENT-RESTORE-FAILED.
  • Android: near-end resume seeks no longer strand the player in the ended state.
  • Android: post-break resume seeks are keyframe-aligned again.
  • iOS: a silent IMA request no longer stalls a GAM multi-break.
  • iOS: a break that ends without content resuming is reported as DA-CONTENT-RESUME-STALLED and repaired once.
  • iOS: GAM pods report their ads even when IMA reports before the break is bound.

[0.49.1] - 2026-08-13

Fixed

  • Web: a play button no longer covers a playing video pause ad.
  • Web: pause-ad resume re-anchors to live when the DVR window has moved on.
  • React Native: live SDK diagnostics are forwarded on Android and iOS through onDiagnostic/offDiagnostic.

[0.49.0] - 2026-08-13

Added

  • tvOS is a shipped platform: the Apple frameworks carry tvOS and tvOS simulator slices.
  • Releases publish to the public package managers as @optiview/ads-sdk.
  • The React Native iOS bridge packages are published as binary xcframeworks.
  • MCP scaffold_quickstart scaffolds React Native integrations for react-native-theoplayer and react-native-video.
  • iOS: break transitions reach Android parity with first-frame-gated cross-fade, dissolve at break end, deferred content pause, and the transition config.
  • Android: picture-in-picture is detected automatically; the host no longer forwards onPictureInPictureModeChanged.
  • Android: ad playback holds system audio focus for the duration of a break.
  • Genius Sports customer demo page.

Changed

  • React Native: the iOS pod and the Android bridge no longer require react-native-theoplayer when only react-native-video is used.
  • React Native documentation covers installation, the supported-player matrix, react-native-web integration, and the Android Maven setup.

Removed

  • BREAKING: the client-side polling override and fallback intervals; the manifest's polling object is the only cadence source.

Fixed

  • Removing a break from a polled manifest while it plays ends it immediately on all platforms.
  • Manifest polling matches the specification on all platforms.
  • React Native: connector.destroy() runs the host-player teardown on the main thread.
  • React Native (Android): bridge calls run on the player UI queue, overlay focus loss is diagnosed, and resume seeks stay exact.
  • React Native: the published package ships its podspec, the podspec no longer points at a nonexistent tag, and the tarball's dependencies resolve for clean installs.
  • iOS: content player errors keep their detail in DA-CONTENT-PLAYBACK-ERROR.
  • iOS: the host application's picture-in-picture is no longer cancelled.

[0.48.0] - 2026-08-07

Added

  • A hung startSession() reports the step it is waiting on (DA-SESSION-STARTING).

Fixed

  • NBA demo: GAM mid-roll pods play.

[0.47.0] - 2026-08-07

Added

  • NBA customer demo page.
  • React Native: react-native-video is supported as a second host player, with the useReactVideoHandle() helper.
  • React Native demo app and documentation.
  • The manifest fetch is bounded by a timeout on every platform.
  • A break abandoned by teardown is reported as DA-BREAK-ABANDONED.
  • A break that plays no ad is reported as DA-BREAK-NO-PLAYABLE-ASSET.
  • Android: a break the renderer cannot render is reported as DA-RENDERER-UNAVAILABLE, and an ad that stalls after starting as DA-AD-STALLED.
  • Android: fullscreen breaks cross-fade instead of cutting to black, and the transition is configurable.
  • Android: content plays under the break transition and is silenced from the moment the break begins.
  • Android: preloaded ads start with a frame already decoded.
  • Playback errors carry the cause, the requested and final URL, the HTTP status, and the response headers.
  • iOS and Android: DA-BREAK-TRANSITION reports sub-phase timing in debug mode.

Fixed

  • Android: content no longer stays paused after a break during which the viewer entered picture-in-picture.
  • Android and iOS: VAST ads are preloaded through IMA.
  • Android: GAM pods are preloaded.
  • Android and iOS/tvOS: quartile events fire for static assets.
  • iOS: the THEOplayer adapter no longer crashes on ID3 timed-metadata cues.

[0.46.0] - 2026-08-06

Fixed

  • SSAI stitcher: live manifests stay consistent across polls (append-only windows, correct discontinuity sequence, no creative looping).
  • SSAI stitcher: EXT-X-TARGETDURATION is raised when spliced ad segments exceed the origin's target duration.

[0.45.0] - 2026-08-04

Added

  • React Native: @dolby-ads/react-native with createDolbyAds(player, config), Android and iOS bridges for react-native-theoplayer, and a react-native-web runtime.
  • Web: DA-ANVATO-CUE-OBSERVED reports every Anvato break-signaling cue observed in the stream when useAnvatoID3 is enabled.

Changed

  • Bally's demo: the VAST tag is generated per ad break instead of typed in.

Fixed

  • Session teardown no longer emits DA-SESSION-ENDED twice or accepts late manifest polls.
  • Android: a multi-ad GAM pod reports one adbegin/adend pair per ad.

[0.44.0] - 2026-08-03

Added

  • pdtGraceSeconds configures how long a wallclock session waits for the stream's Program Date Time (web, Android, iOS).
  • adPreload: 'none' disables all pre-break activity.
  • Preload diagnostics DA-PRELOAD-MODE-RESOLVED and DA-PRELOAD-PATH.
  • iOS: a multi-ad GAM pod reports one adbegin/adend pair per ad.

Fixed

  • Android: playing is emitted once per playback start.
  • iOS: IMA receives timed metadata for GAM pods, so ad events and tracking beacons fire.
  • A wallclock session no longer schedules breaks against the system clock while waiting for the stream's Program Date Time.
  • A DAI mid-roll's post-break resume seek no longer re-fires the break on native HLS players.
  • Live mid-rolls on the native Safari adapter no longer re-fire a break that just ended.
  • The install documentation points at the current artifact host.

[0.43.1] - 2026-08-03

Fixed

  • Web: a GAM pod with several ads is reported as one adbegin/adend pair per ad, and quartile events are attributed to the right ad.
  • Published artifacts reference the host they are published to.

[0.43.0] - 2026-08-02

Added

  • iOS: the SDK drives system picture-in-picture for the content player, and getPresentationState() reaches parity with web and Android.
  • iOS: a viewer who opens picture-in-picture during a break gets the single layout.
  • Web: the SDK plays shared-element ads itself instead of handing them to the content engine, and PlayerAdapter.releaseMediaElement() lets the engine release its media element for the ad.

Fixed

  • iOS: the picture-in-picture format override reaches the public events, and picture-in-picture opens reliably.
  • Web: the SDK tracks the content element when the player swaps it.
  • Web: THEOplayer plays ads through the content element.
  • Web: a shared-element ad that never renders a frame ends the break with an error instead of silence.
  • Web: picture-in-picture state is reported consistently.

[0.42.0] - 2026-07-31

Added

  • Picture-in-picture forces the single layout on web and Android.
  • setPictureInPicture(), isPictureInPicture(), and getPresentationState() on web and Android.
  • Shared-element insertion works over MSE.
  • DA-PIP-TRANSFER-FAILED reports a picture-in-picture window that could not move to the ad element.

Fixed

  • Shared-element breaks report ad progress and quartiles.
  • A break no longer fires again immediately after ending.
  • The content gate no longer freezes an ad that took over the content element.
  • Android: an ad that never starts raises aderror instead of running the break out in silence.

[0.41.1] - 2026-07-30

Fixed

  • Shaka delivers Anvato break cues to useAnvatoID3.

[0.41.0] - 2026-07-30

Added

  • DA-BREAK-TRANSITION reports where a slow transition spends its time.

Fixed

  • iOS: Anvato cues are delivered when the integrator loads content directly.

[0.40.2] - 2026-07-30

Fixed

  • Safari delivers Anvato break cues to useAnvatoID3.

[0.40.1] - 2026-07-30

Fixed

  • Anvato cue-scheduled breaks no longer replay in a loop on live players.
  • Android: content resumes after a pausing break on a live stream with a pts timebase.

[0.40.0] - 2026-07-30

Added

  • DA-BREAK-TRANSITION measures the cost of every playback transition around a break.

Fixed

  • adPreload: 'auto' no longer deadlocks playback on modern Smart TVs.

[0.39.0] - 2026-07-30

Added

  • Anvato in-stream break signaling via the useAnvatoID3 option.

[0.38.0] - 2026-07-29

Added

  • Android: skipAd(), clickAd(), and the adclick event.

Fixed

  • iOS: pre-roll breaks fire.
  • Pause-position breaks are no longer scheduled as timeline breaks.
  • iOS: client-side IMA requests run on the main thread and no longer fail on a missing view controller.
  • iOS: chained breaks no longer re-fire during a seek.

[0.37.0] - 2026-07-27

Fixed

  • Per-URI deviceType asset targeting is applied.
  • Quartile events fire for static assets.
  • double, lshape_ad, and lshape_content breaks reveal content smoothly instead of cutting to black.

Changed

  • Documentation covers the creative CORS requirement, fast pre-roll completion, and DAR resumeOffset semantics.

[0.36.0] - 2026-07-26

Added

  • Bell Media customer demo page.

Changed

  • Customer demo explainer: delayed pre-roll callout and labelled break-detection arrow.

[0.35.0] - 2026-07-24

Added

  • Demo site: site-wide login gate.
  • Customer demo pages: shared "How it works" explainer.

Fixed

  • A pre-roll whose ad fails to load keeps a balanced adbreakbegin/adbreakend lifecycle.
  • Demo pages: the control bar responds and fades during an ad break.

Changed

  • GloboPlay demo: new backdrop image for the double-box and L-bar pre-rolls.

[0.34.0] - 2026-07-15

Added

  • doubleBoxAudio selects whether the ad or the content is audible during a double break.
  • Unified mute and volume API for content and ad playback.
  • Android and iOS/tvOS: adbreakstatus event and getAdBreakStatus() API, with a countdown driven by real ad playback.

Fixed

  • Demo pages: the control bar and break toast keep their size during double and L-shape breaks.
  • Bally's demo: ad breaks start at the correct segment.
  • Live GAM mid-rolls no longer re-fire, and the countdown badge is stable.

Changed

  • GloboPlay demo: updated content stream.

[0.33.1] - 2026-07-13

Added

  • Documentation: "Break Status & Countdown" page.
  • Bally's and GloboPlay demos: configurable delay for pre-roll and pause ads.
  • GloboPlay customer demo page.

Fixed

  • Preloaded VAST ads resize reliably and fit their box in double and L-shape breaks.
  • VAST pre-rolls: the countdown no longer freezes or rewinds, and content no longer plays behind the ad.
  • Demo: the Player page pre-roll uses the correct manifest field.

Changed

  • Bally's and GloboPlay demos: clearer format controls and a separate logo overlay.

[0.33.0] - 2026-07-12

Added

  • adbreakstatus event and getAdBreakStatus() API for break countdown UIs (web).
  • VAST ads are preloaded ahead of the break.

Changed

  • Preload lead time increased to 8 seconds.
  • Bally's demo: the default VAST tag is a GAM live pod endpoint.

Fixed

  • SCTE-35 cue timing computes the break start from Program Date Time plus segment durations.
  • Bally's demo: the full DVR window of breaks is retained; black video, pre-roll no-fill, and the pause image are fixed.

[0.32.0] - 2026-07-12

Added

  • Bally's DVR customer demo page and a password-protected customer demo portal.
  • @dolby-ads/scte35-bridge and a DVR demo page.

Fixed

  • Mid-roll DAI breaks no longer re-fire after they end.
  • VAST ad video fills its box.

[0.31.0] - 2026-07-12

Added

  • Break manifest server: stored manifests expire two hours after they were last fetched.

[0.30.0] - 2026-07-12

Changed

  • Demo: default live stream and OptiView Ads domain updated.

[0.29.0] - 2026-07-12

Added

  • Wallclock breaks match the stream's Program Date Time, enabling DVR seek-back re-fill.

Fixed

  • destroy() disposes the ad player created by adPlayerFactory.
  • THEOplayer adapter: progressive MP4 and WebM sources no longer hang.
  • diagnose() no longer throws on an unknown diagnostic code.

[0.28.0] - 2026-07-01

Fixed

  • A break cut short emits a balanced adend for the in-flight ad.
  • GAM pod serving forwards timed metadata to IMA and emits balanced adbegin/adend events.

[0.27.0] - 2026-06-27

Added

  • interceptManifestRequest lets integrators inspect and modify the manifest request before it is sent.

[0.26.0] - 2026-06-27

Added

  • interceptManifestResponse lets integrators inspect and modify the manifest on the client.
  • Every break and ad event carries a format field.
  • Demo: Preset Builder page and predefined stream configurations on the Player page.

Fixed

  • Ad audio no longer keeps playing after a session ends mid-break.
  • Demo: L-shape content backdrop link, preset switching, and stale status bar fixed.

[0.25.0] - 2026-06-24

Added

  • Video pause ads on all platforms; the break format is pause (the legacy pause_image is still accepted).
  • Demo: File a Bug page bundling a redacted diagnostics report.
  • Demo: the Player page remembers session fields.

[0.24.0] - 2026-06-23

Added

  • Android and iOS/tvOS: pause ads.
  • Demo: pre-roll on the main Player page.

Fixed

  • A pre-roll no longer replays after the manifest is re-polled.

[0.23.2] - 2026-06-23

Fixed

  • Demo: the player video no longer grows beyond the screen on reload.

[0.23.1] - 2026-06-21

Fixed

  • No content flash before an immediate pre-roll.

[0.23.0] - 2026-06-21

Added

  • Demo: VOD page skip-forward and skip-back buttons.

[0.22.1] - 2026-06-21

Fixed

  • Demo: the VAST page sample ad plays in Chrome.
  • Demo: the local break-manifest server starts reliably.

[0.22.0] - 2026-06-21

Added

  • Demo: the VOD page can load a published channel by ID.
  • Demo: current-time indicator on all player pages.

[0.21.1] - 2026-06-19

Changed

  • Demo: the VAST sample tag is self-hosted.

[0.21.0] - 2026-06-19

Added

  • Demo: VAST page.
  • Documentation: features overview, VAST guide, and a step-by-step getting-started guide.
  • Documentation: dedicated AI Assistance page.

Fixed

  • Demo: the AI Assistance sidebar item appears on every page.
  • Deployed demo: the VOD, Pre-roll, and Manifests pages use the hosted manifest server.

[0.20.0] - 2026-06-19

Added

  • Web, Android, and iOS SDK artifacts are published for installation from the demo domain.
  • Android and iOS/tvOS: VAST client-side ad playback.
  • Demo: VOD page and Pre-roll page with content-player and ad-experience selectors.

[0.19.0] - 2026-06-18

Added

  • SessionConfig.adInsertionType ('replacement' or 'insertion') controls how a break relates to the content timeline.
  • Web: VAST client-side ad playback.
  • Pre-roll breaks (position: 'pre') with an optional delay.

Fixed

  • The default ad player routes progressive MP4 creatives to the native <video> element.
  • A mis-configured shared-element insertion no longer stalls content on non-iOS platforms.

[0.18.0] - 2026-06-17

Added

  • @dolby-ads/break-manifest-server stores and serves static break manifests.
  • overlay break format with image overlay assets on web, Android, and iOS.

[0.17.0] - 2026-06-15

Added

  • Version API on every platform.

[0.16.0] - 2026-06-15

No customer-facing changes.

[0.15.0] - 2026-06-15

Added

  • Web: client-side SSAI mode (mode: 'ssai') playing a pre-stitched stream from the stitcher.
  • Stitcher: max_bitrate rendition filtering.
  • timedmetadata capability on the PlayerAdapter contract.
  • Diagnostic codes DA-SSAI-SESSION-FAILED and DA-SSAI-IMA-ERROR.
  • Demo: SSAI support.

Fixed

  • Stitcher follows redirects and resolves relative URIs against the final URL.
  • Stitcher absolutizes #EXT-X-MAP, #EXT-X-KEY, and other URI-bearing tags.

[0.14.0] - 2026-06-13

Added

  • Stitcher: double and lshape_ad breaks are stitched as a fullscreen single ad.

[0.13.0] - 2026-06-12

Added

  • @dolby-ads/stitcher: server-side ad stitcher for single breaks.
  • @dolby-ads/core/server entry with the server-safe manifest utilities.

[0.12.0] - 2026-06-12

Added

  • adBreakCutSafetyMarginSec (default 2 seconds) on all platforms.

Changed

  • Android and iOS honor the manifest's polling cadence.

[0.11.0] - 2026-06-12

No customer-facing changes.

[0.10.0] - 2026-06-12

Added

  • Tune-in support: a viewer who joins or seeks into a running break sees its remainder.

[0.9.0] - 2026-06-12

Added

  • Android TV demo app.
  • Android and iOS: JSON export of diagnostics reports.

[0.8.4] - 2026-06-12

Changed

  • Documentation: platform switcher in the demo docs.

[0.8.3] - 2026-06-12

Changed

  • Documentation: per-SDK sections and multi-SDK how-to pages.

[0.8.2] - 2026-06-12

Changed

  • Documentation: reorganized navigation.

[0.8.1] - 2026-06-12

Changed

  • Documentation: Android and iOS onboarding pages.

[0.8.0] - 2026-06-12

Added

  • Android SDK: Kotlin core, SDK, runtime with ExoPlayerAdapter, GAM pod serving, and demo app.
  • iOS/tvOS SDK: Swift core, SDK, runtime with AVPlayerAdapter, GAM pod serving, and demo app.

Changed

  • Android: the runtime module is renamed to dolbyads-runtime.
  • Documentation covers the native platforms.

[0.7.0] - 2026-06-11

Added

  • AI onboarding agent and quickstart bootstrapper in @dolby-ads/sdk.

[0.6.0] - 2026-06-10

Added

  • iPhone (iOS 17.1+): adaptive ad-insertion mode via Managed Media Source; auto resolves to it when available.
  • detectMediaSourceCapabilities() helper and MediaSourceCapabilities type.

[0.5.0] - 2026-06-09

Added

  • Structured diagnostics: onDiagnostic(), offDiagnostic(), diagnose(), and exportDiagnostics().
  • Consecutive-break chaining via the chaining option.
  • @dolby-ads/mcp server and dolby-ads-init-ai CLI for AI assistants.
  • @dolby-ads/adapter-test-kit conformance suite for player adapters.
  • Demo: AI Troubleshooting panel and AI Assistant documentation.

Fixed

  • Overlapping ad breaks are suppressed.

[0.4.0] - 2026-06-09

Added

  • adInsertion option ('overlay', 'shared-element', or 'auto') enabling iPhone Safari support.
  • adPreload option ('parallel', 'single-decoder', or 'auto').
  • @dolby-ads/sdk entry package with an HLS.js ad player and native <video> fallback.
  • Optional preload() and supportsParallelBuffering members on PlayerAdapter.
  • Native video adapter derives Program Date Time on iPhone.

Changed

  • createAdAdapter is optional; @dolby-ads/core throws a clear error when it is omitted.

[0.2.0] - 2026-06-09

Added

  • waiting and playing events for content and ad playback with a source field.

Changed

  • aderror covers content playback errors too, distinguished by source.

[0.1.0]

Added

  • Initial release: @dolby-ads/core with the PlayerAdapter interface, @dolby-ads/adapter-hlsjs, break manifest polling, and static HLS ad insertion.