Skip to content

Commit

Permalink
Add implementation details for Electron
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Philippe Côté committed Sep 15, 2023
1 parent 163bd7c commit c8e2017
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions website/docs/going-further/electron.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
sidebar_position: 5
title: Electron
---

# Electron

WEBMIDI.js works fine inside [Electron](https://www.electronjs.org/) but you must make sure to
properly handle the permission request and permission check handlers from within the main process:

```javascript
mainWindow.webContents.session.setPermissionRequestHandler((webContents, permission, callback, details) => {
if (permission === 'midi' || permission === 'midiSysex') {
callback(true);
} else {
callback(false);
}
})

mainWindow.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin) => {
if (permission === 'midi' || permission === 'midiSysex') {
return true;
}
return false;
});
```

0 comments on commit c8e2017

Please sign in to comment.