Last active
June 16, 2021 19:08
-
-
Save lucaslgr/c9bbe1a71f18cf02a0ea2a51ac1eb912 to your computer and use it in GitHub Desktop.
Acelerador de video para tag <video>e <iframe>
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
//<IFRAME> | |
var playbackRate = 3; | |
var data = {event: 'command', func: 'setPlaybackRate', args: [playbackRate, true]}; | |
var message = JSON.stringify(data); | |
$('iframe')[0].contentWindow.postMessage(message, '*'); | |
//<ALL IFRAMES WITHOUT JQUERY> | |
var playbackRate = 3; | |
var data = {event: 'command', func: 'setPlaybackRate', args: [playbackRate, true]}; | |
var message = JSON.stringify(data); | |
var iframes = document.querySelectorAll("iframe"); | |
iframes.forEach(fr => fr.contentWindow.postMessage(message, '*')) | |
//<VIDEO> | |
var vid = document.querySelector('video'); | |
vid.playbackRate = 3; | |
//<ALL VIDEOS> | |
var vids = document.querySelectorAll('video'); | |
vids.forEach(vid => vid.playbackRate = 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment