Discussion on: Screen Recording in 10 lines of Vanilla JS

jottedd profile image
Dr. Jeran Ott

Sebastian, Is there a way to also record the audio from the microphone?

sebastianstamm profile image
Sebastian Stamm Author

Sure! Instead of calling getDisplayMedia you would need to call getUserMedia, like this:

const stream = await navigator.mediaDevices.getUserMedia({
  audio: true

You can then plug this stream into the MediaRecorder like described in the post.