久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Electron 加載遠程 URL 并加載本地文件

Electron load remote URL and load local file(Electron 加載遠程 URL 并加載本地文件)
本文介紹了Electron 加載遠程 URL 并加載本地文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個用于藝術展覽的視頻裝置,其中包含大型視頻(數(shù) GB)和一個在線托管的 web 應用程序.

I have a video installation for an art exhibition with big videos (several GBs) and a online hosted webapp.

由于我想在展覽期間節(jié)省一些帶寬,我想將視頻打包到一個電子應用程序中,在啟動時加載一次網(wǎng)頁,然后從本地文件系統(tǒng)/打包的電子應用程序加載視頻.

Since I want to save some bandwith during the exhibition, I would like to package the videos into an electron app, load the webpage once during startup and load the videos from the local filesystem / packaged electron app.

我已經(jīng)實現(xiàn)禁用webSecurity(沒關系,我旁邊沒有人運行這個應用程序)并且我已經(jīng)在JS控制臺中收到錯誤消息

I've already achieved to disable the webSecurity (it's fine, no one beside me runs this application) and I already get the error message in the JS console

GET file:///idle.mp4 net::ERR_FILE_NOT_FOUND.

我找不到引用本地文件的正確路徑/文件夾,您有什么提示嗎?我不能使用固定/絕對文件路徑,因為在線服務器不知道本地文件路徑..

I cannot find the right path/folder to reference the local file, do you have a hint for me? I can't use a fixed/absolute filepath, since the onlineserver has no knowledge about the local filepath..

我嘗試將視頻文件放入主文件夾和渲染器文件夾,但沒有成功,只顯示上面的錯誤消息.謝謝!

I tried to put the video files into the main and renderer folders, but it doesn't work out and only shows the error message above. Thank you!

目前我在我的 webapp 中引用這樣的視頻:

Currently I'm referencing the videos like this in my webapp:

<video id="id12">
  <source src="file:///ship.mp4" type="video/mp4"></source>
</video>

我的文件夾結構如下所示:

My folder structure looks like following:

推薦答案

我自己找到了解決方案,我只需要在我的電子應用程序中創(chuàng)建一個 fileProtocol 攔截器:

I found the solution by myself, I just had to create a fileProtocol interceptor in my electron app:

function createMainWindow() {

  protocol.interceptFileProtocol('file', function(req, callback) {
    var url = req.url.substr(7);
    callback({path: path.normalize(__dirname + url)})
  },function (error) {
    if (error)
      console.error('Failed to register protocol')
  })
...

這篇關于Electron 加載遠程 URL 并加載本地文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創(chuàng)建子窗口時如何修復 BrowserWindow 不是構造函數(shù)錯誤) - IT屋-程序員軟件開發(fā)技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網(wǎng)絡攝像頭?)
主站蜘蛛池模板: 国产成人免费 | 五月婷婷丁香 | 日日操操操 | 日本精品久久久久 | 久久精品色欧美aⅴ一区二区 | 美女视频黄色片 | 一级黄色片免费在线观看 | 久久久.com | 黄色片在线 | 成av在线 | 国产99久久精品一区二区永久免费 | 99爱在线观看 | 国产在线观看av | 一区二区成人在线 | 在线中文字幕日韩 | 欧美激情综合 | 国产精品99久久久久久动医院 | 国产一级电影在线 | 久久久亚洲综合 | 亚洲视频www| 久久高清亚洲 | 精品国产精品三级精品av网址 | 99久久久久久 | 国内自拍偷拍 | 亚洲视频在线观看免费 | 91久色| 精品久久久久久亚洲精品 | 精品视频一区二区在线观看 | 久久小视频 | 久久草在线视频 | 亚洲精品视频一区 | 夜夜爽99久久国产综合精品女不卡 | av在线电影网站 | 国产欧美一区二区在线观看 | 欧美日韩成人在线观看 | 国产美女一区二区 | 日本一区二区三区视频在线 | 色综合久 | 九九综合九九 | 午夜欧美a级理论片915影院 | 欧美99久久精品乱码影视 |