Skip to content

Instantly share code, notes, and snippets.

@pragdave
Created April 18, 2020 23:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pragdave/7c613d1858079841dfaa06584e772fc5 to your computer and use it in GitHub Desktop.
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
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