From 0f40d69a0f8c24969fd0afa8511ff598c604ca38 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 30 Sep 2018 15:18:03 +0200 Subject: adding shortcuts to videojs, adding frame-by-frame support --- client/src/assets/player/peertube-player.ts | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'client/src') diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 2c16c87ec..1bf6c9267 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts @@ -70,6 +70,25 @@ function getVideojsOptions (options: { hotkeys: { enableVolumeScroll: false, enableModifiersForNumbers: false, + + fullscreenKey: function (event) { + // fullscreen with the f key or Ctrl+Enter + return event.key === 'f' || (event.ctrlKey && event.key === 'Enter') + }, + + seekStep: function (event) { + // mimic VLC seek behavior, and default to 5 (original value is 5). + if (event.ctrlKey && event.altKey) { + return 5 * 60 + } else if (event.ctrlKey) { + return 60 + } else if (event.altKey) { + return 10 + } else { + return 5 + } + }, + customKeys: { increasePlaybackRateKey: { key: function (event) { @@ -86,6 +105,17 @@ function getVideojsOptions (options: { handler: function (player) { player.playbackRate((player.playbackRate() - 0.1).toFixed(2)) } + }, + frameByFrame: { + key: function (event) { + return event.key === '.' + }, + handler: function (player, options, event) { + player.pause() + // Calculate movement distance (assuming 30 fps) + const dist = 1 / 30 + player.currentTime(player.currentTime() + dist) + } } } } -- cgit v1.2.3