antoinercbs / tesla-synth-web-player

A web MIDI player specifically designed for the MMMZZZZ's Syntherrupter (Tesla Coil controller)
Mozilla Public License 2.0
4 stars 0 forks source link

WebMIDI not implemented in Firefox (TypeError: navigator.requestMIDIAccess is not a function) #1

Open MMMZZZZ opened 2 years ago

MMMZZZZ commented 2 years ago

Describe the bug When opening the web page I get the following popup message: TypeError: navigator.requestMIDIAccess is not a function

To Reproduce

  1. Followed the installation guide.
  2. Changed the following line because it otherwise failed to open the socket: app.run(debug=False, host='localhost')
  3. No Syntherrupter connected, just opened 127.0.0.1:5000 in firefox.

Expected behavior No error

Desktop (please complete the following information):

Additional context If I missed something please ask.

Kind regards, Max

antoinercbs commented 2 years ago

Hi max,

This error is technically a political issue. This app uses the WebMidi API, provided by the navigator, to access your midi outputs.

This error means that the code don't find the API in Firefox.

This API was introduced by the chromium teams and works well under google chrome, edge, opera and any other chromium based navigator. However, Safari and Firefox decided not to support it, raising security concerns.

I am afraid there is no fix but I will make a more explicit error display.

Best,

Antoine

MMMZZZZ commented 2 years ago

Thanks for the explanation. Does this mean that access to MIDI devices isn‘t possible for Firefox or Safari users? How about serial access?

Kind regards, Max

antoinercbs commented 2 years ago

Hi Max,

Yes it is not possible (see https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_API for more details) for the MIDI and it won't be unless Apple and Mozilla change their minds.

For the USB, the "political issue" is the same but from a technical point of view there are two solutions : WebUSB (https://developer.mozilla.org/en-US/docs/Web/API/USB, since 2017) or WebSerial (since 2021, https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API). WebUSB would require special code in the hardware but WebSerial should work out of the box. I used WebMidi because I use a USB/MIDI module and to have an "universal" app.

Best regards, Antoine

EDIT: Ow, it appears Mozilla are maybe changing their minds about WebMIDI, as the docs states that it is now an experimental feature (go to about:config and change the dom.webmidi.enabled propertie to true). On my side, it ask the permission to access the devices, however, I get another error so the API implementation may still be incomplete.

antoinercbs commented 2 years ago

Reopening the ticket following the ongoing changes (implementation of WebMIDI as an experimental feature) in Firefox