添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
文武双全的爆米花  ·  Mysql ...·  1 年前    · 
性感的小摩托  ·  python - ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Background

The machine I am trying to implement this on contains multiple cameras, I want to select the camera in the code. (all machines have the same hardware)

Issue

I am trying to implement a custom function before requesting video access where I manually set which device that should be used to prevent selection of wrong camera, but when I use

await navigator.mediaDevices.enumerateDevices()

I get empty labels for available video camera devices.

navigator.mediaDevices.enumerateDevices() will return an empty label attribute value if the permission for accessing the mediadevice is not given. Try using it after getUserMedia.

(async () => {   
  await navigator.mediaDevices.getUserMedia({audio: true, video: true});   
  let devices = await navigator.mediaDevices.enumerateDevices();   
  console.log(devices); 
})();
                but how is google meet accessing these labels when i haven't given it the permission and its not only in chrome but in firefox as well. Really wierd how they are getting this info.
– orangespark
                Mar 2, 2020 at 9:07
                are you sure you have not given permission for accessing video or audio? Make sure the entry is not present here - chrome://settings/content/camera  As far as i have seen hangouts asks for camera and microphone as soon as you click Video call.
– Karthik
                Mar 2, 2020 at 9:53
                it asks for permission if the camera needs to be accessed has to be shown but the labels are shown before giving permission. I was amazed how it was working
– orangespark
                Mar 2, 2020 at 14:48
                Note that the enumerate calls don't work on a local dev machine. They have to be deployed to your website in order to function properly.
– fmacdee
                Apr 28, 2020 at 4:06
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.