Request microphone permission in electron

冷暖自知 提交于 2021-01-23 06:24:23

问题


I have an electron app that uses the webkit speech recognition API. If tested in the browser, everything works as intended, but if run in the electron environment, the speech recognition api doesn't work.

What I mean is that when I press the button that starts the recording, the recording won't start in the electron environment. I believe that is because unlike when running the code in the browser, I wasn't asked for and therefore not granted microphone access. So my question is then, how can I request access for the microphone in an electron app? Thanks in advance!


回答1:


Found this in the electron docs. https://electronjs.org/docs/api/system-preferences#systempreferencesaskformediaaccessmediatype-macos

If you're using macOS to run the app use that method to request permission. If not it doesn't look like the app requires permission to use the microphone or camera.



来源:https://stackoverflow.com/questions/56713994/request-microphone-permission-in-electron

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