Last active
April 22, 2021 15:50
-
-
Save nonoesp/ed3448e0ed223883f1c73c5ffdf02d70 to your computer and use it in GitHub Desktop.
Override Playback of Audio and Video HTML5 Elements
This file contains hidden or 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
// Nono Martínez Alonso | |
// Nono.MA | |
// 2021.04.22 | |
// MIT License | |
let overridePlaybackSpeed = 5; | |
let overridePlaybackVolume = 0; | |
setInterval(() => { | |
// Obtain all button-counter elements | |
let elements = document.getElementsByClassName('audio-player__audio-element'); | |
// Convert HTMLCollection to array | |
let arr = Array.prototype.slice.call( elements ); | |
// Loop through array and mount all elements | |
arr.forEach((el) => { | |
console.log(el); | |
el.playbackRate = overridePlaybackSpeed; | |
el.volume = overridePlaybackVolume; | |
}); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment