1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-02 06:32:07 +02:00

fix: Check for VTTCue (#8370) (#8372)

This commit is contained in:
Walter Seymour 2023-07-20 13:22:06 -05:00 committed by GitHub
parent f27df30ca5
commit 9f2d81fb9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 485 additions and 470 deletions

936
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -95,7 +95,7 @@
"mux.js": "6.0.1",
"safe-json-parse": "4.0.0",
"videojs-font": "3.2.0",
"videojs-vtt.js": "^0.15.4"
"videojs-vtt.js": "^0.15.5"
},
"devDependencies": {
"@babel/core": "^7.9.0",

View File

@ -395,7 +395,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