Skip to content

Commit

Permalink
fix(chapters): removed duplicate chapters by id (#4810)
Browse files Browse the repository at this point in the history
fixes #4750

Solved by creating a `Set` for filtering out deplicate elements.

Need confirmation, Shouldn't we add an `assert` for `language` argument
passed to
https://github.com/shaka-project/shaka-player/blob/76f96b9fee2dc43b03f6803dd80c51fdc5b73a9e/lib/player.js#L4340-L4342
  • Loading branch information
WINOFFRG authored and joeyparrish committed Dec 14, 2022
1 parent 611f1d6 commit 3588d37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Prakash <[email protected]>
Robert Colantuoni <[email protected]>
Robert Galluccio <[email protected]>
Rodolphe Breton <[email protected]>
Rohan Gupta <[email protected]>
Roi Lipman <[email protected]>
Roksolana Ivanyshyn <[email protected]>
Rostislav Hejduk <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Robert Colantuoni <[email protected]>
Robert Galluccio <[email protected]>
Rodolphe Breton <[email protected]>
Rohit Makasana <[email protected]>
Rohan Gupta <[email protected]>
Roi Lipman <[email protected]>
Roksolana Ivanyshyn <[email protected]>
Rostislav Hejduk <[email protected]>
Expand Down
6 changes: 5 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4330,6 +4330,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
return [];
}
const chapters = [];
const uniqueChapters = new Set();
for (const chaptersTrack of chaptersTracksWithLanguage) {
if (chaptersTrack && chaptersTrack.cues) {
for (const cue of chaptersTrack.cues) {
Expand All @@ -4344,7 +4345,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
startTime: cue.startTime,
endTime: cue.endTime,
};
chapters.push(chapter);
if (!uniqueChapters.has(id)) {
chapters.push(chapter);
uniqueChapters.add(id);
}
}
}
}
Expand Down

0 comments on commit 3588d37

Please sign in to comment.