关于electron:Electron-使用Pepper-Flash插件

4次阅读

共计 1501 个字符,预计需要花费 4 分钟才能阅读完成。

Electron 中反对 Pepper Flash 插件的应用。想要在 Electron 外面应用 Pepper Flash 插件,咱们须要手动设置 Pepper Flash 的门路,并且在应用程序中启用 Pepper Flash

保留一份 Flash 插件的正本

macOSLinux 上,咱们能够在 Chrome 浏览器的 chrome://plugins 页面上找到 Pepper Flash 的插件信息。插件的门路和版本会对 Election 对其的反对有帮忙。你也能够把插件复制到另一个门路以保留一份正本。

增加插件在 Electron 里的开关

咱们能够间接在命令行中用 --ppapi-flash-pathppapi-flash-version 或者在 app 的筹备事件前调用 app.commandLine.appendSwitch 这个办法。同时增加 browser-window 的插件开关。例如:

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') 获取。

应用 webview 标签启用插件

<webview> 标签里增加 plugins 属性。例如上面所示:

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

故障排查

咱们能够通过在控制台打印 navigator.plugins 来查看 Pepper Flash 插件是否加载。

Pepper Flash 插件的操作系统必须和 Electron 的操作系统匹配。在 Windows 中,一个常见的谬误是对 64 位版本的 Electron 应用 32bit 版本的 Flash 插件。

Windows 中,传递给 --ppapi-flash-path 的门路必须应用 “ 作为门路分隔符,应用 POSIX-style 的门路将无奈工作。

对于一些操作,例如应用 RTMP 的流媒体,有必要向播放器的 .swf 文件授予更多的权限。实现这一点的一种形式是应用 nw-flash-trust

链接:https://www.9xkd.com/

正文完
 0