/flash-player-loader-for-electron

Makes life easier for the electron apps which need the pepper flash player.

Primary LanguageCoffeeScriptMIT LicenseMIT

Flash Player Loader (for electron apps)

Makes life easier for the electron apps which need the Pepper Flash Player.

The path to the Flash Player for your app usually differs between develop (git) version and release (packed) version.
This module manages multiple sources for you, and provides extra debug information and error handling.
Plus some handy features (OS X only) like automatically locate the Flash Player and get the version of it.

More details can be found at electron docs.

Installation

npm install --save flash-player-loader

To run the example app:

cd /path/to/flash-player-loader
npm install
electron test

To run the example app with extra debug output:

electron test -d

Usage

var flashLoader = require('flash-player-loader');
var path = '/path/to/dir/contains/flash/player';
flashLoader.addSource(path);
flashLoader.addSource('/alternative/path');
flashLoader.load();

Alternatively, you can chain the methods together.

require('flash-player-loader').addSource('/path/to/dir').load();

Do not forget to add the 'web-preferences': {'plugins': true} option when creating your BrowserWindow.

See test/index.js for more detailed example and explanations.

Get Pepper Flash Player Plug-in

  • Install Google Chrome.
    You can find the path to the Pepper Flash Player in the chrome://plugins tab.
  • Install the PPAPI system plug-in.
  • You can also download and install any older version of the plug-in from here.

Troubleshooting

The path added is correct, but it doesn't load the plug-in
  1. Please make sure that you are not mixing the architecture of electron and Flash Player.
    That is, 32-bit electron will not work with 64-bit Flash Player, and vice versa.
  2. Please make sure that you have included the option 'web-preferences': {'plugins': true} when creating BrowserWindow.

API

flashLoader.getFilename()

Returns the Flash Player filename according to the running OS.

flashLoader.addSource(location[, version])

  • location String
  • version String (optional)

Adds the location of Pepper Flash Player.

This method can be called multiple times. All added sources will be validated in the order they are added, until the first valid one is found.

The location is the path to the directory contains the Pepper Flash Player file, or the full path to the Pepper Flash Player file (The filename has to match the string returned by flashLoader.getFilename()).
If you have electron v1.2.3 or newer, you can also specify "@system" for location. It will then look for the Pepper Flash Player system plug-in (PPAPI).
If location is omitted, '.' will be used, i.e., the working directory, where you started your app.
On OS X, you can always specify "@chrome" or "@system" for location.
If "@chrome" is specified, it will automatically look for the Pepper Flash Player integrated by the newest installed Google Chrome.
"@system" works for all versions of electron.

You can optionally pass in a version string, which will be passed to Chromium with the ppapi-flash-version switch.
Note:

  1. Google Chrome uses this version number to decide which Flash Player to load, and for displaying. However, for (most) electron apps, it's useless. It's safe to ignore the version string.
  2. On OS X, the Flash Player version is automatically detected. The passed in string is ignored.

This method returns this, so it's possible to chain it.

flashLoader.load()

Validates the source(s) added by addSource(), in the order they are added. The first valid one will be loaded.

flashLoader.debug([options])

  • options Object
    • enable Boolean - Enable/Disable debug mode. Default is true.
    • log Function - Customised log function. Default is console.log.
    • error Function - Customised error function. Default is console.error.

Enable or disable debug mode.
When enabled, extra information and error messages will be print to the console.
You can also specify a customised log/error function, to make the output format match other output of your app, or log the information in other forms (e.g., write to a log file).
Note you may need to use bind to make you log function callable.
(See the example app for instance.)

This method returns this, so it's possible to chain it.

flashLoader.getVersion(location) OS X

  • location String

Returns the version of the Flash Player found at the specified location. An empty string is returned if the location is invalid.