DEV Community

Janavi Anand
Janavi Anand

Posted on

Electron App live streaming— MAC OS

Recently I was working in an Electron app, to set up a live video. It was a very basic set up. I am using MAC OS - Catalina.

I am new to Electron and forked the repo that has the basic set up.

git-hub link to project

I followed all the steps, but I could not get my video or audio consent window.

After spending some on debugging it, came across the doc,

electron-docs

systemPreferences.askForMediaAccess('camera').then((allowed)=>console.log('Camera is allowed'))

Adding the above lines in main.js , should solve the issue.
However, I ran electron . in my folder and the whole app crashed.

I was doing all this from my VS Code terminal, which crashed the app. We need to get permission to access the camera for the electron app and looks like the permissions were requested for VS Code.

Starting the server from Terminal or iTerm (I used iTerm), solved the issue, which requested permission for the app. Once the permission or user consent is given, I was able to access the camera, for other electrons app as well. It is a one time setup and it enables us to access the camera for other apps as well, without going over the above code set up.

REFERENCES

Top comments (0)