How to access camera/webcamera inside electron app?(如何在电子应用程序中访问相机/网络摄像头?)
问题描述
我有一个网络电子应用程序,我想在其中一个页面中实现摄像头.
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.
查看电子文档以获得更多帮助
这篇关于如何在电子应用程序中访问相机/网络摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在电子应用程序中访问相机/网络摄像头?


- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01