-
-
Save Krishna/397ffa0def039c2dafc9e5aca31363a3 to your computer and use it in GitHub Desktop.
Trivial JS function to help sync sound and screen when recording a browser based screencast
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
export function clapperBoard() { | |
let audio = new AudioContext() | |
let beep = audio.createOscillator() | |
let flash = document.createElement("div") | |
beep.frequency.value = 440 * 5 | |
beep.connect(audio.destination) | |
flash.classList.add("clapperboard") | |
beep.start() | |
document.body.appendChild(flash) | |
setTimeout(() => flash.remove(), 100) | |
beep.stop(audio.currentTime + 0.1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Courtesy of @pragdave's tweet