Audio devices plugin and plugout event on chrome browser

与世无争的帅哥 提交于 2020-01-24 22:47:05

问题


I'm building an audio chat web application using WebRTC. So I trying to build that if any external audio device get plugged-in to the system my application automatically start using that microphone and when that external device plugged out application start using system default microphone (as Hangout do).

  1. Is there any event that notify me about device plugged-in plugged-out information?(For chrome browser)

  2. Is there any way to know which device to use in all the listed device that we get from browser so that we actually get an audio? (For example as in desktop systems there are two microphone jacks one in front-side another in back-side so when get Media Devices in browser we will get both jacks as device, but how to choose between both jacks that in this particular jack a microphone is plugged-in)

  3. How system choose default device. Is it good to use always default device?

  4. What is the difference between default and communication devices that browser provides?


回答1:


(1) in the spec, a devicechange event is fired on the navigator.mediaDevices object. That is not yet implemented in Chrome. You can poll navigator.mediaDevices.enumerateDevices which has a performance impact however.

(2) enumerate the devices and look at their labels? See this sample



来源:https://stackoverflow.com/questions/38879393/audio-devices-plugin-and-plugout-event-on-chrome-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!