-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenableFrameJumping.js
36 lines (34 loc) · 1.25 KB
/
enableFrameJumping.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function enableFrameJumping(sharedData) {
var videoElem = document.querySelector('video');
var prevTime = 0;
function setFramesPerJump(sharedData) {
var tmp = parseInt(prompt("Frames to jump: "));
if (tmp) {
sharedData.framesPerJump = tmp;
}
}
setFramesPerJump(sharedData);
prevTime = videoElem.currentTime;
$('.ytp-progress-bar').click(function() {
prevTime = videoElem.currentTime;
console.log('reset prevtime');
});
$(document).keydown(function(e) {
if (e.which === 190 || e.which === 188) {
// period or comma was pressed
if (!sharedData.secondsPerFrame) {
var timeSkip = videoElem.currentTime - prevTime;
sharedData.secondsPerFrame = Math.abs(timeSkip);
}
if (e.which === 190) {
videoElem.currentTime = prevTime + sharedData.secondsPerFrame * framesPerJump;
} else {
videoElem.currentTime = prevTime - sharedData.secondsPerFrame * framesPerJump;
}
prevTime = videoElem.currentTime;
} else if (e.which === 70 && e.ctrlKey && e.altKey) {
// Ctrl+alt+f was pressed
setFramesPerJump();
}
});
}