Skip to content

Commit

Permalink
feat: update videojs-vtt.js and wrap native cues in TextTrack (#4115)
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 committed Feb 27, 2017
1 parent f558648 commit 96a387f
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 @@ -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": {
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 @@ -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;
}
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 @@ -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++) {
Expand Down

0 comments on commit 96a387f

Please sign in to comment.