To use mpv.js in an Electron application, you must load the plugin in the main process and enable the plugins feature in the BrowserWindow web preferences.
Note on Pathing: Due to Chromium restrictions regarding non-ASCII characters in plugin paths, you should use getPluginEntry and potentially change the working directory for non-Linux platforms.
Note on Electron Flags: You must append the no-sandbox switch and use getPluginEntry to register the Pepper plugin.
const path = require("path");
const {app} = require("electron");
const {getPluginEntry} = require("mpv.js");
// Absolute path to the plugin directory.
const pluginDir = path.join(path.dirname(require.resolve("mpv.js")), "build", "Release");
// See pitfalls section for details.
if (process.platform !== "linux") {process.chdir(pluginDir);}
// Fix for latest Electron.
app.commandLine.appendSwitch("no-sandbox");
// To support a broader number of systems.
app.commandLine.appendSwitch("ignore-gpu-blacklist");
app.commandLine.appendSwitch("register-pepper-plugins", getPluginEntry(pluginDir));
// When creating your BrowserWindow, enable plugins:
// const win = new BrowserWindow({
// webPreferences: {plugins: true}
// });