@dolby-optiview/ads-sdk-core

中文文档
1.6.0发布于 2026/11/13SEE LICENSE AT https://optiview.dolby.com/policies/terms-of-service/TypeScriptCommonJS近 30 天下载 2.9万

OptiView Ads SDK Core - Player-agnostic ad insertion

原始使用文档
文档目录5 节
  1. Installation
  2. Quick start
  3. Custom adapters
  4. Documentation
  5. License

@dolby-optiview/ads-sdk-core

Player-agnostic core of the OptiView Ads SDK for the web: break manifest polling and verification, break scheduling, ad playback and event reporting. It never imports player code; content and ad players are driven through the PlayerAdapter interface.

Most applications do not install this package directly: @dolby-optiview/ads-sdk depends on it and adds a default ad player. Use the core on its own when you supply both the content adapter and the ad player adapter yourself, for example with a custom PlayerAdapter.

Installation

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

Replace the adapter with @dolby-optiview/ads-sdk-adapter-shaka or @dolby-optiview/ads-sdk-adapter-theoplayer for those players.

Quick start

With the bare core, createAdAdapter is required:

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);
  },
});

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

Custom adapters

Implement PlayerAdapter (exported as a type from this package) to connect a player that has no ready-made adapter. The adapter reports playback state, program date time and in-stream metadata to the core and receives load, play, pause and seek commands.

Documentation

License

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

版本与发布记录

@dolby-optiview/ads-sdk-core 共发布 15 个版本,首次发布于 2026/09/09;过去 12 个月发布了 15 个版本。

版本发布日期距今
1.6.0latest2026/11/13今天
1.5.12026/11/067 天前
1.4.02026/11/058 天前
1.3.02026/10/2816 天前
1.2.12026/10/2321 天前
1.2.02026/10/2321 天前

其他发布通道:next → 1.0.0-beta.6。

关于 @dolby-optiview/ads-sdk-core 的常见问题

@dolby-optiview/ads-sdk-core 是什么?

OptiView Ads SDK Core - Player-agnostic ad insertion

如何安装 @dolby-optiview/ads-sdk-core?

在项目目录运行 npm install @dolby-optiview/ads-sdk-core,或使用 pnpm add / yarn add / bun add。

@dolby-optiview/ads-sdk-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dolby-optiview/ads-sdk-core 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dolby-optiview/ads-sdk-core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dolby-optiview/ads-sdk-core 可以商用吗?

@dolby-optiview/ads-sdk-core 使用 SEE LICENSE AT https://optiview.dolby.com/policies/terms-of-service/ 许可。声明的许可为 SEE LICENSE AT https://optiview.dolby.com/policies/terms-of-service/,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@dolby-optiview/ads-sdk-core 的下载量有多少?

根据 npm 官方下载统计,@dolby-optiview/ads-sdk-core 在 2026/10/13 – 2026/11/11 这 30 天内被下载 28,776 次,日均约 959 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dolby-optiview/ads-sdk-core 还在维护吗?

最新版本 1.6.0 发布于 2026/11/13(今天);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/09/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。