Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MIDIConnectionEvent

MIDIConnectionEvent

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

TheMIDIConnectionEvent interface of theWeb MIDI API is the event passed to thestatechange event of theMIDIAccess interface and thestatechange event of theMIDIPort interface. This occurs any time a new port becomes available, or when a previously available port becomes unavailable. For example, this event is fired whenever a MIDI device is either plugged in to or unplugged from a computer.

Event MIDIConnectionEvent

Constructor

MIDIConnectionEvent()

Creates a newMIDIConnectionEvent object.

Instance properties

MIDIConnectionEvent.portRead only

Returns a reference to aMIDIPort instance for a port that has been connected or disconnected.

Examples

TheNavigator.requestMIDIAccess() method returns a promise that resolves with aMIDIAccess object. When a port changes state, aMIDIConnectionEvent is passed tostatechange event. Information about the port can then be printed to the console.

js
navigator.requestMIDIAccess().then((access) => {  access.onstatechange = (event) => {    console.log(event.port.name, event.port.manufacturer, event.port.state);  };});

Specifications

Specification
Web MIDI API
# midiconnectionevent-interface

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp