2

I am trying to create a launcher for a flash game. I am new in electron and in programming so I was reading the electron documentation but my flash isn't working.

const electron = require('electron')
const { app, BrowserWindow } = require('electron')
const path = require('path');
let pluginName
switch (process.platform) {
 case 'win32':
   pluginName = 'pepflashplayer.dll'
   break
 case 'darwin':
   pluginName = 'PepperFlashPlayer.plugin'
   break
 case 'linux':
   pluginName = 'libpepflashplayer.so'
   break
}
app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, pluginName))
function createWindow () {
 // Create the browser window.
 let win = new BrowserWindow({
   width: 800,
   height: 600,
   webPreferences: {
     nodeIntegration: true,
     plugins: true,
     webviewTag: true
   }
 }) 
 win.removeMenu(BrowserWindow);

 // and load the index.html of the app.
 win.loadFile('index.html')

 win.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.
   win = null
 })

}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
 // On macOS 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 macOS 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 (win === null) {
   createWindow()
 }
})

The site loads normally but the flash isn't working. So, is something that I am doing wrong? How can I get it working?

Thanks!

Obs: This is my main.js

Dharman
  • 30,962
  • 25
  • 85
  • 135
aquasp
  • 67
  • 1
  • 8
  • 1
    See if this helps: https://stackoverflow.com/a/44550314 – VC.One Sep 19 '19 at 20:52
  • The lib flash is in the same directory. – aquasp Sep 19 '19 at 21:46
  • Maybe this problem is linked to chromium default block to flash? – aquasp Sep 19 '19 at 21:46
  • I don't use Electron. `pluginName = './pepflashplayer.dll'` Are you saying doing it this way doesn't work? Also do you think Electron would accept the alternative NP-API file `NPSWF32.dll` instead of Chromium's own version which uses PP-API? After installing the Flash Player program, find the DLL and copy it to your app directory. – VC.One Sep 19 '19 at 22:03
  • Link: http://get.adobe.com/flashplayer/download/?installer=FP_32_for_Firefox_-_NPAPI&os=Windows%207&browser_type=KHTML&browser_dist=Chrome&dualoffer=false&mdualoffer=true&stype=7694&d=McAfee_Security_Scan_Plus&d=McAfee_Safe_Connect – VC.One Sep 19 '19 at 22:03
  • I did the download, but still not working – aquasp Sep 20 '19 at 20:09
  • It's solved. The answer is: Newer electron versions are not working with flash. – aquasp Sep 24 '19 at 03:42
  • 1
    If you want to use flash, use electron 4.2.6 – aquasp Sep 24 '19 at 03:43
  • you should post that information as an Answer in the big box. It may help others in the future. – VC.One Sep 25 '19 at 16:12
  • I have tried with 4.2.6 electron version. But flash is not working on Mac OS. – Mir Adnan Dec 24 '20 at 19:26

2 Answers2

1

Use an older electron version (4.2.6). Newer electron versions (newer than 4.2.6) will not load flash content.

Edit: In Linux, latest electron from 4.2.x series will work with flash player. In windows, latest version works normally

Added on behalf of question asker.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

Flash appears to be working at least to some extent with Electron 9.0. I've got a test app with Electron 9 (Chromium 83) loading the plugin on my Mac, and also see here: Can I bundle Pepper Flash in an Electron.js app to run Flash in 2021+? Presently having some trouble saving files that my Flash app wants to save while it is embedded within my Electron app, but that may have always been an issue with Flash Player-Electron integration? Not sure.