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.
查看电子文档以获得更多帮助
这篇关于如何在电子应用程序中访问相机/网络摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在电子应用程序中访问相机/网络摄像头?


基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01