Skip to content

Commit

Permalink
Revert recent cast changes
Browse files Browse the repository at this point in the history
This reverts commits:
 - a43f52c
   "Add "noFade" configuration to UI."
 - 08a36e8
   "Add transparency transition cast app controls."
 - a6b159f
   "Keep controls visible while casting."

Moving the showing/hiding up to the receiver app level can waste CPU
on low-end devices, and puts undue configuration burden on the
receiver app.

We will follow up with a more direct fix for shaka-project#2314, as well as a
"fadeDelay" option to allow the cast receiver UI to delay fading for a
few seconds.

Related to issue shaka-project#2314

Change-Id: I0028803432ad028930002b29dd7b94c7d9a0ec56
  • Loading branch information
joeyparrish committed Jan 14, 2020
1 parent 1372da9 commit 361e39e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 55 deletions.
13 changes: 0 additions & 13 deletions demo/cast_receiver/receiver_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@ body {
color: white;
}

.shaka-controls-container {
/* Transparent unless explicitly made opaque through
"shown=true" attribute */
opacity: 0;

/* When we show/hide this, do it gradually using cubic-bezier timing. */
transition: opacity cubic-bezier(0.4, 0, 0.6, 1) 600ms;
}

.shaka-controls-container[receiverShown="true"] {
opacity: 1;
}

#videoContainer {
width: 100%;
height: 100%;
Expand Down
10 changes: 3 additions & 7 deletions demo/cast_receiver/receiver_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ 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 Expand Up @@ -155,17 +154,14 @@ class ShakaReceiverApp {
this.controlsTimerId_ = null;
}

// Control if the controls are visible. Use a custom version of the UI's
// opacity transition with a special name for "show", to over-write the UI's
// control of the element.
if (this.video_.paused && this.video_.readyState > 0) {
// Show controls.
this.controlsElement_.setAttribute('receiverShown', 'true');
this.controlsElement_.style.opacity = 1;
} else {
// Show controls for 3 seconds.
this.controlsElement_.setAttribute('receiverShown', 'true');
this.controlsElement_.style.opacity = 1;
this.controlsTimerId_ = window.setTimeout(() => {
this.controlsElement_.removeAttribute('receiverShown');
this.controlsElement_.style.opacity = 0;
}, ShakaReceiverApp.CONTROLS_TIMEOUT_SECONDS_ * 1000);
}
}
Expand Down
37 changes: 7 additions & 30 deletions ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,6 @@ 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.isCasting_()) {
this.setControlsOpacity_(shaka.ui.Enums.Opacity.OPAQUE);
}

// Init the play state
this.onPlayStateChange_();

Expand Down Expand Up @@ -1046,32 +1041,19 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
// Hide the cursor. (NOTE: not supported on IE)
this.videoContainer_.style.cursor = 'none';

this.chooseControlsOpacity_();
}

/** @private */
chooseControlsOpacity_() {
const adIsPaused = this.ad_ ? this.ad_.isPaused() : false;
const videoIsPaused = this.video_.paused && !this.isSeeking_;

// Keep showing the controls if ad or video is paused or one of
// the control menus is hovered.
if (adIsPaused || this.config_.noFade || this.isCasting_() ||
if (adIsPaused ||
(!this.ad_ && videoIsPaused) || this.overrideCssShowControls_) {
this.setControlsOpacity_(shaka.ui.Enums.Opacity.OPAQUE);
} else {
this.setControlsOpacity_(shaka.ui.Enums.Opacity.TRANSPARENT);
}
}

/**
* @return {boolean}
* @private
*/
isCasting_() {
return this.castProxy_ != null && this.castProxy_.isCasting();
}

/**
* @param {!Event} event
* @private
Expand Down Expand Up @@ -1127,17 +1109,6 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
this.controlsContainer_.setAttribute('casting', 'true');
} else {
this.controlsContainer_.removeAttribute('casting');

// Transition from having the controls forced open to not.
// However, after casting ends, there is typically a brief period of
// buffering, so wait for that to end first; if we called this immediately
// then it would just set the controls to be visible again, as we also
// forcibly-show the controls while the video is paused (or buffering),
// and the user would have to mouse over the video again to make the
// controls fade.
this.eventManager_.listenOnce(this.video_, 'playing', () => {
this.chooseControlsOpacity_();
});
}
}

Expand Down Expand Up @@ -1228,6 +1199,12 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
return false;
}

// TODO: refactor into a single property
// While you are casting, the UI is always opaque.
if (this.castProxy_ && this.castProxy_.isCasting()) {
return true;
}

return this.fadeOutControls_.some((c) => c.getAttribute('shown') != null);
}

Expand Down
5 changes: 1 addition & 4 deletions ui/externs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ shaka.extern.UIVolumeBarColors;
* clearBufferOnQualityChange: boolean,
* seekBarColors: shaka.extern.UISeekBarColors,
* volumeBarColors: shaka.extern.UIVolumeBarColors,
* trackLabelFormat: shaka.ui.TrackLabelFormat,
* noFade: boolean
* trackLabelFormat: shaka.ui.TrackLabelFormat
* }}
*
* @property {!Array.<string>} controlPanelElements
Expand Down Expand Up @@ -98,8 +97,6 @@ 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: 0 additions & 1 deletion ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ shaka.ui.Overlay = class {
level: 'rgb(255, 255, 255)',
},
trackLabelFormat: shaka.ui.TrackLabelFormat.LANGUAGE,
noFade: false,
};
}

Expand Down

0 comments on commit 361e39e

Please sign in to comment.