Electron 使用Pepper Flash插件
source link: https://segmentfault.com/a/1190000040165476
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Electron 使用Pepper Flash插件
Electron
中支持 Pepper Flash
插件的使用。想要在 Electron
里面使用 Pepper Flash
插件,我们需要手动设置 Pepper Flash
的路径,并且在应用程序中启用 Pepper Flash
。
保留一份 Flash 插件的副本
在 macOS
和 Linux
上,我们可以在 Chrome
浏览器的 chrome://plugins
页面上找到 Pepper Flash
的插件信息。插件的路径和版本会对 Election
对其的支持有帮助。你也可以把插件复制到另一个路径以保留一份副本。
添加插件在 Electron 里的开关
我们可以直接在命令行中用 --ppapi-flash-path
和 ppapi-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
。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK