Open liudonghua123 opened 3 years ago
const path = require('path');
const fs = require('fs');
const basedir = __dirname.endsWith('app.asar')
? path.resolve(__dirname, '..', 'app.asar.unpacked')
: __dirname;
function getBundledFlashInfo() {
let pluginName;
let pluginVersion;
switch (process.platform) {
case 'win32':
pluginName = 'pepflashplayer.dll';
pluginVersion = '26.0.0.137';
break;
case 'darwin':
pluginName = 'PepperFlashPlayer.plugin';
pluginVersion = '26.0.0.131';
break;
case 'linux':
pluginName = 'libpepflashplayer.so';
pluginVersion = '32.0.0.101';
break;
}
return {
path: path.join(basedir, 'vendor', pluginName),
version: pluginVersion,
};
}
function loadFlash(app, flashPath) {
app.commandLine.appendSwitch('ppapi-flash-path', flashPath);
}
function setFlashVersion(app, version) {
app.commandLine.appendSwitch('ppapi-flash-version', version);
}
function setupPlugins(app) {
// Load Flash plugin
try {
let systemFlashPath = app.getPath('pepperFlashSystemPlugin');
fs.accessSync(systemFlashPath, fs.R_OK);
loadFlash(app, systemFlashPath);
} catch (err) {
console.log('Access system flash failed.');
let info = getBundledFlashInfo();
loadFlash(app, info.path);
setFlashVersion(app, info.version);
}
}
module.exports = {
setupPlugins,
};
// main.js
// plugin.setupPlugins(app);
cp vendor/libpepflashplayer.so app/vendor/
builder.yaml
asarUnpack:
- 'node_modules/*.{node,dll}'
- 'vendor'
I want to build a electron app which support flash. So I use an old electron
4.2.12
. And write the main code like the following.The strange thing is when I run
yarn electron src/main.js
oryarn compile && yarn electron dist/main/main.js
. The console always showedNOT SANDBOXED
(https://github.com/electron/electron/issues/1779) and the flash plugin loaded successfully.However, when I run
yarn dev
, the console did not showNOT SANDBOXED
, and the webpage showedCouldn't load plugin.
pepper_flash.zip