Added 'doubleClickForFullscreen' config to UI.

This configuration, which is true by default, lets a user optionally
disable the "go fullscreen on double-click" functionality.
This allows a developer to fully disable fullscreen mode, if they so
wish, or to retain the fullscreen button but disable other methods of
entering fullscreen.

Issue #2459

Change-Id: I196602fc9843e0fd799c78703de60f864e906841
This commit is contained in:
Theodore Abshire
2020-03-16 08:58:18 -07:00
parent 935040a3b5
commit d1dce29e89
4 changed files with 20 additions and 3 deletions
+8
View File
@@ -187,6 +187,7 @@ describe('UI', () => {
overflowMenuButtons: [
'quality',
],
doubleClickForFullscreen: false,
};
const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
const controls = ui.getControls();
@@ -195,6 +196,13 @@ describe('UI', () => {
const controlsContainer =
videoContainer.querySelector('.shaka-controls-container');
// When double-click for fullscreen is disabled, it shouldn't happen.
UiUtils.simulateEvent(controlsContainer, 'dblclick');
await Util.shortDelay();
expect(spy).not.toHaveBeenCalled();
// Change the configuration and try again.
config.doubleClickForFullscreen = true;
(/** @type {!shaka.ui.Overlay} */ (ui)).configure(config);
UiUtils.simulateEvent(controlsContainer, 'dblclick');
await Util.shortDelay();
expect(spy).toHaveBeenCalledTimes(1);
+5 -2
View File
@@ -854,8 +854,11 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
// for focused elements.
this.eventManager_.listen(window, 'keydown', (e) => this.onKeyDown_(e));
this.eventManager_.listen(
this.controlsContainer_, 'dblclick', () => this.toggleFullScreen());
this.eventManager_.listen(this.controlsContainer_, 'dblclick', () => {
if (this.config_.doubleClickForFullscreen) {
this.toggleFullScreen();
}
});
this.eventManager_.listen(this.video_, 'play', () => {
this.onPlayStateChange_();
+6 -1
View File
@@ -66,7 +66,8 @@ shaka.extern.UIVolumeBarColors;
* seekBarColors: shaka.extern.UISeekBarColors,
* volumeBarColors: shaka.extern.UIVolumeBarColors,
* trackLabelFormat: shaka.ui.TrackLabelFormat,
* fadeDelay: number
* fadeDelay: number,
* doubleClickForFullscreen: boolean
* }}
*
* @property {!Array.<string>} controlPanelElements
@@ -119,6 +120,10 @@ shaka.extern.UIVolumeBarColors;
* interacting with them. We recommend setting this to 3 on your cast
* receiver UI.
* Defaults to 0.
* @property {boolean} doubleClickForFullscreen
* Whether or not double-clicking on the UI should cause it to enter
* fullscreen.
* Defaults to true.
*/
shaka.extern.UIConfiguration;
+1
View File
@@ -195,6 +195,7 @@ shaka.ui.Overlay = class {
},
trackLabelFormat: shaka.ui.TrackLabelFormat.LANGUAGE,
fadeDelay: 0,
doubleClickForFullscreen: true,
};
// On mobile, by default, hide the volume slide and the small play/pause