1
0
mirror of https://github.com/videojs/video.js.git synced 2025-03-17 21:18:27 +02:00

region support

This commit is contained in:
Gary Katsevman 2020-01-15 12:19:08 -05:00
parent 5e173b0f93
commit 11ab7ec829
2 changed files with 14 additions and 1 deletions

View File

@ -397,6 +397,7 @@ class TextTrackDisplay extends Component {
}
const cues = [];
const regions = [];
// push all active track cues
for (let i = 0; i < tracks.length; ++i) {
@ -405,10 +406,16 @@ class TextTrackDisplay extends Component {
for (let j = 0; j < track.activeCues.length; ++j) {
cues.push(track.activeCues[j]);
}
if (track.regionList) {
for (let j = 0; j < track.regionList.length; ++j) {
regions.push(track.regionList[j]);
}
}
}
// removes all cues before it processes new ones
window.WebVTT.processCues(window, cues, this.el_);
window.WebVTT.processCues(window, cues, this.el_, regions);
// add unique class to each language text track & add settings styling if necessary
for (let i = 0; i < tracks.length; ++i) {

View File

@ -29,16 +29,22 @@ const parseCues = function(srcContent, track) {
window.WebVTT.StringDecoder()
);
const errors = [];
const regions = [];
parser.oncue = function(cue) {
track.addCue(cue);
};
parser.onregion = function(region) {
regions.push(region);
};
parser.onparsingerror = function(error) {
errors.push(error);
};
parser.onflush = function() {
track.regionList = regions;
track.trigger({
type: 'loadeddata',
target: track