TextTrack: cuechange event - Web APIs 编辑
The cuechange
event fires when a TextTrack
has changed the currently displaying cues. The event is fired at both the TextTrack
and at the HTMLTrackElement
in which it's being presented, if any.
Bubbles | No |
---|---|
Cancelable | No |
Interface | Event |
Event handler property | GlobalEventHandlers.oncuechange |
Examples
On the TextTrack
You can set up a listener for the cuechange
event on a TextTrack
using the addEventListener()
method:
track.addEventListener('cuechange', function () {
let cues = track.activeCues; // array of current cues
});
Or you can just set the oncuechange
event handler property:
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;
});
Specifications
Specification | Status |
---|---|
HTML Living Standard The definition of 'cuechange' in that specification. | Living Standard |
Browser compatibility
BCD tables only load in the browser
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.See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论