Electron supports Pepper Flash plug-ins. To use the Pepper Flash plug-in in Electron , we need to manually set the path of Pepper Flash Pepper Flash in the application.

Keep a copy of the Flash plugin

In macOS and Linux , we can Chrome browser chrome://plugins found on page Pepper Flash plug-in information. The path and version of the plug-in will Election support it. You can also copy the plug-in to another path to keep a copy.

Add plug-in switch in Electron

We can direct the command line with --ppapi-flash-path and ppapi-flash-version or app call preparation before the event app.commandLine.appendSwitch this method. At the same time, add the plug-in switch of browser-window E.g:

const { app, BrowserWindow } = require('electron')
const path = require('path')
// 指定flash路径,假定它与main.js放在同一目录中。
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))
// 可选:指定flash的版本,例如v17.0.0.169
app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169')
app.on('ready', () => {
  let win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      plugins: true
    }
  })
  win.loadURL(`file://${__dirname}/index.html`)
  // ...
})

Or you can also try to load the Pepper Flash plug-in installed by the system instead of shipping the plug-in. The path can be obtained by calling app.getPath('pepperFlashSystemPlugin') .

Use the webview tag to enable the plugin

Add the plugins attribute to the <webview> For example, as shown below:

<webview src="http://www.adobe.com/software/flash/about/" plugins></webview>

Troubleshooting

We can check Pepper Flash plugin is loaded navigator.plugins on the console.

The operating system of the Pepper Flash plug-in must match the operating system of Electron In Windows , a common error is to use the 32bit version of the Flash plug- 64 -bit version of Electron

In Windows , the path passed to --ppapi-flash-path must use `` as the path separator, and POSIX-style paths will not work.

For some operations, such as using RTMP streaming media, it is necessary to grant more permissions .swf One way to achieve this is to use nw-flash-trust .

Link: https://www.9xkd.com/


知否
221 声望177 粉丝

Skrike while the iron is hot.