Why is navigator.requestMIDIAccess() working on websites but NOT on local files in Firefox?

114 views Asked by At

Trying to create an application for local use which receives messages from my MIDI keyboard. Whenever I call navigator.requestMIDIAccess() I get TypeError: navigator.requestMIDIAccess is not a function. But I can go to other websites which implement this API and don't get that error, the prompt comes up to select my keyboard as an input and the application receives MIDI events just fine. I am on Firefox and Ubuntu if that helps, accessing my application through file:/// . The developer console will even autocomplete navigator.requestMIDIAccess() if I'm on a website, but not when I'm viewing a local file. I thought it was simpler to use WebMIDI locally then online? What is going on?!

I've tried querying the permission policy status for MIDI with

    navigator.permissions.query({ name: "midi", sysex: true }).then((result) => {
        console.log(result.state);
    });

Console logs 'prompt', not 'denied'. I've also checked window.isSecureContext and it is 'true'. I don't know what else to check. I've read through the first 2 or 3 pages of duckduckgo results pertaining to this error but sadly they all seem to refer back to the days when Firefox didn't support this API at all, and so do not cover the issue I am having. Again I know my browser supports MIDI because when I browse to other's apps which use this API they work just fine, and the console recognizes navigator.requestMIDIAccess() when I am looking at any non-local site, but not when viewing my local application with a file:/// address. I would really like to know how to get WebMIDI working.

1

There are 1 answers

1
evilpie On

Firefox doesn't support the navigator.requestMIDIAccess API on file:// URLs (even though it's a secure context). This might change with Bug 1850446.