Skip to content

Commit

Permalink
feat: update videojs-vtt.js and wrap native cues in TextTrack (#4131)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gkatsev authored Feb 27, 2017
1 parent dcc615a commit 3d4aebc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"videojs-font": "2.0.0",
"videojs-ie8": "1.1.2",
"videojs-swf": "5.2.0",
"videojs-vtt.js": "0.12.1",
"videojs-vtt.js": "0.12.2",
"xhr": "2.2.2"
},
"devDependencies": {
Expand Down
3 changes: 0 additions & 3 deletions src/js/tech/tech.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,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;
}
Expand Down
12 changes: 11 additions & 1 deletion src/js/tracks/text-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,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();

if (tracks) {
Expand Down

0 comments on commit 3d4aebc

Please sign in to comment.