1
0
mirror of https://github.com/videojs/video.js.git synced 2025-04-07 07:19:54 +02:00

feat: update videojs-vtt.js and wrap native cues in TextTrack (#4115)

Update videojs-vtt.js and don't auto-export its versions of VTTCue globally.
When our TextTrack object is given a cue, if it's a native cue, wrap it in our emulated vttjs.VTTCue.

Fixes #4093.
This commit is contained in:
Gary Katsevman 2017-02-27 13:52:01 -05:00 committed by GitHub
parent f558648f44
commit 96a387f723
3 changed files with 12 additions and 5 deletions

View File

@ -44,7 +44,7 @@
"tsml": "1.0.1",
"videojs-font": "2.0.0",
"videojs-ie8": "1.1.2",
"videojs-vtt.js": "0.12.1",
"videojs-vtt.js": "0.12.2",
"xhr": "2.3.3"
},
"devDependencies": {

View File

@ -520,9 +520,6 @@ class Tech extends Component {
// as an option. novtt builds will turn the above require call into an empty object
// which will cause this if check to always fail.
if (!this.options_['vtt.js'] && isPlain(vtt) && Object.keys(vtt).length > 0) {
Object.keys(vtt).forEach(function(k) {
window[k] = vtt[k];
});
this.trigger('vttjsloaded');
return;
}

View File

@ -336,7 +336,17 @@ class TextTrack extends Track {
* @param {TextTrack~Cue} cue
* The cue to add to our internal list
*/
addCue(cue) {
addCue(originalCue) {
let cue = originalCue;
if (!(originalCue instanceof window.vttjs.VTTCue)) {
cue = new window.vttjs.VTTCue(originalCue.startTime, originalCue.endTime, originalCue.text);
for (const prop in originalCue) {
cue[prop] = originalCue[prop];
}
}
const tracks = this.tech_.textTracks();
for (let i = 0; i < tracks.length; i++) {