Pepper Flash loads in webview, but not elsewhere


#1

I am currently trying to get Pepper flash to load a local swf. I have copied the PepperFlashPlayer.plugin from Chrome into my project and referenced it in the code.

However, the main renderer can not load a swf, but a webview is able to load swfs (by loading the Adobe Flash about page).

When I check the debugger, I am able to see the plug is loaded via navigator.plugins If I comment out the app.commandLine.appendSwitch lines, the webview will also not load SWFs.

main.js

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

let win;

function createWindow() {
  win = new BrowserWindow({
    width: 800,
    height: 600,
    resizable: true,
      'web-preferences': {
        plugins: true
      }
    }
  );

  win.loadURL('file://' + path.join(__dirname, 'index.html'));

  win.on('closed', () => {
    win = null;
  });
}

let ppapi_flash_path;

// Specify flash path.
// On Windows, it might be /path/to/pepflashplayer.dll
// On OS X, /path/to/PepperFlashPlayer.plugin
// On Linux, /path/to/libpepflashplayer.so
if(process.platform  == 'win32'){
  // Not on Windows atm, don't care
  ppapi_flash_path = path.join(__dirname, 'pepflashplayer.dll');
} else if (process.platform == 'linux') {
  // Not on Linux atm, don't care
  ppapi_flash_path = path.join(__dirname, 'libpepflashplayer.so');
} else if (process.platform == 'darwin') {
  ppapi_flash_path = path.join(__dirname, 'PepperFlashPlayer.plugin');
}
app.commandLine.appendSwitch('ppapi-flash-path', ppapi_flash_path);
app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169');

app.on('ready', createWindow);

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (win === null) {
    createWindow();
  }
});

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Pepper, Where are you!</title>
  </head>
  <body>
    <embed src="king-of-the-hill.swf">
    </embed>

    <webview src="http://www.adobe.com/software/flash/about/" style="display:inline-flex; width:800px; height:480px" plugins></webview>
  </body>
</html>

#2

You didn’t specify which version of Electron you’re using, but the option names for BrowserWindow were converted to camel case a while back, so try specifying webPreferences: { plugins: true } when creating the window.


#3

That was it, thanks!