Skip to content

Commit

Permalink
feat: Add Id to chapters (#4184)
Browse files Browse the repository at this point in the history
Related to #3895
  • Loading branch information
Álvaro Velad Galván committed May 3, 2022
1 parent c2f1fb5 commit 5ca3271
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions externs/shaka/player.js
Expand Up @@ -1253,11 +1253,14 @@ shaka.extern.Thumbnail;

/**
* @typedef {{
* id: string,
* title: string,
* startTime: number,
* endTime: number
* }}
*
* @property {string} id
* The id of the chapter.
* @property {string} title
* The title of the chapter.
* @property {number} startTime
Expand Down
5 changes: 5 additions & 0 deletions lib/player.js
Expand Up @@ -4056,8 +4056,13 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
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,
Expand Down

0 comments on commit 5ca3271

Please sign in to comment.