MIDIMessageEvent

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

MIDIMessageEvent interface of the Web MIDI API represents the event passed to the onmidimessage event handler of the MIDIInput interface. A midimessage event is fired every time a MIDI message is sent from a device represented by a MIDIInput , for example when a MIDI keyboard key is pressed, a knob is tweaked, or a slider is moved.

构造函数

MIDIMessageEvent.MIDIMessageEvent
创建新的 MIDIMessageEvent object instance.

特性

MIDIConnectionEvent.data
A Uint8Array containing the data bytes of a single MIDI message. See the MIDI specification for more information on its form.

注意 : Even though the Web MIDI API specifies a receivedTime property that returns a DOMHighResTimeStamp , Chrome (the only implementation at the time of writing) does not support that property since the basic Event.timeStamp property already returns a DOMHighResTimeStamp in Chrome.

范例

// Printing all messages to console
navigator.requestMIDIAccess().then(midiAccess => {
  Array.from(midiAccess.inputs).forEach(input => {
    input[1].onmidimessage = console.log;
  })
});
					

规范

规范 状态 Comment
Web MIDI API
The definition of 'MIDIMessageEvent' in that specification.
工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
MIDIMessageEvent
Chrome 43 Edge ≤79 Firefox ? IE No Opera 30 Safari ? WebView Android No Chrome Android 43 Firefox Android ? Opera Android 30 Safari iOS No Samsung Internet Android 4.0
MIDIMessageEvent() 构造函数
Chrome 43 Edge ≤79 Firefox ? IE No Opera 30 Safari ? WebView Android No Chrome Android 43 Firefox Android ? Opera Android 30 Safari iOS No Samsung Internet Android 4.0
data
Chrome 43 Edge ≤79 Firefox ? IE No Opera 30 Safari ? WebView Android No Chrome Android 43 Firefox Android ? Opera Android 30 Safari iOS No Samsung Internet Android 4.0

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。