Skip to content

Instantly share code, notes, and snippets.

@ravenjohn
Created August 10, 2023 06:31
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 ravenjohn/07e4ddf9a1375dabc5da1f7e8abc0be2 to your computer and use it in GitHub Desktop.
Save ravenjohn/07e4ddf9a1375dabc5da1f7e8abc0be2 to your computer and use it in GitHub Desktop.
Output devices on a table
navigator.mediaDevices.enumerateDevices()
.then(devices => devices.filter(dev => dev.deviceId && dev.kind === 'audioinput'))
.then(devices => devices.map((device) =>
navigator.mediaDevices.getUserMedia({
audio: {
deviceId: {
exact: device.deviceId
},
}
})
.then(stream => stream.getAudioTracks()[0])
.then(track => ({name: device.label, ...track.getSettings()}))
))
.then(promises => Promise.all(promises))
.then(console.table);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment