From a43f52caf30f255f33a9c820395c827ea45addc9 Mon Sep 17 00:00:00 2001 From: Theodore Abshire Date: Thu, 9 Jan 2020 15:12:11 -0800 Subject: [PATCH] Add "noFade" configuration to UI. This allows users to tell the UI to stay visible at all times, even if there are no mouse events. This is necessary on ChromeCast, where there is no mouse, or touch controls, or anything; without this setting, the controls just stay transparent all the time. Change-Id: Ie74c689f9bee9f07ffcb68dbacfd7bfe3ad066de --- demo/cast_receiver/receiver_app.js | 1 + ui/controls.js | 7 ++++++- ui/externs/ui.js | 5 ++++- ui/ui.js | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/demo/cast_receiver/receiver_app.js b/demo/cast_receiver/receiver_app.js index cc4b7efe2d..8422b85f77 100644 --- a/demo/cast_receiver/receiver_app.js +++ b/demo/cast_receiver/receiver_app.js @@ -50,6 +50,7 @@ class ShakaReceiverApp { // Make sure we don't show extra UI elements we don't need on the TV. ui.configure({ + noFade: true, controlPanelElements: [ 'play_pause', 'time_and_duration', diff --git a/ui/controls.js b/ui/controls.js index 5ae5272812..66e2f6d66d 100644 --- a/ui/controls.js +++ b/ui/controls.js @@ -363,6 +363,11 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget { // Create the new layout this.createDOM_(); + // If the controls are supposed to not fade, then they should be shown here. + if (config.noFade) { + this.setControlsOpacity_(shaka.ui.Enums.Opacity.OPAQUE); + } + // Init the play state this.onPlayStateChange_(); @@ -1046,7 +1051,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget { // Keep showing the controls if ad or video is paused or one of // the control menus is hovered. - if (adIsPaused || + if (adIsPaused || this.config_.noFade || (!this.ad_ && videoIsPaused) || this.overrideCssShowControls_) { this.setControlsOpacity_(shaka.ui.Enums.Opacity.OPAQUE); } else { diff --git a/ui/externs/ui.js b/ui/externs/ui.js index cab871bdf0..73a8b8b621 100644 --- a/ui/externs/ui.js +++ b/ui/externs/ui.js @@ -60,7 +60,8 @@ shaka.extern.UIVolumeBarColors; * clearBufferOnQualityChange: boolean, * seekBarColors: shaka.extern.UISeekBarColors, * volumeBarColors: shaka.extern.UIVolumeBarColors, - * trackLabelFormat: shaka.ui.TrackLabelFormat + * trackLabelFormat: shaka.ui.TrackLabelFormat, + * noFade: boolean * }} * * @property {!Array.} controlPanelElements @@ -97,6 +98,8 @@ shaka.extern.UIVolumeBarColors; * ROLE means that only the role of the item is shown. * LANGUAGE_ROLE means both are shown, or just language if there is no role. * Defaults to LANGUAGE. + * @property {boolean} noFade + * If set to true, the UI will not fade, even if the user is not mousing over. */ shaka.extern.UIConfiguration; diff --git a/ui/ui.js b/ui/ui.js index c427464fbb..138557d982 100644 --- a/ui/ui.js +++ b/ui/ui.js @@ -210,6 +210,7 @@ shaka.ui.Overlay = class { level: 'rgb(255, 255, 255)', }, trackLabelFormat: shaka.ui.TrackLabelFormat.LANGUAGE, + noFade: false, }; }