diff options
Diffstat (limited to 'client/src/assets/player/peertube-player.ts')
-rw-r--r-- | client/src/assets/player/peertube-player.ts | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index ef9e7fcc0..db63071cb 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts | |||
@@ -14,6 +14,10 @@ import { UserWatching, VideoJSCaption, videojsUntyped } from './peertube-videojs | |||
14 | import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' | 14 | import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' |
15 | import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' | 15 | import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' |
16 | 16 | ||
17 | // FIXME: something weird with our path definition in tsconfig and typings | ||
18 | // @ts-ignore | ||
19 | import { Player } from 'video.js' | ||
20 | |||
17 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) | 21 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) |
18 | videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' | 22 | videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' |
19 | // Change Captions to Subtitles/CC | 23 | // Change Captions to Subtitles/CC |
@@ -75,12 +79,12 @@ function getVideojsOptions (options: { | |||
75 | enableVolumeScroll: false, | 79 | enableVolumeScroll: false, |
76 | enableModifiersForNumbers: false, | 80 | enableModifiersForNumbers: false, |
77 | 81 | ||
78 | fullscreenKey: function (event: any) { | 82 | fullscreenKey: function (event: KeyboardEvent) { |
79 | // fullscreen with the f key or Ctrl+Enter | 83 | // fullscreen with the f key or Ctrl+Enter |
80 | return event.key === 'f' || (event.ctrlKey && event.key === 'Enter') | 84 | return event.key === 'f' || (event.ctrlKey && event.key === 'Enter') |
81 | }, | 85 | }, |
82 | 86 | ||
83 | seekStep: function (event: any) { | 87 | seekStep: function (event: KeyboardEvent) { |
84 | // mimic VLC seek behavior, and default to 5 (original value is 5). | 88 | // mimic VLC seek behavior, and default to 5 (original value is 5). |
85 | if (event.ctrlKey && event.altKey) { | 89 | if (event.ctrlKey && event.altKey) { |
86 | return 5 * 60 | 90 | return 5 * 60 |
@@ -95,26 +99,26 @@ function getVideojsOptions (options: { | |||
95 | 99 | ||
96 | customKeys: { | 100 | customKeys: { |
97 | increasePlaybackRateKey: { | 101 | increasePlaybackRateKey: { |
98 | key: function (event: any) { | 102 | key: function (event: KeyboardEvent) { |
99 | return event.key === '>' | 103 | return event.key === '>' |
100 | }, | 104 | }, |
101 | handler: function (player: any) { | 105 | handler: function (player: Player) { |
102 | player.playbackRate((player.playbackRate() + 0.1).toFixed(2)) | 106 | player.playbackRate((player.playbackRate() + 0.1).toFixed(2)) |
103 | } | 107 | } |
104 | }, | 108 | }, |
105 | decreasePlaybackRateKey: { | 109 | decreasePlaybackRateKey: { |
106 | key: function (event: any) { | 110 | key: function (event: KeyboardEvent) { |
107 | return event.key === '<' | 111 | return event.key === '<' |
108 | }, | 112 | }, |
109 | handler: function (player: any) { | 113 | handler: function (player: Player) { |
110 | player.playbackRate((player.playbackRate() - 0.1).toFixed(2)) | 114 | player.playbackRate((player.playbackRate() - 0.1).toFixed(2)) |
111 | } | 115 | } |
112 | }, | 116 | }, |
113 | frameByFrame: { | 117 | frameByFrame: { |
114 | key: function (event: any) { | 118 | key: function (event: KeyboardEvent) { |
115 | return event.key === '.' | 119 | return event.key === '.' |
116 | }, | 120 | }, |
117 | handler: function (player: any) { | 121 | handler: function (player: Player) { |
118 | player.pause() | 122 | player.pause() |
119 | // Calculate movement distance (assuming 30 fps) | 123 | // Calculate movement distance (assuming 30 fps) |
120 | const dist = 1 / 30 | 124 | const dist = 1 / 30 |