Skip to content

Commit

Permalink
handle the case where multiple cues can target the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent-Bouisset committed Nov 14, 2023
1 parent dd71e57 commit 57dab60
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ export default class TextTrackCuesStore {
// approximation.
// Add a tolerance of 1ms to fix this issue
if (ret.length === 0 && cues.length) {
if (areNearlyEqual(time, cues[0].start, DELTA_CUES_GROUP)) {
ret.push(cues[0].element);
} else if (areNearlyEqual(time, cues[cues.length - 1].end, DELTA_CUES_GROUP)) {
ret.push(cues[cues.length - 1].element);
for (let j = 0; j < cues.length; j++) {
if (areNearlyEqual(time, cues[j].start, DELTA_CUES_GROUP)
|| areNearlyEqual(time, cues[j].end, DELTA_CUES_GROUP)
) {
ret.push(cues[j].element);
}
}
return ret;
Expand Down

0 comments on commit 57dab60

Please sign in to comment.