'requestMIDIAccess not working on Android locally, getting DOMException

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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Liam Newmarch