Skip to content

Commit

Permalink
chore(Demo): Add extra chapter functionality (#5796)
Browse files Browse the repository at this point in the history
Related to #3597
  • Loading branch information
avelad committed Oct 30, 2023
1 parent 766b0a1 commit 6a8d6af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
12 changes: 11 additions & 1 deletion demo/common/asset.js
Expand Up @@ -45,6 +45,8 @@ const ShakaDemoAssetInfo = class {
this.extraText = [];
/** @type {!Array.<string>} */
this.extraThumbnail = [];
/** @type {!Array.<!shakaAssets.ExtraChapter>} */
this.extraChapter = [];
/** @type {?string} */
this.certificateUri = null;
/** @type {?string} */
Expand Down Expand Up @@ -321,7 +323,6 @@ const ShakaDemoAssetInfo = class {
* @return {!ShakaDemoAssetInfo}
*/
addExtraText(extraText) {
// TODO: At no point do we actually use the extraText... why does it exist?
this.extraText.push(extraText);
return this;
}
Expand All @@ -335,6 +336,15 @@ const ShakaDemoAssetInfo = class {
return this;
}

/**
* @param {shakaAssets.ExtraChapter} extraChapter
* @return {!ShakaDemoAssetInfo}
*/
addExtraChapter(extraChapter) {
this.extraChapter.push(extraChapter);
return this;
}

/**
* If this is called, the asset will be focused on by the integration tests.
* @return {!ShakaDemoAssetInfo}
Expand Down
17 changes: 17 additions & 0 deletions demo/common/assets.js
Expand Up @@ -178,6 +178,23 @@ shakaAssets.Feature = {
* (optional) The codecs string, if needed to refine the MIME type.
*/
shakaAssets.ExtraText;


/**
* @typedef {{
* uri: string,
* language: string,
* mime: string
* }}
*
* @property {string} uri
* The URI of the chapter.
* @property {string} language
* The language of the chapter (e.g. 'en').
* @property {string} mime
* The MIME type of the chapter (e.g. 'text/vtt')
*/
shakaAssets.ExtraChapter;
// End types and enums }}}


Expand Down
5 changes: 5 additions & 0 deletions demo/main.js
Expand Up @@ -1268,6 +1268,11 @@ shakaDemo.Main = class {
this.player_.addThumbnailsTrack(extraThumbnail);
}

for (const extraChapter of asset.extraChapter) {
this.player_.addChaptersTrack(extraChapter.uri, extraChapter.language,
extraChapter.mime);
}

// If the asset has an ad tag attached to it, load the ads
const adManager = this.player_.getAdManager();
if (adManager && asset.adTagUri) {
Expand Down

0 comments on commit 6a8d6af

Please sign in to comment.