Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 1.06 KB

index.md

File metadata and controls

44 lines (28 loc) · 1.06 KB
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".

Syntax

close()

Parameters

None.

Return value

Returns a {{jsxref("Promise")}} which resolves once the port has been closed.

Examples

The following example shows an output port being closed.

let output = midiAccess.outputs.get(portID);
output.close(); // closes the port

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}