Skip to content

Instantly share code, notes, and snippets.

@Krishna
Forked from pragdave/clapperboard.js
Created April 23, 2020 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Krishna/397ffa0def039c2dafc9e5aca31363a3 to your computer and use it in GitHub Desktop.
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
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)
}
@Krishna
Copy link
Author

Krishna commented Apr 23, 2020

Trivial JS function to help sync sound and screen when recording a browser based screencast

Courtesy of @pragdave's tweet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment