Last active
January 30, 2020 22:05
-
-
Save pfgithub/295841cc1bb742ce08cd7178eb253746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let video = document.querySelector("video"); | |
let frameTime = 0.01; | |
let timeElem = document.createElement("div"); | |
let q = document.createTextNode("---"); | |
timeElem.style.position = "fixed"; | |
timeElem.style.top = "0"; | |
timeElem.style.right = "0"; | |
timeElem.style.padding = "10px"; | |
timeElem.style.fontSize = "24pt"; | |
timeElem.style.backgroundColor = "#fff"; | |
timeElem.style.color = "#000"; | |
timeElem.appendChild(q); | |
document.body.appendChild(timeElem); | |
setInterval(() => (q.nodeValue = video.currentTime.toFixed(2)), 100); | |
window.addEventListener("keypress", function(evt) { | |
console.log(evt.key); | |
if (evt.key === ",") { | |
video.pause(); | |
video.currentTime = Math.max(0, video.currentTime - frameTime); | |
} else if (evt.key === ".") { | |
video.pause(); | |
video.currentTime = Math.min(video.duration, video.currentTime + frameTime); | |
} else if (evt.key === "k") { | |
if(video.paused) video.play(); else video.pause(); | |
} else if (evt.key === "d") { | |
video.pause(); | |
video.currentTime = Math.min(video.duration, video.currentTime + frameTime * 10); | |
} else if (evt.key === "a") { | |
video.pause(); | |
video.currentTime = Math.max(0, video.currentTime - frameTime * 10); | |
} else if (evt.key === "l") { | |
video.pause(); | |
video.currentTime = Math.min(video.duration, video.currentTime + frameTime * 100); | |
} else if (evt.key === "j") { | |
video.pause(); | |
video.currentTime = Math.max(0, video.currentTime - frameTime * 100); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment