djipco / webmidi

Tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.).
Apache License 2.0
1.52k stars 115 forks source link

webmidi on android/IOS ? #294

Closed ryodes closed 1 year ago

ryodes commented 1 year ago

Does webmidi work with android/IOS devices ?

I am experiencing some troubles using your API on mobile devices. It works perfectly fine for desktop users but on mobile it seems that WebMIDI can not be enabled.

Detail

WebMidi.enable((error) => { if (error) { console.warn("WebMidi could not be enabled."); return; } console.log("WebMidi enabled."); if (WebMidi.inputs.length === 0) { console.log("No MIDI inputs."); return; } const input = WebMidi.inputs[0]; input.addListener("noteon", "all", (event) => { this.handlePlayNoteInput(event.note.number); }); input.addListener("noteoff", "all", (event) => { this.handleStopNoteInput(event.note.number); }); });

here is my website with WebMidi: https://learn-chords.netlify.app/

Thank you.

djipco commented 1 year ago

Are you getting the "WebMidi could not be enabled." message when you execute your code? If so, which browser are you using and on which platform?

By the way, the Web MIDI API is not supported by Safari. On iOS, Chrome uses Safari's engine (as per Apple's requirements). This prevents support for the Web MIDI API on Chrome/iOS.

ryodes commented 1 year ago

I don't know what message I have on mobile, I can't open the element inspector, and for the browser, I'm using an android device with Chrome.

djipco commented 1 year ago

It should work on Chrome/Android. You can view error messages by using a remote debugging session. Once you know what error you are getting, it will be easier to help you.

ryodes commented 1 year ago

ok i will try it, thanks

djipco commented 1 year ago

Did you ever get this problem resolved?

ryodes commented 1 year ago

oops, sorry, I totally forgot to answer. yes i still have the problem on android. When I connect my android device to my piano, I get the message "No MIDI inputs"

image

but it works fine on pc

djipco commented 1 year ago

Can you see the device at the OS level? You can try this procedure to verify it: https://source.android.com/docs/core/audio/midi_test?hl=en

djipco commented 1 year ago

Did you resolve this issue?

ryodes commented 1 year ago

no, but I have the impression that it's my piano which is not familiar with android webpacks, you can close this issue, I plan to make an application on mobile to test, thanks :)