diff --git a/demo/custom.js b/demo/custom.js index a7a8028170..bee8a9c51b 100644 --- a/demo/custom.js +++ b/demo/custom.js @@ -46,6 +46,9 @@ shakaDemo.Custom = class { /** @private {!Set.} */ this.assets_ = this.loadAssetInfos_(); + /** @private {!HTMLInputElement} */ + this.manifestField_; + /** @private {!Array.} */ this.assetCards_ = []; this.savedList_ = document.createElement('div'); @@ -238,6 +241,7 @@ shakaDemo.Custom = class { return headersDiv; } + /** * @param {!ShakaDemoAssetInfo} assetInProgress * @param {!Array.} inputsToCheck @@ -270,9 +274,14 @@ shakaDemo.Custom = class { if (assetInProgress.imaContentSrcId) { input.value = assetInProgress.imaContentSrcId; } + + this.manifestField_.required = + this.checkManifestRequired_(assetInProgress); }; const contentSrcIdOnChange = (input) => { assetInProgress.imaContentSrcId = input.value; + this.manifestField_.required = + this.checkManifestRequired_(assetInProgress); }; const contentSrcIdName = shakaDemoMain.getLocalizedString( shakaDemo.MessageIds.IMA_CONTENT_SRC_ID); @@ -284,9 +293,14 @@ shakaDemo.Custom = class { if (assetInProgress.imaVideoId) { input.value = assetInProgress.imaVideoId; } + + this.manifestField_.required = + this.checkManifestRequired_(assetInProgress); }; const videoIdOnChange = (input) => { assetInProgress.imaVideoId = input.value; + this.manifestField_.required = + this.checkManifestRequired_(assetInProgress); }; const videoIdName = shakaDemoMain.getLocalizedString( shakaDemo.MessageIds.IMA_VIDEO_ID); @@ -298,9 +312,14 @@ shakaDemo.Custom = class { if (assetInProgress.imaAssetKey) { input.value = assetInProgress.imaAssetKey; } + + this.manifestField_.required = + this.checkManifestRequired_(assetInProgress); }; const assetKeyChange = (input) => { assetInProgress.imaAssetKey = input.value; + this.manifestField_.required = + this.checkManifestRequired_(assetInProgress); }; const assetKeyName = shakaDemoMain.getLocalizedString( shakaDemo.MessageIds.IMA_ASSET_KEY); @@ -431,8 +450,9 @@ shakaDemo.Custom = class { container.appendChild(error); // Add a regex that will detect empty strings. - input.required = true; + input.required = this.checkManifestRequired_(assetInProgress); input.pattern = '^(?!([\r\n\t\f\v ]+)$).*$'; + this.manifestField_ = input; }; const manifestOnChange = (input) => { assetInProgress.manifestUri = input.value; @@ -511,6 +531,18 @@ shakaDemo.Custom = class { return mainDiv; } + /** + * @param {!ShakaDemoAssetInfo} assetInProgress + * @private + */ + checkManifestRequired_(assetInProgress) { + // The manifest field is required unless we're getting the manifest + // from the Google Ad Manager using IMA ids. + const isDaiAdManifest = (assetInProgress.imaContentSrcId && + assetInProgress.imaVideoId) || assetInProgress.imaAssetKey != null; + return !isDaiAdManifest; + } + /** * @param {!ShakaDemoAssetInfo} assetInProgress * @param {!Array.} inputsToCheck diff --git a/demo/locales/en.json b/demo/locales/en.json index a614acaa13..4d1f37b525 100644 --- a/demo/locales/en.json +++ b/demo/locales/en.json @@ -115,7 +115,7 @@ "DEMO_MANIFEST_SEARCH": "Manifest", "DEMO_MANIFEST_SECTION_HEADER": "Manifest", "DEMO_MANIFEST_URL": "Manifest URL", - "DEMO_MANIFEST_URL_ERROR": "Must have a manifest URL.", + "DEMO_MANIFEST_URL_ERROR": "Must have a manifest URL, or IMA DAI id fields", "DEMO_MAX_ATTEMPTS": "Max Attempts", "DEMO_MAX_BANDWIDTH": "Max Bandwidth", "DEMO_MAX_FRAMERATE": "Max Framerate", diff --git a/demo/locales/source.json b/demo/locales/source.json index b391be0666..fee2ca416d 100644 --- a/demo/locales/source.json +++ b/demo/locales/source.json @@ -464,8 +464,8 @@ "message": "Manifest URL" }, "DEMO_MANIFEST_URL_ERROR": { - "description": "An error that is displayed if the user does not provide a manifest URL for a custom asset.", - "message": "Must have a manifest URL." + "description": "An error that is displayed if the user does not provide a manifest URL for a custom asset or identification fields in the Google Ad Manager system.", + "message": "Must have a manifest URL, or IMA DAI id fields." }, "DEMO_MAX_ATTEMPTS": { "description": "The name of a configuration value.",