Electron unable to fetch resources (.swf)

北城以北 提交于 2020-01-05 08:24:24

问题


I am using electron (using pepper flash plugin) to load a swf file directly into my BrowserWindow. The .swf file loads correctly but the code inside the .swf file is requesting a seperate resource (eg: something.labels).

For some reason the something.labels file cannot be requested, everytime it fails instantly (screenshot). I cannot figure out why the error occurs, no details provided... any ideas?

Network request

main.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();
  }
});

回答1:


For everyone who is experiencing the same problem.. This is a bug in the elctron framework, introduced in version 7

Changing you're electron version to 6.1.2 will fix this



来源:https://stackoverflow.com/questions/58628818/electron-unable-to-fetch-resources-swf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!