Electron
中支持 Pepper Flash
插件的使用。想要在 Electron
里面使用 Pepper Flash
插件,咱们须要手动设置 Pepper Flash
的路径,而且在应用程序中启用 Pepper Flash
。html
在 macOS
和 Linux
上,咱们能够在 Chrome
浏览器的 chrome://plugins
页面上找到 Pepper Flash
的插件信息。插件的路径和版本会对 Election
对其的支持有帮助。你也能够把插件复制到另外一个路径以保留一份副本。linux
咱们能够直接在命令行中用 --ppapi-flash-path
和 ppapi-flash-version
或者在 app
的准备事件前调用 app.commandLine.appendSwitch
这个方法。同时添加 browser-window
的插件开关。例如:web
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`) // ... })
或者也能够尝试加载系统安装的 Pepper Flash
插件,而不是装运 插件,其路径能够经过调用 app.getPath('pepperFlashSystemPlugin')
获取。chrome
在 <webview>
标签里添加 plugins
属性。例以下面所示:api
<webview src="http://www.adobe.com/software/flash/about/" plugins></webview>
咱们能够经过在控制台打印 navigator.plugins
来检查 Pepper Flash
插件是否加载 。浏览器
Pepper Flash
插件的操做系统必须和 Electron
的操做系统匹配。在 Windows
中, 一个常见的错误是对 64
位版本的 Electron
使用 32bit
版本的 Flash
插件。app
在 Windows
中,传递给 --ppapi-flash-path
的路径必须使用 `` 做为路径分隔符,使用 POSIX-style 的路径将没法工做。electron
对于一些操做,例如使用 RTMP
的流媒体,有必要向播放器的 .swf
文件授予更多的权限。 实现这一点的一种方式是使用 nw-flash-trust
。ui
连接:https://www.9xkd.com/操作系统