1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-27 02:43:45 +02:00

fix: Check for VTTCue (#8370)

This commit is contained in:
Walter Seymour 2023-07-20 11:38:15 -05:00 committed by GitHub
parent 452a918a42
commit da15810355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 5 deletions

14
package-lock.json generated
View File

@ -15300,6 +15300,14 @@
"requires": {
"global": "^4.4.0"
}
},
"videojs-vtt.js": {
"version": "0.15.4",
"resolved": "https://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.4.tgz",
"integrity": "sha512-r6IhM325fcLb1D6pgsMkTQT1PpFdUdYZa1iqk7wJEu+QlibBwATPfPc9Bg8Jiym0GE5yP1AG2rMLu+QMVWkYtA==",
"requires": {
"global": "^4.3.1"
}
}
}
},
@ -15618,9 +15626,9 @@
}
},
"videojs-vtt.js": {
"version": "0.15.4",
"resolved": "https://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.4.tgz",
"integrity": "sha512-r6IhM325fcLb1D6pgsMkTQT1PpFdUdYZa1iqk7wJEu+QlibBwATPfPc9Bg8Jiym0GE5yP1AG2rMLu+QMVWkYtA==",
"version": "0.15.5",
"resolved": "https://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.5.tgz",
"integrity": "sha512-yZbBxvA7QMYn15Lr/ZfhhLPrNpI/RmCSCqgIff57GC2gIrV5YfyzLfLyZMj0NnZSAz8syB4N0nHXpZg9MyrMOQ==",
"requires": {
"global": "^4.3.1"
}

View File

@ -98,7 +98,7 @@
"safe-json-parse": "4.0.0",
"videojs-contrib-quality-levels": "4.0.0",
"videojs-font": "4.1.0",
"videojs-vtt.js": "0.15.4"
"videojs-vtt.js": "0.15.5"
},
"devDependencies": {
"@babel/core": "^7.9.0",

View File

@ -391,7 +391,7 @@ class TextTrack extends Track {
addCue(originalCue) {
let cue = originalCue;
if (window.vttjs && !(originalCue instanceof window.vttjs.VTTCue)) {
if (cue.constructor && cue.constructor.name !== 'VTTCue') {
cue = new window.vttjs.VTTCue(originalCue.startTime, originalCue.endTime, originalCue.text);
for (const prop in originalCue) {

View File

@ -231,6 +231,21 @@ QUnit.test('original cue can be used to remove cue from cues list', function(ass
assert.equal(tt.cues.length, 0, 'we have removed cue1');
});
QUnit.test('non-VTTCue can be used to remove cue from cues list', function(assert) {
const tt = new TextTrack({
tech: this.tech
});
const cue1 = { id: 1, text: 'test' };
assert.equal(tt.cues.length, 0, 'start with zero cues');
tt.addCue(cue1);
assert.equal(tt.cues.length, 1, 'we have one cue');
tt.removeCue(cue1);
assert.equal(tt.cues.length, 0, 'we have removed cue1');
});
QUnit.test('can only remove one cue at a time', function(assert) {
const tt = new TextTrack({
tech: this.tech