MIDIConnectionEvent: thuộc tính port
Khả dụng hạn chế
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 in secure contexts (HTTPS), in some or all supporting browsers.
Thuộc tính chỉ đọc port của giao diện MIDIConnectionEvent trả về cổng đã bị ngắt kết nối hoặc được kết nối.
Giá trị
Một đối tượng MIDIPort.
Ví dụ
Phương thức Navigator.requestMIDIAccess() trả về một promise giải quyết với đối tượng MIDIAccess. Khi trạng thái cổng thay đổi, một MIDIConnectionEvent được truyền đến sự kiện statechange. Thông tin về cổng sau đó có thể được in ra console.
js
navigator.requestMIDIAccess().then((access) => {
access.onstatechange = (event) => {
console.log(event.port.name, event.port.manufacturer, event.port.state);
};
});
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Web MIDI API> # dom-midiconnectionevent-port> |