npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dolby-optiview/ads-sdk-react-native

v1.6.1

Published

OptiView Ads SDK for React Native - bridges the native Android/iOS/tvOS SDKs

Readme

@dolby-optiview/ads-sdk-react-native

Scheduled scrubber markers

await connector.getScheduledBreaks() returns a ScheduledBreak[] snapshot, empty without a session. Subscribe to scheduledbreakschange for { breaks } updates. Types are re-exported from this package and match the web SDK: id, position (pre/mid/post), nullable startSec and startDate, manifest durationSec, and played (set after break-begin and retained on rewind).

Only viewer-playable opportunities are listed. Bookmark-skipped pre-rolls and overlap skips are excluded; earlier bookmark mid-rolls remain unplayed. Post-roll and wallclock content coordinates are null; wallclock uses ISO dates, and PTS coordinates remain null until mapped. Session end clears the list. Equal snapshots emit nothing. Native schedule changes are discrete FIFO events, not coalesced; the newest snapshot is protected during bounded-buffer overflow.

VOD bookmark startup

See Start VOD from a bookmark for native and web startup ordering, including completed iOS/tvOS host seeks.

VOD snapback

Call connector.seek(time) rather than seeking the host directly so Android, iOS/tvOS and web SDK seek policy is applied before the player moves. For an unplayed, playable mediatime-scheduled client-side break with controls.snapback: true, the entire break plays from zero. After seek-over, 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 into an unplayed window use normal insertion/replacement resume policy. Only the last crossed snapback break can play; if it is already played or unplayable, all crossed breaks are skipped without fallback. Skipped unplayed breaks can be considered on a later viewer seek. A break already started does not snap back again in that session. Live, PTS/wallclock, event-triggered, SSAI and SSB breaks are excluded.

THEOplayer and react-native-video native hosts use the same scheduling policy. Host-control seeks on react-native-video iOS/tvOS rely on position jumps greater than two seconds, whereas connector seeks are planned directly. RN web delegates to THEOplayer/web SDK policy; TV-web shells are excluded.

With liveStartPushback: { enabled: true }, live startup keeps a five-target-duration minimum distance from the reported edge when metadata and the DVR window allow it. It is off by default for every ptsSource, including 'anvatoCue'. The bridge forwards liveStartPushback unchanged on Android, iOS/tvOS and Web: an omitted enabled or { enabled: false } keeps it off; { targetDurationSeconds: 10 } supplies the actual stream's declared HLS TD when the player cannot. Diagnostics carry TD and requested/measured offsets in seconds and TD multiples. VOD and later break-resume policy remain unchanged.

React Native support for the OptiView Ads SDK: a typed JavaScript facade over the native Android and iOS/tvOS SDKs, plus a browser entry for react-native-web.

RN app (JS)
  └─ @dolby-optiview/ads-sdk-react-native   config, startSession(), events, controls, diagnostics
       └─ TurboModule bridge
            └─ native OptiView Ads orchestrator
                 ├─ PlayerAdapter        wraps the native host player
                 ├─ OverlayAdRenderer    native view above the player
                 └─ GAM / VAST (IMA)     native ad playback

Ad scheduling, break insertion and ad progress run on the native side, so they keep working while the JavaScript thread is paused or throttled (background, picture-in-picture). Events raised while JS is paused are buffered and delivered on resume. The configuration mirrors the web OptiViewAdsConfig without its DOM and function members, and events reuse the web OptiViewAdsEventMap.

Requirements

  • React Native 0.76 or newer with the new architecture (TurboModules and Fabric). Apple TV apps use the matching react-native-tvos release.
  • A host player: react-native-theoplayer or react-native-video (v6, Media3/ExoPlayer on Android, AVPlayer on iOS/tvOS). Either host can be installed without the other.
  • With react-native-theoplayer, version 11.7.0 or newer on Android and web for THEOplayer ad events (usePlayerFacade). iOS/tvOS may use older wrappers.
  • Android: Java 17 with core library desugaring. iOS/tvOS: Xcode 16 or newer, one platform per Podfile.

