Skip to content

Commit

Permalink
feat: Add Id to chapters (shaka-project#4184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Velad Galván authored 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.