Closed abudaan closed 9 years ago
Many thanks for that! I haven't tested it all, but it solved a big problem I've been facing recently -- writing client code that works both in Firefox with the Jazz plugin, and in Chrome with its Web-MIDI-API flag enabled. All I needed was to adapt the code in the comment above:
var iterator = MIDIAccess.inputs.values();
var data;
while((data = iterator.next()).done !== true){
port = data.value;
console.log('input id:', port.id, ' input name:', port.name);
}
Bravo, and thanks again.
In short:
MIDIAccess.inputs and MIDIAccess.outputs are still implemented as functions in Chromium. Therefor I have also added a wrapper for Chromium's WebMIDI implementation, see the init method.
According to the new draft it should be possible to loop over inputs and outputs like so:
But in Chrome's WebMIDI implementation this doesn't work yet. The functionality is implemented in the shim and works correctly but to make the examples work with both the Jazz plugin and native WebMIDI, I have used the iterator in the web examples to loop over inputs and outputs: