requestMidiAccess from Rust

I'm new to Rust and am looking for a short example on how to access navigator.requestMIDIAccess and handle onmessage events from Rust:

This is the code I run in Javascript:
navigator.requestMIDIAccess({ sysex: sysEx }).then( (result) => this._onMIDISuccess(result), this._onMIDIFailure );

Many thanks,

WASM doesn't have access to any browser functionality, so you have to do this by calling out to JS, like for all DOM functionality.

The response is a Promise, which adds some complication: https://rustwasm.github.io/docs/wasm-bindgen/reference/js-promises-and-rust-futures.html

Ok, I made some progress, and now compiled ok with:

navigator.request_midi_access();

I think I can make further progress now, but will need to read-up on how to convert the promise into a future and am curious to find out why I am not being prompted to allow MIDI access from the request_midi_access() call.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.