diff --git a/demo/config.js b/demo/config.js index 03517d7d..f5d3dea1 100644 --- a/demo/config.js +++ b/demo/config.js @@ -741,6 +741,11 @@ shakaDemo.Config = class { this.latestInput_.input().checked = true; } + this.addCustomTextInput_('Watermark text', (input) => { + shakaDemoMain.setWatermarkText(input.value); + }); + this.latestInput_.input().value = shakaDemoMain.getWatermarkText(); + // shaka.log is not set if logging isn't enabled. // I.E. if using the release version of shaka. if (!shaka['log']) { diff --git a/demo/main.js b/demo/main.js index 5786e58c..e3b89521 100644 --- a/demo/main.js +++ b/demo/main.js @@ -62,6 +62,9 @@ shakaDemo.Main = class { /** @private {boolean} */ this.customContextMenu_ = false; + /** @private {string} */ + this.watermarkText_ = ''; + /** @private {boolean} */ this.nativeControlsEnabled_ = false; @@ -397,6 +400,11 @@ shakaDemo.Main = class { uiConfig.overflowMenuButtons.push('visualizer'); } ui.configure(uiConfig); + if (this.watermarkText_) { + ui.setTextWatermark(this.watermarkText_); + } else { + ui.removeWatermark(); + } } /** @private */ @@ -819,6 +827,27 @@ shakaDemo.Main = class { return this.customContextMenu_; } + /** + * Set the text for watermark. + * + * @param {string} text + */ + setWatermarkText(text) { + this.watermarkText_ = text; + // Configure the UI, to add or remove the controls. + this.configureUI_(); + this.remakeHash(); + } + + /** + * Get the current text for watermark. + * + * @return {string} + */ + getWatermarkText() { + return this.watermarkText_; + } + /** * Enable or disable the native controls. * Goes into effect during the next load. @@ -1004,6 +1033,10 @@ shakaDemo.Main = class { this.configureUI_(); } + if ('watermarkText' in params) { + this.watermarkText_ = params['watermarkText']; + } + if ('visualizer' in params) { this.setIsVisualizerActive(true); } else { @@ -1571,6 +1604,10 @@ shakaDemo.Main = class { params.push('customContextMenu'); } + if (this.watermarkText_) { + params.push('watermarkText=' + this.watermarkText_); + } + if (this.getIsVisualizerActive()) { params.push('visualizer'); } diff --git a/ui/ui.js b/ui/ui.js index f3cd8779..85d52913 100644 --- a/ui/ui.js +++ b/ui/ui.js @@ -179,7 +179,7 @@ shaka.ui.Overlay = class { /** * @param {string} text - * @param {!shaka.ui.Watermark.Options} options + * @param {?shaka.ui.Watermark.Options=} options * @export */ setTextWatermark(text, options) { diff --git a/ui/watermark.js b/ui/watermark.js index fcda82df..1bf68892 100644 --- a/ui/watermark.js +++ b/ui/watermark.js @@ -82,7 +82,7 @@ shaka.ui.Watermark = class extends shaka.ui.Element { * Sets a text watermark on the video with customizable options. * The watermark can be either static (fixed position) or dynamic (moving). * @param {string} text The text to display as watermark - * @param {shaka.ui.Watermark.Options} options configuration options + * @param {?shaka.ui.Watermark.Options=} options configuration options * @export */ setTextWatermark(text, options) {