Skip to content

Commit

Permalink
Handle request and check permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
djipco authored Sep 14, 2023
1 parent 163bd7c commit 9757059
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/electron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,25 @@ A collection of examples to use WEBMIDI.js inside an Electron application.
## Examples

* [**Basic Electron Example**](basic-example)

## Platform specific notes

The permission requests must be properly handled in the main process before initializing WEBMIDI:

```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 9757059

Please sign in to comment.