diff --git a/src/js/tracks/text-track-display.js b/src/js/tracks/text-track-display.js index e83f1921bd..53bb92c05f 100644 --- a/src/js/tracks/text-track-display.js +++ b/src/js/tracks/text-track-display.js @@ -243,8 +243,6 @@ class TextTrackDisplay extends Component { const tracks = this.player_.textTracks(); const allowMultipleShowingTracks = this.options_.allowMultipleShowingTracks; - this.clearDisplay(); - if (allowMultipleShowingTracks) { const showingTracks = []; @@ -290,6 +288,8 @@ class TextTrackDisplay extends Component { this.setAttribute('aria-live', 'assertive'); } this.updateForTrack(descriptionsTrack); + } else { + this.clearDisplay(); } } @@ -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) { diff --git a/src/js/tracks/text-track.js b/src/js/tracks/text-track.js index f7093538a4..82ee1f64db 100644 --- a/src/js/tracks/text-track.js +++ b/src/js/tracks/text-track.js @@ -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