大网数据广告活动
Web 标准与前端开发

VTTRegion

· 52CE 我爱测

The `VTTRegion` interface of the WebVTT API describes a portion of the video to render a VTTCue onto.

WebVTT

The VTTRegion interface of the WebVTT API describes a portion of the video to render a VTTCue onto.

Constructor

  • VTTRegion.VTTRegion
    • : Creates a new VTTRegion object instance.

Instance properties

  • VTTRegion.id
    • : A string that identifies the region.
  • VTTRegion.width
    • : Represents the width of the region, as a percentage of the video's width.
  • VTTRegion.lines
    • : Represents the height of the region, in number of lines.
  • VTTRegion.regionAnchorX
    • : Represents the region anchor X offset, as a percentage of the region's width.
  • VTTRegion.regionAnchorY
    • : Represents the region anchor Y offset, as a percentage of the region's height.
  • VTTRegion.viewportAnchorX
    • : Represents the viewport anchor X offset, as a percentage of the video's width.
  • VTTRegion.viewportAnchorY
    • : Represents the viewport anchor Y offset, as a percentage of the video's height.
  • VTTRegion.scroll
    • : An enumerated value indicating how existing cues in the region move when a new cue is added.

Examples

const region = new VTTRegion();
region.width = 50; // Set the region to 50% of the video's width
region.lines = 4; // Render cues in 4 lines
region.viewportAnchorX = 25; // Place the region 25% from the left edge of the video
const cue = new VTTCue(2, 3, "Cool text to be displayed");
cue.region = region; // This cue will be drawn only within this region.

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。