Skip to content

Commit

Permalink
Add "noFade" configuration to UI.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
theodab committed Jan 10, 2020
1 parent 36331f9 commit a43f52c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions demo/cast_receiver/receiver_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 6 additions & 1 deletion ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_();

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion ui/externs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<string>} controlPanelElements
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ shaka.ui.Overlay = class {
level: 'rgb(255, 255, 255)',
},
trackLabelFormat: shaka.ui.TrackLabelFormat.LANGUAGE,
noFade: false,
};
}

Expand Down

0 comments on commit a43f52c

Please sign in to comment.