3

I have a MIDI device (launchpad) that I want to use with an Electron application. I was able to read events on the MIDI device using Microsoft Edge Chromium using Web MIDI API (https://github.com/djipco/webmidi). However, in order to start reading the MIDI device, permissions needed to be set, and displayed like so:

Permission

When I run npm start to start the electron project, I cannot find a way to enable permissions for MIDI devices. I cannot see any of my MIDI devices, and I am assuming that is because I am missing permissions.

I have researched the Electron documentation, and was not able to find anything. systemPreferences provides a way to request permissions, but for camera and microphone, not MIDI devices (https://electronjs.org/docs/api/system-preferences).

Thank you very much, and any help is appreciated :)

Francisco F.
  • 111
  • 1
  • 3
  • 14
  • Could you move to using https://github.com/justinlatimer/node-midi instead? I used this recently for an electron project and it works well on all platforms. It means not running the midi in BrowserWindow though. – Starfish_mod Feb 12 '20 at 02:13

1 Answers1

2

we can handle this using ses.setPermissionRequestHandler.

  • 1
    I put `mainWindow.webContents.session.setPermissionRequestHandler( function permissionRequestHandler(webContents, permission, callback) { return callback(true); } );` after `mainWindow.loadURL(url);` and I still did not get the permission request. I read the documentation, but I was not able to understand it very well, so I looked for other code online, and that was what I was able to get. Am I missing something? Am I doing anything wrong? – Francisco F. Jan 08 '20 at 06:21
  • From my understanding, that handles the permission once called, but does not actually call the permission – Francisco F. Jan 08 '20 at 06:22
  • 1
    In this handler we can get the permissions and based on the permissions you can handle it. If you need a deep knowledge you can refer opensource wavebox code. They are handling it. – Matcha Sesha Abhishek Jan 08 '20 at 08:08