如何在电子应用程序中访问相机/网络摄像头?
我有一个网络电子应用程序,我想在其中一个页面中实现摄像头.
I have a web electron application and I want to implement camera in one of the pages.
问题是最近出于安全原因,网络摄像头只能通过https"访问.但是对于在本地提供应用程序的 Electron 应用程序,方案是不同的,因此流式传输失败.所以我的问题是:
The problem is that lately for security reasons webcam can only be accessed via 'https'. But in case of an Electron app where the application is served locally the scheme is different and therefore streaming fails. So my question is:
有什么好的解决方案可以在电子内部实现网络摄像头吗?
如果不行,除了网络摄像头还有什么解决方案可行?
推荐答案
我正在回答我自己的问题,以防它帮助其他人.在我的情况下,a 有一个自定义方案,而不是标准方案,即 file
但我遗漏了一些东西.我发现我只需要在 registerStandardSchemes
(版本 4)中添加:{ secure: true }
.这让 electron 知道这个方案是安全的,并且足以让网络摄像头工作.
I am answering my own question in case it helps anyone else. In my case a had a custom scheme instead of the standard one which is file
but I was missing something. I found out I just had to add: { secure: true }
inside registerStandardSchemes
(version 4). That makes electron know that this scheme is secure and that is enough for webcam to work.
查看电子文档以获得更多帮助
相关文章