Apple player view transitions

On iOS and tvOS, the bridge keeps the ad-overlay controller attached to the screen containing the player when the application moves a retained native player between inline, expanded and floating containers. There is no additional JavaScript API and no need to restart the ads session just because the view moves. Applications must continue to perform UIKit hierarchy changes on the main thread.

The bridge observes player superview changes synchronously and ancestor window changes through a hidden, non-interactive child view. It chains the host class's existing move methods; only registered instances receive ads callbacks. Controller ownership is cleared before a move and restored after it, while geometry-only updates remain deferred. Session teardown unregisters the observers.

npm run test:rn:ios runs the real UIKit containment regression suite in an iOS simulator. Set OPTIVIEW_IOS_TEST_DEVICE to select a simulator UDID; otherwise the script reuses a booted iOS simulator or boots an available one. Set OPTIVIEW_RN_IOS_SOURCE_DIR to an unpacked package's ios directory to run the same suite against the shipped native sources instead of the checkout.

Installation

npm install @dolby-optiview/ads-sdk-react-native

Pin an exact version with --save-exact for reproducible native builds: the native artifacts are resolved at the installed package version. If an .npmrc routes the @dolby-optiview scope elsewhere, point it at https://registry.npmjs.org/.

Android

Add the THEOplayer Maven repository to the repositories used by the React Native projects, keeping Google and Maven Central:

// android/build.gradle
allprojects {
    repositories {
        maven { url "https://maven.theoplayer.com/releases" }
        google()
        mavenCentral()
    }
}

React Native's Gradle plugin may ignore repositories declared only in settings.gradle. Enable desugaring in android/app/build.gradle:

android {
    compileOptions { coreLibraryDesugaringEnabled true }
}
dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
}

For react-native-video, also set in android/gradle.properties:

RNVideo_useExoplayerIMA=true

This uses the real IMA integration instead of react-native-video's stub classes, which conflict with the IMA SDK shipped by the OptiView runtime.

The THEOplayer binding is compiled only when the :react-native-theoplayer Gradle project is autolinked; otherwise the package builds without it. No extra flag is needed. If both players are linked, the player view you pass in selects the binding; their Media3 dependencies must be compatible.

The 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 to build both against one version:

THEOplayer_sdk=11.15.1

Without the property, the newest available 11.x version (11.5.0 or newer) is used.

iOS / tvOS

Add both sources to the platform's Podfile and run bundle exec pod install:

source 'https://github.com/THEOplayer/cocoapods-specs.git'
source 'https://github.com/Dolby-OptiView/cocoapods-specs.git'
source 'https://cdn.cocoapods.org/'

The bundled OptiViewAdsReactNative.podspec autolinks and depends on the OptiViewAdsRuntime and OptiViewAdsReactBridge pods at exactly the package version; OptiViewAdsAdapterTHEOplayer is added when react-native-theoplayer is present. Set OPTIVIEW_ADS_NATIVE_PODS=0 at pod install time to supply the native dependencies yourself.

react-native-theoplayer 11.5.0 and 11.6.0 import a header that React Native 0.87.0 (and react-native-tvos 0.87.0-0) no longer ships. If you use that combination, remove the single line #import <React/RCTRootContentView.h> from node_modules/react-native-theoplayer/ios/Theoplayer-Bridging-Header.h through your dependency-patch process, or upgrade the wrapper.

Web (react-native-web)

The package's browser and default export conditions (or an explicit import from @dolby-optiview/ads-sdk-react-native/web) run the web SDK in-process, with no bridge and no native setup. The web-safe default also covers Next.js server-side rendering of client components, where browser is not active; no SDK-specific resolver alias is needed. Metro still selects the native entry through the react-native condition. Create players and SDK sessions only in the browser after the player is mounted, not during server rendering.

Quick start

react-native-theoplayer

import { THEOplayerView } from 'react-native-theoplayer';
import { createOptiViewAds } from '@dolby-optiview/ads-sdk-react-native';

