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

在電子中使用 AudioWorklet (DOMException: The user abort

Use AudioWorklet within electron (DOMException: The user aborted a request)(在電子中使用 AudioWorklet (DOMException: The user aborted a request))
本文介紹了在電子中使用 AudioWorklet (DOMException: The user aborted a request)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試在我的電子應用程序中使用 AudioWorklet 進行計量等.在開發模式下執行時工作正常,其中工作集由諸如 http://localhost:3000/processor.js.但是,如果我嘗試在 prod 模式下運行該應用程序,則該文件將在本地提供,例如 file://tmp/etc/etc/build/processor.js 并且在開發人員控制臺中,我什至可以看到該文件正在正確預覽,但我收到此錯誤消息:

I am trying to use an AudioWorklet within my electron app for metering etc. which works fine when executed in dev mode where the worklet is being served by an express dev server like http://localhost:3000/processor.js. However if I try to run the app in prod mode the file is being served locally like file://tmp/etc/etc/build/processor.js and in the developer-console I can even see the file correctly being previewed but I get this error message:

Uncaught (in promise) DOMException: The user aborted a request.

Uncaught (in promise) DOMException: The user aborted a request.

在在這里但不幸的是,我在堆棧溢出方面的聲譽還不夠高,無法直接發表評論.將 mime 類型更改為 application/javascript 或 text/javascript 的建議聽起來不錯,但我不知道如何強制電子對特定文件使用特定的 mime 類型.此外,在網絡選項卡的開發者控制臺中,似乎 chromium 實際上已經為我的 processor.js 假設了一個 javascript 文件.

I saw that someone else had a similar problem before over here but unfortunately my reputation on stack overflow is not high enough to comment directly. The suggestion there to change the mime-type to application/javascript or text/javascript sounds good but I have no idea how to force electron to use a specific mime-type for a specific file. Furthermore in the developer-console in the network tab it seems like chromium is actually already assuming a javascript file for my processor.js.

我已經嘗試使用類似的自定義協議加載工作集

I already tried to load the worklet with a custom protocol like that

protocol.registerStandardSchemes(['worklet']);

app.on('ready', () => {
  protocol.registerHttpProtocol('worklet', (req, cb) => {
    fs.readFile(req.url.replace('worklet://', ''), (err, data) => {
      cb({ mimeType: 'text/javascript', data });
    });
  });
});

然后在添加worklet時

and then when adding the worklet

await ctx.audioWorklet.addModule('worklet://processor.js');

不幸的是,這只以這些錯誤結束,然后是第一個錯誤

unfortunately this only ends in these errors followed by the first error

GET worklet://processor.js/0 ()
未捕獲的錯誤:您提供的錯誤不包含堆棧跟蹤.
...

GET worklet://processor.js/ 0 ()
Uncaught Error: The error you provided does not contain a stack trace.
...

推薦答案

如果有人感興趣,我找到了一個 hacky 解決方案.為了強制使用 mime 類型的電子/鉻,我很高興我將帶有文件 api 作為字符串的 worklet 文件加載,將其轉換為具有 mime 類型 text/javascript 的 blob,然后從中創建一個對象 url

I found a hacky solution if anybody is interested. To force a mime-type electron / chromium is happy with I load the worklet file with the file api as a string, convert it to a blob with mime-type text/javascript and then create an object url from that

const processorPath = isDevMode ? 'public/processor.js' : `${global.__dirname}/processor.js`;
const processorSource = await readFile(processorPath); // just a promisified version of fs.readFile
const processorBlob = new Blob([processorSource.toString()], { type: 'text/javascript' });
const processorURL = URL.createObjectURL(processorBlob);
await ctx.audioWorklet.addModule(processorURL);

希望這對遇到同樣問題的人有所幫助...

Hope this helps anyone having the same problem...

這篇關于在電子中使用 AudioWorklet (DOMException: The user aborted a request)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
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 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 狠狠干美女 | 国产探花在线精品一区二区 | 国产女人与拘做受免费视频 | a成人| www成人免费视频 | 91视频在线 | 国产 欧美 日韩 一区 | 国产亚洲精品久久久优势 | 国产乱码精品一区二区三区中文 | 午夜噜噜噜 | 欧美日在线| 欧美一二三 | 欧美三级网站 | 国产激情在线 | 欧美一区精品 | 日韩免费| 亚洲一二三区免费 | 国产一区二区三区久久久久久久久 | 欧美日韩成人在线 | 日本欧美视频 | 一级黄色生活视频 | 中文字字幕在线中文乱码范文 | 国产精品免费一区二区 | 在线成人免费视频 | 亚洲人在线观看视频 | 午夜网| 黄视频在线网站 | 成年人国产在线观看 | 久草网址 | 久久久久久一区 | 夜夜操天天干 | 成人黄色电影在线播放 | 资源首页二三区 | av资源网站 | 欧美日韩国产免费 | 国产精品久久国产精品 | 国产成人精品a视频一区www | 成人免费在线 | 成人欧美一区二区三区色青冈 | 精品国产乱码久久久久久蜜退臀 | 欧美日韩最新 |