Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
Handle remove cues from track properly if cues is null (videojs/video…
Browse files Browse the repository at this point in the history
  • Loading branch information
askaliuk authored and jrivera committed Dec 5, 2016
1 parent cfa621c commit db0edc1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/remove-cues-from-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const removeCuesFromTrack = function(start, end, track) {
return;
}

if (!track.cues) {
return;
}

i = track.cues.length;

while (i--) {
Expand Down
29 changes: 29 additions & 0 deletions test/html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,35 @@ function() {
);
});

QUnit.test(
'calling remove property handles absence of cues (null)',
function() {
let mediaSource = new videojs.MediaSource();
let sourceBuffer = mediaSource.addSourceBuffer('video/mp2t');

initializeNativeSourceBuffers(sourceBuffer);

sourceBuffer.inbandTextTrack_ = {
cues: null
};

mediaSource.videoBuffer_.remove = function(start, end) {
// pass
};
mediaSource.audioBuffer_.remove = function(start, end) {
// pass
};

// this call should not raise an exception
sourceBuffer.remove(3, 10);

QUnit.equal(
sourceBuffer.inbandTextTrack_.cues,
null,
'cues are still null'
);
});

QUnit.test('removing works even with audio disabled', function() {
let mediaSource = new videojs.MediaSource();
let muxedBuffer = mediaSource.addSourceBuffer('video/mp2t');
Expand Down

0 comments on commit db0edc1

Please sign in to comment.