Improve the docs on loading flash plugin

This commit is contained in:
Cheng Zhao 2016-06-15 09:41:47 +09:00
parent 9223019af8
commit be90e2e9ff

View file

@ -13,20 +13,30 @@ location.
## Add Electron Switch
You can directly add `--ppapi-flash-path` and `ppapi-flash-version` to the
You can directly add `--ppapi-flash-path` and `--ppapi-flash-version` to the
Electron command line or by using the `app.commandLine.appendSwitch` method
before the app ready event. Also, turn on `plugins` option of `BrowserWindow`.
For example:
```javascript
// Specify flash path.
// On Windows, it might be /path/to/pepflashplayer.dll or just pepflashplayer.dll if it resides main.js
// On OS X, /path/to/PepperFlashPlayer.plugin
// On Linux, /path/to/libpepflashplayer.so
app.commandLine.appendSwitch('ppapi-flash-path', '/path/to/libpepflashplayer.so');
// Specify flash path, supposing it is placed in the same directory with 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))
// Optional: Specify flash version, for example, v17.0.0.169
app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169');
app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169')
app.on('ready', () => {
win = new BrowserWindow({
@ -35,13 +45,15 @@ app.on('ready', () => {
webPreferences: {
plugins: true
}
});
win.loadURL(`file://${__dirname}/index.html`);
})
win.loadURL(`file://${__dirname}/index.html`)
// Something else
});
```
The path to the system wide Pepper Flash plugin can also be obtained by calling `app.getPath('pepperFlashSystemPlugin')`.
You can also try loading the system wide Pepper Flash plugin instead of shipping
the plugins yourself, its path can be received by calling
`app.getPath('pepperFlashSystemPlugin')`.
## Enable Flash Plugin in a `<webview>` Tag
@ -60,3 +72,6 @@ plugin's path is correct).
The architecture of Pepper Flash plugin has to match Electron's one. On Windows,
a common error is to use 32bit version of Flash plugin against 64bit version of
Electron.
On Windows the path passed to `--ppapi-flash-path` has to use `\` as path
delimiter, using POSIX-style paths will not work.