title | short-title | slug | page-type | browser-compat |
---|---|---|---|---|
MIDIPort: close() method |
close() |
Web/API/MIDIPort/close |
web-api-instance-method |
api.MIDIPort.close |
{{securecontext_header}}{{DefaultAPISidebar("Web MIDI API")}}
The close()
method of the {{domxref("MIDIPort")}} interface makes the access to the MIDI device connected to this MIDIPort
unavailable.
If the port is successfully closed a new {{domxref("MIDIConnectionEvent")}} is queued to the {{domxref("MIDIPort.statechange_event", "MIDIPort statechange")}} and {{domxref("MIDIAccess.statechange_event", "MIDIAccess statechange")}} events, and the {{domxref("MIDIPort.connection")}} property is changed to "closed"
.
close()
None.
Returns a {{jsxref("Promise")}} which resolves once the port has been closed.
The following example shows an output port being closed.
let output = midiAccess.outputs.get(portID);
output.close(); // closes the port
{{Specifications}}
{{Compat}}