【问题标题】:Electron unable to fetch resources (.swf)Electron 无法获取资源 (.swf)
【发布时间】:2020-02-25 22:56:20
【问题描述】:

我正在使用电子(使用辣椒闪存插件)将 swf 文件直接加载到我的 BrowserWindow 中。 .swf 文件正确加载,但 .swf 文件中的代码请求单独的资源(例如:something.labels)。

由于某种原因,无法请求 something.labels 文件,每次它都会立即失败(屏幕截图)。我无法弄清楚为什么会发生错误,没有提供任何细节......有什么想法吗?

网络请求

ma​​in.js

const { app, BrowserWindow } = require('electron');
const path = require('path');

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
  app.quit();
}

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

const createWindow = () => {
  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 800,
    height: 900,
    titleBarStyle: 'hidden',
    resizable: true,
    autoHideMenuBar: true,

    webPreferences: {
      plugins: true
    }
  });

  // and load the index.html of the app.
  mainWindow.loadURL('https://example.org/myapplication.swf');

  // Open the DevTools.
  mainWindow.webContents.openDevTools({ mode: 'detach' });

  // Emitted when the window is closed.
  mainWindow.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
};

app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, 'pepflashplayer.dll'));
app.commandLine.appendSwitch('ppapi-flash-version', '32.0.0.270');

// This method will be called when Electron has finished
// initialization and is ready to create browser windows. 
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  // On OS X it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (mainWindow === null) {
    createWindow();
  }
});

【问题讨论】:

  • 不知道——但为了测试,我会尝试在创建BrowserWindow 实例时设置webSecurity: false。
  • @NoGrabbing 是一个很好的尝试,但没有奏效

标签: javascript node.js flash electron


【解决方案1】:

对于遇到同样问题的每个人.. 这是 elctron 框架中的一个错误,在版本 7 中引入

将您的电子版本更改为 6.1.2 将解决此问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-17
    • 2022-01-14
    • 2021-01-07
    • 1970-01-01
    相关资源
    最近更新 更多