Is it possible to check if the user has a camera and microphone and if the permissions have been granted with Javascript?

前端 未结 6 1606
情书的邮戳
情书的邮戳 2020-12-13 03:09

I would like to find out if the user\'s device has an attached camera and microphone, and if so, has permissions been granted to get the audio and video stream using Javascr

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 03:40

    You can use the MediaStreamTrack which represent a media stream, then you can use its getSources method as explained here: html5rocks

    If you don't get any media sources then your client hasn't a webcam. It's not supported by firefox.

提交回复
热议问题