Skip to content

Instantly share code, notes, and snippets.

@pedrouid
Last active November 29, 2017 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrouid/7c7177e18e9390dc385d846e9a4a12d5 to your computer and use it in GitHub Desktop.
Save pedrouid/7c7177e18e9390dc385d846e9a4a12d5 to your computer and use it in GitHub Desktop.
Tiny script to change currently playing HTML video speed
// Copy & Paste to the browser's console and call function to adjust playbackRate for currenly playing videos
// Common playback rates are 0.25 / 0.5 / 0.75 / 1.0 / 1.25 / 1.5 / 1.75 / 2.0
// Maximum value recommended is 4.0 (browser / hardward dependent)
// @param {Number} [rate = 1.0]
function changePlaybackRate(rate) {
var videos = document.getElementsByTagName('video');
var currentlyPlaying = [];
var playbackRate = Number(rate) || 1.0;
for (var i = 0; i < videos.length; i++) {
if (!videos[i].paused) {
currentlyPlaying.push(videos[i]);
}
}
currentlyPlaying[0].playbackRate = playbackRate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment