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): Added keyboardSeekDistance config to UI #4246

Merged
merged 1 commit into from
May 19, 2022
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
14 changes: 8 additions & 6 deletions ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,21 +1260,23 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
return;
}

const keyboardSeekDistance = this.config_.keyboardSeekDistance;

switch (event.key) {
case 'ArrowLeft':
// If it's not focused on the volume bar, move the seek time backward
// for 5 sec. Otherwise, the volume will be adjusted automatically.
if (this.seekBar_ && !isVolumeBar) {
// for a few sec. Otherwise, the volume will be adjusted automatically.
if (this.seekBar_ && !isVolumeBar && keyboardSeekDistance > 0) {
event.preventDefault();
this.seek_(this.seekBar_.getValue() - 5);
this.seek_(this.seekBar_.getValue() - keyboardSeekDistance);
}
break;
case 'ArrowRight':
// If it's not focused on the volume bar, move the seek time forward
// for 5 sec. Otherwise, the volume will be adjusted automatically.
if (this.seekBar_ && !isVolumeBar) {
// for a few sec. Otherwise, the volume will be adjusted automatically.
if (this.seekBar_ && !isVolumeBar && keyboardSeekDistance > 0) {
event.preventDefault();
this.seek_(this.seekBar_.getValue() + 5);
this.seek_(this.seekBar_.getValue() + keyboardSeekDistance);
}
break;
// Jump to the beginning of the video's seek range.
Expand Down
8 changes: 7 additions & 1 deletion ui/externs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ shaka.extern.UIVolumeBarColors;
* enableKeyboardPlaybackControls: boolean,
* enableFullscreenOnRotation: boolean,
* forceLandscapeOnFullscreen: boolean,
* enableTooltips: boolean
* enableTooltips: boolean,
* keyboardSeekDistance: number
* }}
*
* @property {!Array.<string>} controlPanelElements
Expand Down Expand Up @@ -177,6 +178,11 @@ shaka.extern.UIVolumeBarColors;
* Whether or not buttons in the control panel display tooltips that contain
* information about their function.
* Defaults to false.
* @property {number} keyboardSeekDistance
* The time interval, in seconds, to seek when the user presses the left or
* right keyboard keys when the video is selected. If less than or equal to 0,
* no seeking will occur.
* Defaults to 5 seconds.
* @exportDoc
*/
shaka.extern.UIConfiguration;
Expand Down
1 change: 1 addition & 0 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ shaka.ui.Overlay = class {
enableFullscreenOnRotation: true,
forceLandscapeOnFullscreen: true,
enableTooltips: false,
keyboardSeekDistance: 5,
};

// Check AirPlay support
Expand Down