Skip to content

Commit

Permalink
Fix deleting all cues from text tracks (#3938)
Browse files Browse the repository at this point in the history
* Fix deleting all cues from text tracks

* Fix deleting all cues from period
  • Loading branch information
bbert authored May 3, 2022
1 parent 19d290a commit c5d1323
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/streaming/text/TextTracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,17 +577,17 @@ function TextTracks(config) {
return false;
}

function cueInRange(cue, start, end) {
return (isNaN(start) || cue.startTime >= start) && (isNaN(end) || cue.endTime <= end);
function cueInRange(cue, start, end, strict = true) {
return (isNaN(start) || (strict ? cue.startTime : cue.endTime) >= start) && (isNaN(end) || (strict ? cue.endTime : cue.startTime) <= end);
}

function deleteTrackCues(track, start, end) {
function deleteTrackCues(track, start, end, strict = true) {
if (track.cues) {
const cues = track.cues;
const lastIdx = cues.length - 1;

for (let r = lastIdx; r >= 0; r--) {
if (cueInRange(cues[r], start, end)) {
if (cueInRange(cues[r], start, end, strict)) {
if (cues[r].onexit) {
cues[r].onexit();
}
Expand All @@ -609,7 +609,7 @@ function TextTracks(config) {
for (let i = 0; i < ln; i++) {
const track = getTrackByIdx(i);
if (track) {
deleteTrackCues.call(this, track, streamInfo.start, streamInfo.start + streamInfo.duration);
deleteTrackCues.call(this, track, streamInfo.start, streamInfo.start + streamInfo.duration, false);
}
}
nativeTrackElementArr = [];
Expand Down

0 comments on commit c5d1323

Please sign in to comment.