Electron-vue: can not load flash plugin

Created on 4 Jul 2017  ·  4Comments  ·  Source: SimulatedGREG/electron-vue

which folder should I put in for "pepflashplayer.dll"?

question

Most helpful comment

@wenpengfei

You would want to place the plugin files in the static/ directory and access them using the __static variable. So something like path.join(__static, pluginName) should work.

Related: https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html#use-case-within-js-with-fspath-and-static

All 4 comments

I clone the https://github.com/hokein/electron-sample-apps and copy "pepflashplayer.dll" to the folder where "main.js" in, it works. The electron-sample-apps code like this:
````
const {app, BrowserWindow} = require('electron');
const path = require('path');

let mainWindow;

app.on('window-all-closed', function() {
if (process.platform != 'darwin')
app.quit();
});

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))

app.on('ready', function() {
mainWindow = new BrowserWindow({
'width': 800,
'height': 600,
'webPreferences': {'plugins': true}
});
mainWindow.loadURL('http://www.adobe.com/software/flash/about/');
});

````

And my electron-vue's main.js like this:
But it doesn't work
````
'use strict'

import { app, BrowserWindow } from 'electron'
const path = require('path')
// 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))
/**

let mainWindow
const winURL = process.env.NODE_ENV === 'development'
? http://localhost:9080
: file://${__dirname}/index.html

function createWindow () {
/**

  • Initial window options
    */
    mainWindow = new BrowserWindow({
    height: 600,
    useContentSize: true,
    width: 1000,
    webPreferences: { plugins: true}
    })

mainWindow.loadURL(winURL)
mainWindow.setMenu(null)

mainWindow.on('closed', () => {
mainWindow = null
})
}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
})

````

@wenpengfei

You would want to place the plugin files in the static/ directory and access them using the __static variable. So something like path.join(__static, pluginName) should work.

Related: https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html#use-case-within-js-with-fspath-and-static

It works! thanks~!

No problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simonwjackson picture simonwjackson  ·  3Comments

jt-wang picture jt-wang  ·  3Comments

alexiej picture alexiej  ·  3Comments

Oriol-GG picture Oriol-GG  ·  3Comments

haomehaode picture haomehaode  ·  3Comments