electron-userland / electron-userland/electron-webpack

electron-webpack dev not works for flash plugin

Open
#443 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
902
Forks
168
PR merge metrics
No merged PRs in 30d

Description

* **Version**:
```json
{
"name": "electron-webpack-quick-start",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"dist": "yarn compile && electron-builder",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null"
},
"dependencies": {
"source-map-support": "^0.5.16"
},
"devDependencies": {
"electron": "4.2.12",
"electron-builder": "^22.4.1",
"electron-webpack": "^2.8.2",
"webpack": "~4.42.1"
}
}
```

* **Target**:
Windows

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.

```js
'use strict'

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

const isDevelopment = process.env.NODE_ENV !== 'production'
console.info(isDevelopment)

// global reference to mainWindow (necessary to prevent window from being garbage collected)
let mainWindow

function createMainWindow() {
console.info(`createMainWindow`)
const window = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: false,
plugins: true,
}
})

if (isDevelopment) {
window.webContents.openDevTools()
}

window.loadURL(
'https://www.ultrasounds.com/'
);

window.on('closed', () => {
mainWindow = null
})

window.webContents.on('devtools-opened', () => {
window.focus()
setImmediate(() => {
window.focus()
})
})

return window
}

// Specify flash path, supposing it is placed in the same directory with main.js.
const flash_version = '27_0_0_159';
const arch = process.arch === 'x64' ? '64' : '32';
let pluginName;
switch (process.platform) {
case 'win32':
pluginName = `pepflashplayer${arch}_${flash_version}.dll`
break
case 'darwin':
pluginName = `PepperFlashPlayer${arch}_${flash_version}.plugin`
break
case 'linux':
pluginName = `libpepflashplayer${arch}_${flash_version}.so`
break
}

const flash_path = path.join(__dirname, 'pepper_flash', pluginName);
console.info(`try to use flash_version: ${flash_version}, flash_path: ${flash_path}`);
if (!fs.existsSync(flash_path)) {
console.error(`flash_path ${flash_path} does not exists!`);
}
else {
console.info(`flash_path ${flash_path} ok!`);
}
app.commandLine.appendSwitch('ppapi-flash-path', flash_path)
// Optional: Specify flash version
app.commandLine.appendSwitch('ppapi-flash-version', flash_version)
// app.commandLine.appendSwitch('--enable-sandbox')

// quit application when all windows are closed
app.on('window-all-closed', () => {
// on macOS it is common for applications to stay open until the user explicitly quits
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
// on macOS it is common to re-create a window even after all windows have been closed
if (mainWindow === null) {
mainWindow = createMainWindow()
}
})

// create main BrowserWindow when electron is ready
app.on('ready', () => {
mainWindow = createMainWindow()
})

```

The strange thing is when I run `yarn electron src/main.js` or `yarn compile && yarn electron dist/main/main.js`. The console always showed `NOT SANDBOXED` (https://github.com/electron/electron/issues/1779) and the flash plugin loaded successfully.

However, when I run `yarn dev`, the console did not show `NOT SANDBOXED`, and the webpage showed `Couldn't load plugin.`

![image](https://user-images.githubusercontent.com/2276718/120054927-79a4b780-c065-11eb-8cc6-8a54cc0c0b5c.png)

[pepper_flash.zip](https://github.com/electron-userland/electron-webpack/files/6563896/pepper_flash.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.