mattdesl / canvas-sketch

[beta] A framework for making generative artwork in JavaScript and the browser.
MIT License
4.97k stars 393 forks source link

how to implement navigator.requestMIDIAccess(); #192

Closed alexalex25 closed 5 months ago

alexalex25 commented 11 months ago

Hey, i'd like to control some stuff in my sketch with midi. But wherever i try to navigator.requestMIDIAccess(), i get undefined...

Is it possible to use webMIDI in the sketches ?

Thx!

alexalex25 commented 11 months ago

Ok, I solved it after reading this :

It says :

"navigator.requestMIDIAccess() is only available in a secure context, which means your remote host must serve your resources via HTTPS.

Resources served from localhost are considered to be in a secure context, whether delivered via HTTPS or HTTP.

Connect to your remote host using HTTPS instead of HTTP and that should resolve the problem".

So what i did is write localhost:9966 instead of ip_adress:9966 that comes up by default in the url of the navigator. It works !

mattdesl commented 5 months ago

Yes I've run into something similar, bit of a pain when testing. I'll close since localhost should do the trick for the most part!