Created
April 18, 2020 23:00
-
-
Save pragdave/7c613d1858079841dfaa06584e772fc5 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