requestMIDIAccess not working on Android locally, getting DOMException

162 views Asked by At

I'm trying to access MIDI devices using the local Test.html page loaded on my smartphone(galaxy a40):

<!DOCTYPE html>
<html lang="ru">
<head><meta charset="utf-8" /><title>Test</title></head>
<body>
<script> 
navigator.requestMIDIAccess( { sysex: true } ).catch(console.error);
</script>
</body>
</html>

I get this console output: DOMException: An attempt was made to break through the security policy of the user agent. At the same time, https://virtualpiano.eu/ has no access problems. Chrome browsers 97,98,100 Please tell me how to fix

1

There are 1 answers

0
Liam Newmarch On

Chrome will only grant access to Web MIDI in secure contexts. See the MIDIAccess docs on MDN:

This feature is available only in secure contexts (HTTPS)

The reason the site you linked to works is because it uses HTTPS. Note: localhost is also treated as a secure context for development purposes, if you want to develop locally try running a web server.