Add more keyboard shortcuts for the player (#7487)

* add keyboard shortcuts

* fix lint

* Update static/locales/en-US.yaml

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>

---------

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
This commit is contained in:
efb4f5ff-1298-471a-8973-3d47447115dc 2025-05-31 03:17:42 +02:00 committed by GitHub
parent 2c533a4347
commit 2a394328c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 2 deletions

View File

@ -187,12 +187,16 @@ const KeyboardShortcuts = {
SMALL_REWIND: 'arrowleft',
SMALL_FAST_FORWARD: 'arrowright',
DECREASE_VIDEO_SPEED: 'o',
DECREASE_VIDEO_SPEED_ALT: '<',
INCREASE_VIDEO_SPEED: 'p',
INCREASE_VIDEO_SPEED_ALT: '>',
SKIP_N_TENTHS: '0..9',
LAST_CHAPTER: 'ctrl+arrowleft',
NEXT_CHAPTER: 'ctrl+arrowright',
LAST_FRAME: ',',
NEXT_FRAME: '.',
HOME: 'home',
END: 'end',
}
},
}

View File

@ -152,8 +152,10 @@ const localizedShortcutNameToShortcutsMappings = computed(() => {
[t('KeyboardShortcutPrompt.Large Fast Forward'), ['LARGE_FAST_FORWARD']],
[t('KeyboardShortcutPrompt.Small Rewind'), ['SMALL_REWIND']],
[t('KeyboardShortcutPrompt.Small Fast Forward'), ['SMALL_FAST_FORWARD']],
[t('KeyboardShortcutPrompt.Decrease Video Speed'), ['DECREASE_VIDEO_SPEED']],
[t('KeyboardShortcutPrompt.Increase Video Speed'), ['INCREASE_VIDEO_SPEED']],
[t('KeyboardShortcutPrompt.Decrease Video Speed'), ['DECREASE_VIDEO_SPEED', 'DECREASE_VIDEO_SPEED_ALT']],
[t('KeyboardShortcutPrompt.Increase Video Speed'), ['INCREASE_VIDEO_SPEED', 'INCREASE_VIDEO_SPEED_ALT']],
[t('KeyboardShortcutPrompt.Home'), ['HOME']],
[t('KeyboardShortcutPrompt.End'), ['END']],
[t('KeyboardShortcutPrompt.Skip by Tenths'), ['SKIP_N_TENTHS']],
[t('KeyboardShortcutPrompt.Last Chapter'), ['LAST_CHAPTER']],
[t('KeyboardShortcutPrompt.Next Chapter'), ['NEXT_CHAPTER']],

View File

@ -2116,11 +2116,13 @@ export default defineComponent({
seekBySeconds(defaultSkipInterval.value * player.getPlaybackRate() * 2)
break
case KeyboardShortcuts.VIDEO_PLAYER.PLAYBACK.DECREASE_VIDEO_SPEED:
case KeyboardShortcuts.VIDEO_PLAYER.PLAYBACK.DECREASE_VIDEO_SPEED_ALT:
// Decrease playback rate by user configured interval
event.preventDefault()
changePlayBackRate(-videoPlaybackRateInterval.value)
break
case KeyboardShortcuts.VIDEO_PLAYER.PLAYBACK.INCREASE_VIDEO_SPEED:
case KeyboardShortcuts.VIDEO_PLAYER.PLAYBACK.INCREASE_VIDEO_SPEED_ALT:
// Increase playback rate by user configured interval
event.preventDefault()
changePlayBackRate(videoPlaybackRateInterval.value)
@ -2235,6 +2237,24 @@ export default defineComponent({
detail: !showStats.value
}))
break
case KeyboardShortcuts.VIDEO_PLAYER.PLAYBACK.HOME:
// Jump to beginning of video
if (canSeek()) {
event.preventDefault()
// use seek range instead of duration so that it works for live streams too
const seekRange = player.seekRange()
video_.currentTime = seekRange.start
}
break
case KeyboardShortcuts.VIDEO_PLAYER.PLAYBACK.END:
// Jump to end of video
if (canSeek()) {
event.preventDefault()
// use seek range instead of duration so that it works for live streams too
const seekRange = player.seekRange()
video_.currentTime = seekRange.end
}
break
case 'escape':
// Exit full window
if (fullWindowEnabled.value) {

View File

@ -1214,3 +1214,5 @@ KeyboardShortcutPrompt:
Last Chapter: Last Chapter
Next Chapter: Next Chapter
Skip by Tenths: Skip through video by percentage (3 skips to 30% of duration)
Home: Seek to the beginning of the video
End: Seek to the end of the video