Skip to content

Commit 06a8785

Browse files
authored
feat(UI): Allow hide/show controls on tap (#8398)
Close #6490
1 parent b0cd08b commit 06a8785

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

ui/controls.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,9 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
16771677
if (this.isOpaque()) {
16781678
this.lastTouchEventTime_ = Date.now();
16791679
// The controls are showing.
1680-
// Let this event continue and become a click.
1680+
this.onContainerClick(/* fromTouchEvent= */ true);
1681+
// Stop this event from becoming a click event.
1682+
event.cancelable && event.preventDefault();
16811683
} else {
16821684
// The controls are hidden, so show them.
16831685
this.onMouseMove_(event);
@@ -1688,8 +1690,9 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
16881690

16891691
/**
16901692
* Manage the container click.
1693+
* @param {boolean=} fromTouchEvent
16911694
*/
1692-
onContainerClick() {
1695+
onContainerClick(fromTouchEvent = false) {
16931696
if (!this.enabled_ || this.isPlayingVR()) {
16941697
return;
16951698
}
@@ -1698,6 +1701,8 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
16981701
this.hideSettingsMenusTimer_.tickNow();
16991702
} else if (this.config_.singleClickForPlayAndPause) {
17001703
this.playPausePresentation();
1704+
} else if (fromTouchEvent && this.isOpaque()) {
1705+
this.hideUI();
17011706
}
17021707
}
17031708

ui/hidden_seek_button.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ shaka.ui.HiddenSeekButton = class extends shaka.ui.Element {
5555
this.hideSeekButtonContainerTimer_ = new shaka.util.Timer(() => {
5656
const seekSeconds = parseInt(this.seekValue_.textContent, 10);
5757
if (seekSeconds === 0) {
58-
this.controls.onContainerClick();
58+
this.controls.onContainerClick(/* fromTouchEvent= */ true);
5959
}
6060
this.hideSeekButtonContainer_();
6161
});
6262

6363
/** @protected {!HTMLElement} */
6464
this.seekContainer = shaka.util.Dom.createHTMLElement('div');
65+
this.seekContainer.classList.add('shaka-no-propagation');
6566
this.parent.appendChild(this.seekContainer);
6667

6768
/** @private {!HTMLElement} */

ui/ui.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ shaka.ui.Overlay = class {
333333
fullScreenElement: this.videoContainer_,
334334
preferDocumentPictureInPicture: true,
335335
showAudioChannelCountVariants: true,
336-
seekOnTaps: navigator.maxTouchPoints > 0,
336+
seekOnTaps: false,
337337
tapSeekDistance: 10,
338338
refreshTickInSeconds: 0.125,
339339
displayInVrMode: false,
@@ -356,6 +356,8 @@ shaka.ui.Overlay = class {
356356
// This is in line with default styles in Chrome.
357357
if (this.isMobile()) {
358358
config.addBigPlayButton = true;
359+
config.singleClickForPlayAndPause = false;
360+
config.seekOnTaps = true;
359361
config.controlPanelElements = config.controlPanelElements.filter(
360362
(name) => name != 'play_pause' && name != 'volume');
361363
}

0 commit comments

Comments
 (0)