Detect if a MIDI interface is connected in Web MIDI API

时间秒杀一切 提交于 2019-12-09 18:40:44

问题


I am experimenting with the Web Midi API in Chrome/OS X. So far I get good results but I am wondering:

Is there a way to detect if a MIDI interface is connected/disconnected WHILE an application is running?

The way it works for now is to restart the browser to let the application know that an interface is present or not ...

There seems to be a MIDIAccess onconnect / ondisconnect event but I don't know what to do to make them fire. Is this implemented yet in Chrome (Canary)?


回答1:


The current implementation in Chrome has two shortcomings - it requires the browser to be rebooted to detect device changes, and it doesn't yet support the connect/disconnect events. Both of those problems will be fixed, but right now, you can't do what you're trying to do. (AKA - you're understanding the spec correctly, but Chrome just doesn't do that yet. :)

UPDATE MAY 2015: Chrome 43 supports both of these properly, so as of version 43 you should be able to have these work as specified.



来源:https://stackoverflow.com/questions/19550437/detect-if-a-midi-interface-is-connected-in-web-midi-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!