Created
August 10, 2023 06:31
-
-
Save ravenjohn/07e4ddf9a1375dabc5da1f7e8abc0be2 to your computer and use it in GitHub Desktop.
Output devices on a table
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
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