How to detect if microphone permissions have been granted in chrome

后端 未结 3 843
谎友^
谎友^ 2021-02-01 22:58

I would liked to detect whether or not microphone permissions have been granted on my site when it loads without actually running something like the following:

n         


        
3条回答
  •  既然无缘
    2021-02-01 23:15

    navigator.getUserMedia is now obsolete, replaced by MediaDevices.getUserMedia, which returns a promise. If the promise gets rejected you get an DOMException with indication of the problem. Insufficient permissions is one of the options there.

    Details here: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

提交回复
热议问题