Skip to content

Commit

Permalink
fix(UI): Allow play/pause when seekOnTaps is enabled (#8206)
Browse files Browse the repository at this point in the history
Fixes #8199
  • Loading branch information
avelad authored Mar 4, 2025
1 parent 051da08 commit db43a18
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
26 changes: 11 additions & 15 deletions ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,13 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
return;
}

if (this.ad_) {
this.playPauseAd();
if (this.ad_.isLinear()) {
return;
}
}

if (!this.video_.duration) {
// Can't play yet. Ignore.
return;
Expand Down Expand Up @@ -1336,10 +1343,10 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
const keyboardSeekDistance = this.config_.keyboardSeekDistance;
switch (details.action) {
case 'pause':
this.onPlayPauseClick_();
this.playPausePresentation();
break;
case 'play':
this.onPlayPauseClick_();
this.playPausePresentation();
break;
case 'seekbackward':
if (details.seekOffset && !isFinite(details.seekOffset)) {
Expand Down Expand Up @@ -1669,19 +1676,8 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
if (this.anySettingsMenusAreOpen()) {
this.hideSettingsMenusTimer_.tickNow();
} else if (this.config_.singleClickForPlayAndPause) {
this.onPlayPauseClick_();
}
}

/** @private */
onPlayPauseClick_() {
if (this.ad_) {
this.playPauseAd();
if (this.ad_.isLinear()) {
return;
}
this.playPausePresentation();
}
this.playPausePresentation();
}

/** @private */
Expand Down Expand Up @@ -1792,7 +1788,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
// Pause or play by pressing space on the seek bar.
case ' ':
if (isSeekBar) {
this.onPlayPauseClick_();
this.playPausePresentation();
}
break;
}
Expand Down
4 changes: 4 additions & 0 deletions ui/hidden_seek_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ shaka.ui.HiddenSeekButton = class extends shaka.ui.Element {
* @private {shaka.util.Timer}
*/
this.hideSeekButtonContainerTimer_ = new shaka.util.Timer(() => {
const position = parseInt(this.seekValue_.textContent, 10);
this.hideSeekButtonContainer_();
if (position == 0) {
this.controls.playPausePresentation();
}
});

/** @protected {!HTMLElement} */
Expand Down
6 changes: 0 additions & 6 deletions ui/play_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
});

this.eventManager.listen(this.button, 'click', () => {
if (this.ad) {
this.controls.playPauseAd();
if (this.ad.isLinear()) {
return;
}
}
this.controls.playPausePresentation();
});

Expand Down

0 comments on commit db43a18

Please sign in to comment.