@financial-times/o-video

中文文档
9.1.0发布于 2026/09/15MITES Module近 30 天下载 2174

Creates a video player and attaches analytics.

原始使用文档
文档目录10 节
  1. Usage
  2. Markup
  3. Sass
  4. JavaScript
  5. Config
  6. With a playlist
  7. Testing
  8. Migration
  9. Contact
  10. Licence

o-video MIT licensed

Creates a video player and attaches analytics.

Usage

Check out how to include Origami components in your project to get started with o-video.

Markup

<div class="o-video" data-o-component="o-video"></div>

Videos can be styled in three different sizes, namely 'small', 'medium' and 'large', which can be added to the element as class modifiers, e.g.

<div class="o-video o-video--large" data-o-component="o-video"></div>

Sass

In order to output every size and attribute of o-video, you'll need to include the following:

@import "@financial-times/o-video/main";

@include oVideo();

You can be more selective about which sizes and attributes you would like to output, by using an $opts map. It accepts the following lists:

attributes

  • 'info'
  • 'placeholder'

sizes

  • 'small'
  • 'medium'
  • 'large'
@import "@financial-times/o-video";

@include oVideo(
    $opts: (
        "sizes": (
            "small",
            "large",
        ),
    )
); // outputs small and large video styles

JavaScript

In order to initialise o-video, you will need the following:

import Video from "@financial-times/o-video";
const opts = {
    id: 4165329773001,
    optimumwidth: 710,
    placeholder: true,
    classes: ["video"],
    systemcode: "my-biz-ops-code",
};
const video = new Video(document.body, opts);

Config

Where opts is an optional object with properties

  • id [String] Source's ID of the video (brightcoveId or uuid)
  • autorender [Boolean] Whether to have the video render automatically. If-false* then you will need to call init() when ready
  • optimumwidth [Number] The optimum width of the video placeholder image
  • optimumvideowidth [Number] The optimum width of the video itself, used when there are multiple video renditions available to decide which to display (the smallest one that's at least as large as this width, if it exists)
  • placeholder [Boolean] Show just the poster image, load (and play) video on click
  • placeholderHint [String] An optional hint to display alongside the play icon (defaults to empty)
  • placeholderInfo [Array] A list of extra information to display on the placeholder (Available: title, description, brand)
  • playsinline [Boolean] Whether to play the video inline on iOS smallscreen (defaults to fullscreen)
  • classes [Array] Classes to add to the video (and placeholder) element
  • showCaptions [Boolean] whether or not to add captions to the video. Defaults to true.
  • data [Object] JSON object representing a response from next-media-api. If used, the component will not make a call to the API and use this data instead.
  • systemcode [String] a valid Bizops system code for the project using o-video. option but is missing properties, it will use the properties set in the defaultTargeting object instead. here is what each property on the targeting object affects:
    • site: refers to the ad unit that contains the line items for video creatives (part of the ad request).
    • sizes: also added to ad request to specify video ad sizes to be returned. subscription level, resolution.

The config options can also be set as data attribute to instantiate the module declaratively:

<div
    data-o-component="o-video o-video--large"
    data-o-video-id="4165329773001"
    data-o-video-optimumwidth="710"
></div>

With a playlist

Playlists may take a queue of videos and play them one after another.

import Video from "@financial-times/o-video";

const queue = ["4165329773001", "4907997821001", "4165329773001"];

const player = new Video(document.body, {
    autorender: false,
    systemcode: "my-biz-ops-code",
});
const playlist = new Video.Playlist({ player, queue });

document.querySelector(".next-btn").onclick = () => playlist.next();
document.querySelector(".prev-btn").onclick = () => playlist.prev();

The queue is an array containing Brightcove video ID strings.

Testing

See Origami build tools.

$ obt test

Requires Firefox (v38.0.0 to test with polyfills and mirror CI)

Migration

StateMajor VersionLast Minor ReleaseMigration guide
⚠ maintained8N/Amigrate to v8
╳ deprecated77.3migrate to v7
╳ deprecated66.1migrate to v6
╳ deprecated55.1migrate to v5
╳ deprecated44.1migrate to v4
╳ deprecated33.1migrate to v3
╳ deprecated22.5migrate to v2
╳ deprecated11.4-

Contact

If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #origami-support or email Origami Support.

Licence

This software is published by the Financial Times under the MIT licence.

版本与发布记录

@financial-times/o-video 共发布 51 个版本,首次发布于 2019/02/13;过去 12 个月发布了 2 个版本。

版本发布日期距今
9.1.0latest2026/09/151 个月前
9.0.02026/07/273 个月前
8.0.12025/10/291 年前
8.0.02025/02/201.7 年前
7.3.12024/07/262 年前
7.3.02024/06/112 年前

其他发布通道:prerelease → 7.0.0-beta.0,tag--v6.1.4 → 6.1.4。

关于 @financial-times/o-video 的常见问题

@financial-times/o-video 是什么?

Creates a video player and attaches analytics.

如何安装 @financial-times/o-video?

在项目目录运行 npm install @financial-times/o-video,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@financial-times/o-loading(^6.0.0)、@financial-times/o-private-foundation(^1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@financial-times/o-video 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/financial-times__o-video 是否存在。

@financial-times/o-video 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@financial-times/o-video 可以商用吗?

@financial-times/o-video 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@financial-times/o-video 的下载量有多少?

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

@financial-times/o-video 还在维护吗?

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