Hacker News new | ask | show | jobs
by throwaway40324 2422 days ago
It's been a little while since I used this, but navigator.mediaDevices.enumerateDevices

will give you that list, allowing you to have a menu for a user to choose one and then the client code must use setSinkId to assign the chosen device id. https://developer.mozilla.org/en-US/docs

1 comments

The IDs you get (both deviceID and groupID) are not user displayable. They're like random numbers. In normal browsing mode, you keep getting the same deviceIDs for the same domain, but random groupIDs for every refresh. You get different deviceIDs for different sites. In private browsing mode, you get both random every time.
Ah, I forgot that the device label is only returned when there is an active stream. And has zero support in Safari. https://developer.mozilla.org/en-US/docs/Web/API/MediaDevice...

I never knew the device ids were randomized like that, thanks for the info.