Last active
November 29, 2017 22:25
-
-
Save pedrouid/7c7177e18e9390dc385d846e9a4a12d5 to your computer and use it in GitHub Desktop.
Tiny script to change currently playing HTML video speed
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
// 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