const onPlayerReady = async (player) => {
  player.source = { sources: [{ src: CONTENT_URL, type: 'application/x-mpegurl' }] };
  const ads = createOptiViewAds(player, {});
  ads.addEventListener('adbreakbegin', (e) => console.log('break', e.break.id));
  await ads.startSession({ manifestUrl: MANIFEST_URL });
};

<THEOplayerView config={{ license: THEOPLAYER_LICENSE }} onPlayerReady={onPlayerReady} />;

Pass the player from onPlayerReady directly on Android, iOS, tvOS and react-native-web. Create the connector only after the player is mounted.

react-native-video

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} />;

useReactVideoHandle() derives the native view handle from the player's own events; react-native-video v6 does not expose it through findNodeHandle.

Connector API

const ads = createOptiViewAds(player, config); // config: OptiViewAdsReactNativeConfig
await ads.startSession({ manifestUrl: MANIFEST_URL });
ads.addEventListener('adbreakbegin', (e) => console.log(e.break.id));
const skipped = await ads.skipAd(); // false until the manifest skipOffset is reached
const clickThrough = await ads.clickAd(); // URL or null; the app decides whether to navigate
ads.setManifestRequestInterceptor(async (request) => ({ ...request }), { timeoutMs: 1500 });
await ads.destroy();

Interceptors run on the JS thread; the native side waits at most timeoutMs (default 2000 ms) and proceeds unmodified on timeout, so interception never stalls playback. updateAssetParameters() and updateAssetParameterMacros() change targeting without restarting the session.

Managed sessions and hooks

OptiViewAdsSession owns one connector and its asynchronous startup. It exposes ready, connector, destroyed, getSnapshot() and subscribe(); destroy() waits for pending startup and is safe to call repeatedly.

useOptiViewAds manages a session from React. In hook ownership, memoize the factory and return null while the player is not ready; changing the factory identity replaces the session after the previous cleanup finishes.

import { useCallback } from 'react';
import {
  createOptiViewAds,
  OptiViewAdsSession,
  useOptiViewAds,
} from '@dolby-optiview/ads-sdk-react-native';

const createSession = useCallback(
  () =>
    player ? new OptiViewAdsSession(createOptiViewAds(player, sdkConfig), sessionConfig) : null,
  [player, sdkConfig, sessionConfig]
);
const ads = useOptiViewAds({ ownership: 'hook', createSession });

For floating or backgrounded playback, keep the session in your playback owner and observe it from any host component with external ownership. Unmounting never destroys an external session; the owner calls await retainedSession.destroy() before releasing the native player.

const ads = useOptiViewAds({ ownership: 'external', session: retainedSession });

Both modes return { session, connector, status, error }; status is idle, starting, active, failed or destroyed. Use ads.connector for events, controls, diagnostics and targeting updates.

useTHEOplayerAdsBinding enables usePlayerFacade, forwards the host callbacks, waits for the player handle and returns a memoized createSession factory. After restoring a retained player, call binding.playerHandlers.onPlayerRestored(player).

const binding = useTHEOplayerAdsBinding({
  config: playerConfig,
  adsConfig: sdkConfig,
  sessionConfig,
  onPlayerReady,
  onPlayerDestroy,
});
const ads = useOptiViewAds({ ownership: 'hook', createSession: binding.createSession });
const debug = useOptiViewAdsDebug({ connector: ads.connector, status: ads.status, maxEvents: 50 });

return (
  <THEOplayerView
    config={binding.playerConfig}
    onPlayerReady={binding.playerHandlers.onPlayerReady}
    onPlayerDestroy={binding.playerHandlers.onPlayerDestroy}
  />
);

On web, wire the binding's ready handler when the content player is created, even if enabled is initially false. The binding prepares a player-owned presentation host before forwarding onPlayerReady; assign the first content source in or after that callback. Ads activation and connector replacement reuse this hierarchy without moving the content video or its ancestors. Hook ownership and configuration dependencies remain unchanged.

SDK destruction releases ad resources but leaves the content host intact. The host is released after the wrapper's underlying player teardown is confirmed, not when the hook unmounts or its factory changes. Restoring the same retained player reuses the host. An active player that was never prepared is rejected before DOM mutation; pausing it does not make late wrapping safe. Preparation failures are surfaced through the managed hook's error result without suppressing the application's ready callback. The direct web-config overload retains its existing rendering contract; this preparation applies to the RN THEOplayer path.

useOptiViewAdsDebug is an opt-in, player-independent helper for local inspection: it returns recent event names with timestamps, current ad and break details, clearEvents() and exportDiagnostics(). It polls once per second while the session is active and never controls playback.

THEOplayer ad events

With react-native-theoplayer 11.7.0 or newer and usePlayerFacade: true set before the player is created, OptiView breaks and ads surface through THEOplayer's own ad events on Android and web: break and ad lifecycle, quartiles, errors and clicks, identified by integration: 'csai' with customData.provider: 'optiview-ads'. On iOS and tvOS the native bridge registers the integration automatically. During content-replacing breaks the player clock follows the ad; analytics should observe the facade rather than the raw content player. OptiView keeps ownership of playback; THEOplayer's own IMA integration is not activated.

Picture-in-picture

  • On iOS, enable the Audio, AirPlay, and Picture in Picture background mode (UIBackgroundModes: [audio]), and with react-native-theoplayer set player.pipConfiguration = { retainPipOnSourceChange: true } so the PiP window survives the source swap at the start of an ad.

  • react-native-video has no presentation-mode event the bridge can observe. Forward its status event so the SDK adapts the break layout:

    <Video onPictureInPictureStatusChanged={(e) => connector.notePictureInPicture(e.isActive)} />

AirPlay (iOS)

The bridge's iOS adapters report and gate the content player's AirPlay route, so the SDK's external-playback behaviour (the guard around ad breaks and, when the manifest carries a server-side beaconing ssb stream, the switch to that stream on the receiver) needs no extra wiring:

  • react-native-theoplayer: THEOplayerAdapter reads player.cast.airPlay for the route state and gates through THEOplayer's allowsExternalPlayback. Start AirPlay from the system route picker or with player.cast.airplay.start(); the gate decides whether the video leaves the device.
  • react-native-video: AVPlayerAdapter reads the audio route (connecting) and AVPlayer.isExternalPlaybackActive (active) and gates through AVPlayer.allowsExternalPlayback. Do not set the view's allowsExternalPlayback prop while a session runs: a re-render re-applies it to the same AVPlayer property and reopens a gate the SDK closed.
  • Android never reports an external playback state; the gate is a no-op there.

Set the guard window with externalPlayback: { blockBeforeBreakSec } in the connector config (default 5). Observe the state through adbreakstatus (externalPlaybackAllowed; deliveryMode: 'ssb' while the receiver plays the SSB stream), adchannelchange with reason external-playback, and the DA-EXTERNAL-PLAYBACK-* and DA-SSB-* diagnostics. The gate moves the video only: after a failed switch the audio stays on the receiver until the viewer ends the route, so keep a route picker reachable. Details: Server-side beaconing stream on the Break Manifest page and External playback on the Player Adapters page of the OptiView Ads SDK integration guide.

Platform notes

  • Anvato break signaling (ptsSource: 'anvatoCue'): on Android the Media3 and THEOplayer adapters deliver Anvato DASH emsg cues. With THEOplayer the break starts at the cue's signaled pts; with Media3 (react-native-video) it can still start up to one segment early (DA-ANVATO-CUE-SEGMENT-ANCHORED). On iOS and tvOS playback goes through AVFoundation, which has no DASH engine; Anvato signaling there arrives as HLS ID3 GEOB frames, which are supported.
  • Every exported function, type and connector method carries TypeScript documentation, visible in the editor.

Documentation

License

See https://optiview.dolby.com/policies/terms-of-service/.