Skip to content

Instantly share code, notes, and snippets.

@GabiGrin
Created May 7, 2020 16:14
Show Gist options
  • Save GabiGrin/3f071f84f57edf5988ee9a04bc4ee3b5 to your computer and use it in GitHub Desktop.
Save GabiGrin/3f071f84f57edf5988ee9a04bc4ee3b5 to your computer and use it in GitHub Desktop.
(() => {
const desiredSpeed = 1.5;
const timeToDesiredSpeed = 5 * 60 * 1000; // 3 minutes
const intervalSpeed = 5000;
const intervals = timeToDesiredSpeed / intervalSpeed;
const speedingRate = (desiredSpeed - 1) / intervals;
const start = new Date();
setInterval(() => {
const vid = document.querySelector('video');
const curr = vid.playbackRate;
const newSpeed = Math.min(desiredSpeed, curr + speedingRate);
console.info(`Speeding ${curr} -> ${newSpeed}`);
vid.playbackRate = newSpeed;
}, intervalSpeed);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment