adding shortcuts to videojs, adding frame-by-frame support

pull/1156/head
Rigel Kent 2018-09-30 15:18:03 +02:00
parent 8b183196cb
commit 0f40d69a0f
No known key found for this signature in database
GPG Key ID: EA12971B0E438F36
1 changed files with 30 additions and 0 deletions

View File

@ -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)
}
}
}
}