Skip to content

Commit

Permalink
feat(UI): Add PageUp and PageDown to UI seek bar (#5519)
Browse files Browse the repository at this point in the history
  • Loading branch information
theodab authored Aug 22, 2023
1 parent 8cf692c commit 8e22a50
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
}

const keyboardSeekDistance = this.config_.keyboardSeekDistance;
const keyboardLargeSeekDistance = this.config_.keyboardLargeSeekDistance;

switch (event.key) {
case 'ArrowLeft':
Expand All @@ -1289,6 +1290,22 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
this.seek_(this.seekBar_.getValue() + keyboardSeekDistance);
}
break;
case 'PageDown':
// PageDown is like ArrowLeft, but has a larger jump distance, and does
// nothing to volume.
if (this.seekBar_ && isSeekBar && keyboardSeekDistance > 0) {
event.preventDefault();
this.seek_(this.seekBar_.getValue() - keyboardLargeSeekDistance);
}
break;
case 'PageUp':
// PageDown is like ArrowRight, but has a larger jump distance, and does
// nothing to volume.
if (this.seekBar_ && isSeekBar && keyboardSeekDistance > 0) {
event.preventDefault();
this.seek_(this.seekBar_.getValue() + keyboardLargeSeekDistance);
}
break;
// Jump to the beginning of the video's seek range.
case 'Home':
if (this.seekBar_) {
Expand Down
6 changes: 6 additions & 0 deletions ui/externs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ shaka.extern.UIVolumeBarColors;
* forceLandscapeOnFullscreen: boolean,
* enableTooltips: boolean,
* keyboardSeekDistance: number,
* keyboardLargeSeekDistance: number,
* fullScreenElement: HTMLElement
* }}
*
Expand Down Expand Up @@ -184,6 +185,11 @@ shaka.extern.UIVolumeBarColors;
* right keyboard keys when the video is selected. If less than or equal to 0,
* no seeking will occur.
* Defaults to 5 seconds.
* @property {number} keyboardLargeSeekDistance
* The time interval, in seconds, to seek when the user presses the page up or
* page down keyboard keys when the video is selected. If less than or equal
* to 0, no seeking will occur.
* Defaults to 60 seconds.
* @property {HTMLElement} fullScreenElement
* DOM element on which fullscreen will be done.
* Defaults to Shaka Player Container.
Expand Down
1 change: 1 addition & 0 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ shaka.ui.Overlay = class {
forceLandscapeOnFullscreen: true,
enableTooltips: false,
keyboardSeekDistance: 5,
keyboardLargeSeekDistance: 60,
fullScreenElement: this.videoContainer_,
};

Expand Down

0 comments on commit 8e22a50

Please sign in to comment.