久久久久久久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)絡攝像頭?)
主站蜘蛛池模板: 久久久激情视频 | 99精品一区二区三区 | 成人精品区 | 久草视频在线播放 | 特级一级黄色片 | 国产成人精品一区二区三区在线 | 一区网站| 久久精品国产亚洲a | 久免费视频| 欧美日韩在线观看一区 | 久草精品视频 | 国产精品一码二码三码在线 | 久久免费看 | 欧美日韩精品免费 | 日本一区不卡 | 黄色骚片| 国产精品1区2区 | 欧美区在线 | 特级黄色毛片 | 日本视频在线播放 | 亚洲欧美久久 | 一区二区三区国产 | 国产精品久久久久久久久免费相片 | 成人在线免费网站 | 天天干狠狠操 | 免费a级毛片在线播放 | 中文字幕 在线观看 | av大全在线观看 | 久久精品视频在线观看 | 欧美日韩专区 | 华人黄网站大全 | 日本天天操 | 成人在线小视频 | 午夜欧美| 久久新| 国产精品成人久久久久 | 涩涩视频在线播放 | 久久久久亚洲av毛片大全 | www.日本在线 | 久久久亚洲 | 国产精品久久九九 |