Cleanup player hotkeys

pull/4723/head
Chocobozzz 2022-01-12 16:01:39 +01:00
parent dd200d3477
commit fc3412fd4e
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 30 additions and 13 deletions

View File

@ -714,22 +714,28 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
private initHotkeys () { private initHotkeys () {
this.hotkeys = [ this.hotkeys = [
// These hotkeys are managed by the player // These hotkeys are managed by the player
new Hotkey('f', e => e, undefined, $localize`Enter/exit fullscreen (requires player focus)`), new Hotkey('f', e => e, undefined, $localize`Enter/exit fullscreen`),
new Hotkey('space', e => e, undefined, $localize`Play/Pause the video (requires player focus)`), new Hotkey('space', e => e, undefined, $localize`Play/Pause the video`),
new Hotkey('m', e => e, undefined, $localize`Mute/unmute the video (requires player focus)`), new Hotkey('m', e => e, undefined, $localize`Mute/unmute the video`),
new Hotkey('0-9', e => e, undefined, $localize`Skip to a percentage of the video: 0 is 0% and 9 is 90% (requires player focus)`), new Hotkey('0-9', e => e, undefined, $localize`Skip to a percentage of the video: 0 is 0% and 9 is 90%`),
new Hotkey('up', e => e, undefined, $localize`Increase the volume (requires player focus)`), new Hotkey('up', e => e, undefined, $localize`Increase the volume`),
new Hotkey('down', e => e, undefined, $localize`Decrease the volume (requires player focus)`), new Hotkey('down', e => e, undefined, $localize`Decrease the volume`),
new Hotkey('right', e => e, undefined, $localize`Seek the video forward (requires player focus)`), new Hotkey('right', e => e, undefined, $localize`Seek the video forward`),
new Hotkey('left', e => e, undefined, $localize`Seek the video backward (requires player focus)`), new Hotkey('left', e => e, undefined, $localize`Seek the video backward`),
new Hotkey('>', e => e, undefined, $localize`Increase playback rate (requires player focus)`), new Hotkey('>', e => e, undefined, $localize`Increase playback rate`),
new Hotkey('<', e => e, undefined, $localize`Decrease playback rate (requires player focus)`), new Hotkey('<', e => e, undefined, $localize`Decrease playback rate`),
new Hotkey('.', e => e, undefined, $localize`Navigate in the video frame by frame (requires player focus)`) new Hotkey(',', e => e, undefined, $localize`Navigate in the video to the previous frame`),
new Hotkey('.', e => e, undefined, $localize`Navigate in the video to the next frame`),
new Hotkey('t', e => {
this.theaterEnabled = !this.theaterEnabled
return false
}, undefined, $localize`Toggle theater mode`)
] ]
if (this.isUserLoggedIn()) { if (this.isUserLoggedIn()) {

View File

@ -687,9 +687,20 @@ export class PeertubePlayerManager {
player.playbackRate(parseFloat(newValue.toFixed(2))) player.playbackRate(parseFloat(newValue.toFixed(2)))
} }
}, },
frameByFrame: { previousFrame: {
key: function (event: KeyboardEvent) { key: function (event: KeyboardEvent) {
return isNaked(event, '.') return event.key === ','
},
handler: function (player: videojs.Player) {
player.pause()
// Calculate movement distance (assuming 30 fps)
const dist = 1 / 30
player.currentTime(player.currentTime() - dist)
}
},
nextFrame: {
key: function (event: KeyboardEvent) {
return event.key === '.'
}, },
handler: function (player: videojs.Player) { handler: function (player: videojs.Player) {
player.pause() player.pause()