0

I'm trying to make a simple synth web-app using the web audio API and I want to use it with my MIDI keyboard through the web MIDI API, so I tried these instructions both on Chrome and Chrome Canary but always I get the "navigator.getMIDIAccess is not a function" error, the version is 40 for Chrome and 42 for Chrome Canary, both on Mac OS X (10.10.2) and the experimental flag has been enabled. The code for now is very simple (this is a test):

<script type="text/javascript">
try{
    //navigator.getMIDIAccess = ( navigator.getMIDIAccess || navigator.webkitGetMIDIAccess || navigator.mozGetMIDIAccess || navigator.msGetMIDIAccess);
    navigator.getMIDIAccess(_event_success, function(){
        alert("ERROR");
    });
}catch(ex){
    console.log(ex);
    alert("NOT SUPPORTED");
}

function _event_success(){
    console.log("OK");
}
</script>

Where is the error? If may be helpful I'm using a M-AUDIO Keystation88 keyboard on USB. Is Chrome the only one that suport this feature?

RyanJ
  • 131
  • 5
  • 16

1 Answers1

2

The api call is "requestMIDIAccess". (It is not prefixed.)

cwilso
  • 13,610
  • 1
  • 30
  • 35
  • I've done a attempt using the prefixes with no success so after that I've commented the line. So the right form is "navigator. requestMIDIAccess(onSuccess, onError);"? – RyanJ Feb 21 '15 at 21:27
  • (Sorry for delay) - sort of - there is an options object that you can pass in to ask for system exclusive support. For your case, you can pass in an empty object (or null) - so navigator.requestMIDIAccess(null, onSuccess, onError). – cwilso Mar 02 '15 at 23:50
  • Thanks very much for help, I've done a simple example and it works fine, here the code if it may be helpful for some one else with this problem: https://gist.github.com/RyanJ93/8c0d78323ab13787ea51 – RyanJ Mar 06 '15 at 19:30