From be90e2e9fff44934bd39a30bba921d0b8a3b9b01 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 15 Jun 2016 09:41:47 +0900 Subject: [PATCH] Improve the docs on loading flash plugin --- docs/tutorial/using-pepper-flash-plugin.md | 35 +++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/docs/tutorial/using-pepper-flash-plugin.md b/docs/tutorial/using-pepper-flash-plugin.md index 9ff6ebf..747543f 100644 --- a/docs/tutorial/using-pepper-flash-plugin.md +++ b/docs/tutorial/using-pepper-flash-plugin.md @@ -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 `` 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. -- 2.7.4