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

DataCue: type property

· 52CE 我爱测

The **`type`** read-only property of the DataCue interface returns a string identifying the type or schema of the data stored in the cue's DataCue.value property. This is typically a reverse-domain notation string (e.g., `"org.id3"`, `"com.apple.itunes"`) that allows applications

WebVTT

The type read-only property of the DataCue interface returns a string identifying the type or schema of the data stored in the cue's DataCue.value property. This is typically a reverse-domain notation string (e.g., "org.id3", "com.apple.itunes") that allows applications to interpret the cue's data payload correctly.

When a user agent automatically generates DataCue objects for in-band timed metadata (for example, from an HTTP Live Streaming source), it sets this property to indicate the metadata format. When application code creates a DataCue using the DataCue.DataCue constructor, the type is set from the optional fourth argument and defaults to an empty string if omitted.

Value

A string. Common values set by user agents for in-band metadata include:

  • "org.id3" — ID3 metadata.
  • "org.mp4ra" — MPEG-4 metadata.
  • "com.apple.quicktime.udta" — QuickTime User Data.
  • "com.apple.quicktime.mdta" — QuickTime Metadata.
  • "com.apple.itunes" — iTunes metadata.

Application-defined cues may use any string, but reverse-domain notation is recommended to avoid collisions.

Examples

Reading the type of a DataCue

<video controls src="video.mp4"></video>
const video = document.querySelector("video");
const track = video.addTextTrack("metadata", "Events");
track.mode = "hidden";

const cue = new DataCue(
  0,
  10,
  { latitude: 51.5043, longitude: -0.0762 },
  "org.example.geo",
);
track.addCue(cue);

console.log(cue.type);
// "org.example.geo"

Dispatching on type for in-band metadata

When a user agent generates DataCue objects from in-band timed metadata, the type property can be used to determine how to handle each cue.

track.addEventListener("cuechange", () => {
  for (const cue of track.activeCues) {
    switch (cue.type) {
      case "org.id3":
        handleID3Metadata(cue.value);
        break;
      case "org.mp4ra":
        handleMP4Metadata(cue.value);
        break;
      default:
        console.log(`Unknown cue type: ${cue.type}`);
    }
  }
});

Specifications

Browser compatibility

See also

  • DataCue
  • DataCue.value
  • DataCue.DataCue constructor
  • TextTrackCue

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

资料来源与适用范围

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

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

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