Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UI): Add PageUp and PageDown to UI seek bar #5519

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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