From f47263d1f919c67acde2dcd83e70f531a6c454fd Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Fri, 4 Mar 2022 23:39:22 +1100 Subject: [PATCH] Nav requestmidi updates (#13479) * Navigator.requestMIDIUpdates() - add security/permission info * WebMIDI API page - secure context and improve example --- .../web/api/navigator/requestmidiaccess/index.md | 11 ++++++----- files/en-us/web/api/web_midi_api/index.md | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/files/en-us/web/api/navigator/requestmidiaccess/index.md b/files/en-us/web/api/navigator/requestmidiaccess/index.md index 21a49914bcc3eb2..e0f83610d6e04b5 100644 --- a/files/en-us/web/api/navigator/requestmidiaccess/index.md +++ b/files/en-us/web/api/navigator/requestmidiaccess/index.md @@ -12,12 +12,13 @@ tags: browser-compat: api.Navigator.requestMIDIAccess --- -{{DefaultAPISidebar("Web MIDI API")}} +{{DefaultAPISidebar("Web MIDI API")}}{{SecureContext_Header}} -The **`requestMIDIAccess()`** method of the {{domxref('Navigator')}} interface -returns a {{jsxref('Promise')}} representing a request for access to MIDI devices on a user's system. This method is part of the [Web MIDI API](/en-US/docs/Web/API/Web_MIDI_API), which provides a means for accessing, enumerating, and manipulating MIDI devices. +The **`requestMIDIAccess()`** method of the {{domxref('Navigator')}} interface returns a {{jsxref('Promise')}} representing a request for access to MIDI devices on a user's system. +This method is part of the [Web MIDI API](/en-US/docs/Web/API/Web_MIDI_API), which provides a means for accessing, enumerating, and manipulating MIDI devices. -This method prompts the user for access to MIDI devices available to their system. If the user grants permission, then the {{jsxref('Promise')}} resolves and a [`MIDIAccess`](/en-US/docs/Web/API/MIDIAccess) object is returned. +This method may prompt the user for access to MIDI devices available to their system, or it may use a previously established preference to grant or deny access. +If permission is granted then the {{jsxref('Promise')}} resolves and a [`MIDIAccess`](/en-US/docs/Web/API/MIDIAccess) object is returned. ## Syntax @@ -48,7 +49,7 @@ A {{jsxref('Promise')}} that resolves with a [`MIDIAccess`](/en-US/docs/Web/API/ - `NotSupportedError` - : If the feature or options are not supported by the system. - `SecurityError` - - : If the user or system denies the application from creating a [MIDIAccess](/en-US/docs/Web/API/MIDIAccess) object with the requested options, or if the document is not allowed to use the feature (for example, an iframe without the correct [feature policy](/en-US/docs/Web/HTTP/Feature_Policy)). + - : If the user or system denies the application from creating a [MIDIAccess](/en-US/docs/Web/API/MIDIAccess) object with the requested options, or if the document is not allowed to use the feature (for example, an iframe without the correct [Permission Policy](/en-US/docs/Web/HTTP/Feature_Policy), or when the user has previously denied a permissions access to the feature). ## Examples diff --git a/files/en-us/web/api/web_midi_api/index.md b/files/en-us/web/api/web_midi_api/index.md index ca92aea947c28b1..2c8d7ec49605f6d 100644 --- a/files/en-us/web/api/web_midi_api/index.md +++ b/files/en-us/web/api/web_midi_api/index.md @@ -8,7 +8,7 @@ tags: - Reference - Web MIDI API --- -{{DefaultAPISidebar("Web MIDI API")}} +{{DefaultAPISidebar("Web MIDI API")}}{{SecureContext_Header}} The Web MIDI API connects to and interacts with with Musical Instrument Digital Interface (MIDI) Devices. @@ -37,7 +37,8 @@ The interfaces deal with the practical aspects of sending and receiving MIDI mes ### Gaining access to the MIDI port -In the following example the {{domxref("MIDIAccess")}} interface is used to gain access to a MIDI device. +The {{domxref("navigator.requestMIDIAccess()")}} method returns a promise that resolves to a {{domxref("MIDIAccess")}}, which can then be used to access a MIDI device. +The method must be called in a secure context. ```js var midi = null; // global MIDIAccess object