問(wèn)題描述
我有一個(gè)網(wǎng)絡(luò)電子應(yīng)用程序,我想在其中一個(gè)頁(yè)面中實(shí)現(xiàn)攝像頭.
I have a web electron application and I want to implement camera in one of the pages.
問(wèn)題是最近出于安全原因,網(wǎng)絡(luò)攝像頭只能通過(guò)https"訪問(wèn).但是對(duì)于在本地提供應(yīng)用程序的 Electron 應(yīng)用程序,方案是不同的,因此流式傳輸失敗.所以我的問(wèn)題是:
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:
有什么好的解決方案可以在電子內(nèi)部實(shí)現(xiàn)網(wǎng)絡(luò)攝像頭嗎?
如果不行,除了網(wǎng)絡(luò)攝像頭還有什么解決方案可行?
推薦答案
我正在回答我自己的問(wèn)題,以防它幫助其他人.在我的情況下,a 有一個(gè)自定義方案,而不是標(biāo)準(zhǔn)方案,即 file
但我遺漏了一些東西.我發(fā)現(xiàn)我只需要在 registerStandardSchemes
(版本 4)中添加:{ secure: true }
.這讓 electron 知道這個(gè)方案是安全的,并且足以讓網(wǎng)絡(luò)攝像頭工作.
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.
查看電子文檔以獲得更多幫助
這篇關(guān)于如何在電子應(yīng)用程序中訪問(wèn)相機(jī)/網(wǎng)絡(luò)攝像頭?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!