Search code examples
flashelectron

How Can I make flash work in my electron application?


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


Solution

  • 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.