diff --git a/AUTHORS b/AUTHORS index cb96fe4539..4039c7f51f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -61,6 +61,7 @@ Prakash Robert Colantuoni Robert Galluccio Rodolphe Breton +Rohan Gupta Roi Lipman Roksolana Ivanyshyn Rostislav Hejduk diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4b0b8b2c55..63d89447b4 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -91,6 +91,7 @@ Robert Colantuoni Robert Galluccio Rodolphe Breton Rohit Makasana +Rohan Gupta Roi Lipman Roksolana Ivanyshyn Rostislav Hejduk diff --git a/lib/player.js b/lib/player.js index f1dd42820b..cd8e01dc12 100644 --- a/lib/player.js +++ b/lib/player.js @@ -3952,16 +3952,25 @@ 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) { + let id = cue.id; + if (!id || id == '') { + id = cue.startTime + '-' + cue.endTime + '-' + cue.text; + } /** @type {shaka.extern.Chapter} */ const chapter = { + id: id, title: cue.text, startTime: cue.startTime, endTime: cue.endTime, }; - chapters.push(chapter); + if (!uniqueChapters.has(id)) { + chapters.push(chapter); + uniqueChapters.add(id); + } } } }