jazz-soft / jazz-midi

MIDI support for Node.js and browsers
https://jazz-soft.net
17 stars 4 forks source link

how do I trigger this in modern firefox? #9

Open Pomax opened 2 years ago

Pomax commented 2 years ago

If I use the following code to detect midi support on https://pomax.github.io/mini-daw/:

async function connectMIDI() {
  if (!navigator.requestMIDIAccess) {
    // Warn the user that they won't have MIDI functionality. Then load anyway
    alert(
      `WebMIDI is not supported (without plugins?) in this browser.\nYou can still play around, just... no MIDI functionality, obviously.`
    );
  } else {
    try {
      const result = await navigator.requestMIDIAccess();
      return onMidiSuccess(result);
    } catch (e) {
      onMidiFail();
    }
  }
}

then the jazz midi plugin does not appear to kick in using current Firefox.

jazz-soft commented 2 years ago

jazz-midi requires JZZ.js https://github.com/jazz-soft/JZZ

Try to include JZZ.js on your page, then call if (!navigator.requestMIDIAccess) navigator.requestMIDIAccess = JZZ.requestMIDIAccess

Pomax commented 2 years ago

Cheers. The new Firefox "you get midi but only after you submit yourself to our addon process so that we know which pages you've put on the web" is a super disappointing development, so I'd much rather just go "don't bother with FF itself, use Jazz" =P

Pomax commented 2 years ago

Oh, is there an ES Module version of the library (with an export { JZZ } in it) so it can be loaded with the async attribute to not block the page, and imported the modern way without needing any old school "if not loaded setTimeout for 100ms and retry" shenanigans =)

jazz-soft commented 2 years ago

I'm afraid you have to do it manually. A CDN link would not take much loading time anyway. Or, you are welcome to play around with the index.d.ts, however it would need some updates.

Pomax commented 2 years ago

It does, but my entire codebase is ESM because IE11 is finally only a few weeks away from proper permanent death so ESM finally "just works(tm)" in everything (hurray!). Rather than playing around with index.d.ts, it might just be a matter of "use esbuild to build both versions".