cuechange event fires when a TextTrack has changed the currently displaying cues. The event is fired at both the TextTrack and HTMLTrackElement in which it's being presented, if any.

冒泡 No
可取消 No
接口 事件
Event handler oncuechange

范例

On the TextTrack

You can set up a listener for the cuechange event on a TextTrack using  the addEventListener() 方法:

track.addEventListener('cuechange', function () {
  let cues = track.activeCues;  // array of current cues
});
					

Or you can just set the oncuechange 事件处理程序特性:

track.oncuechange = function () {
  let cues = track.activeCues; // array of current cues
}
					

On the track element

The underlying TextTrack , indicated by the track property, receives a cuechange event every time the currently-presented cue is changed. This happens even if the track isn't associated with a media element.

If the track is associated with a media element, using the <track> element as a child of the <audio> or <video> element, the cuechange event is also sent to the HTMLTrackElement .

let textTrackElem = document.getElementById("texttrack");
textTrackElem.addEventListener("cuechange", (event) => {
  let cues = event.target.track.activeCues;
});
					

In addition, you can use the oncuechange event handler:

let textTrackElem = document.getElementById("texttrack");
textTrackElem.oncuechange = (event) => {
  let cues = event.target.track.activeCues;
});
					

规范

规范 状态
HTML 实时标准
The definition of 'cuechange' in that specification.
实时标准

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
cuechange event Chrome Yes Edge 12 Firefox 31 IE ? Opera ? Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 31 Opera Android No Safari iOS ? Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改:
  1. TextTrack
  2. 特性
    1. mode
  3. 事件
    1. cuechange
  4. 继承:
    1. EventTarget