Created
March 31, 2023 23:26
-
-
Save bojidaryovchev/8b48adeeea84a59cc21b0bc5fa241b37 to your computer and use it in GitHub Desktop.
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
function amplifyMedia(mediaElem, multiplier) { | |
var context = new (window.AudioContext || window.webkitAudioContext), | |
result = { | |
context: context, | |
source: context.createMediaElementSource(mediaElem), | |
gain: context.createGain(), | |
media: mediaElem, | |
amplify: function(multiplier) { result.gain.gain.value = multiplier; }, | |
getAmpLevel: function() { return result.gain.gain.value; } | |
}; | |
result.source.connect(result.gain); | |
result.gain.connect(context.destination); | |
result.amplify(multiplier); | |
return result; | |
} | |
let [video] = document.getElementsByTagName('video'); | |
let multiplier = 4; | |
amplifyMedia(video, multiplier); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment