← audioPreferred capture in getDisplayMedia API

v152 · dictionary member · screen capture

DisplayMediaStreamOptions.audioSelection

Limited availability

  • Chrome · desktop 152
  • Edge · not separately reported
  • Firefox · no position recorded
  • Safari · no signal

Not on the Baseline register (webstatus.dev query, zero results 2026-07-28); no BCD entry yet — see compatibility.

A dictionary member of the options argument to navigator.mediaDevices.getDisplayMedia(). When set to "preferred" — the only value of its enum — it signals that the application would like the user agent to steer the user toward sharing audio along with the screen video. It is a hint: the user agent MAY ignore it, and it never overrides the user's choice in the picker.

syntax

enum AudioSelectionPreferenceEnum { "preferred" };

dictionary DisplayMediaStreamOptions {
  (boolean or MediaTrackConstraints) video = true;
  (boolean or MediaTrackConstraints) audio = false;
  // ... CaptureController, selfBrowserSurface, systemAudio,
  //     windowAudio, surfaceSwitching, monitorTypeSurfaces ...
  AudioSelectionPreferenceEnum audioSelection;  // no default
};

// Use:
navigator.mediaDevices.getDisplayMedia({
  video: true,
  audio: true,
  audioSelection: "preferred"
});

The IDL above quotes the Screen Capture Working Draft of 23 July 2026 verbatim for the enum and the member line. Chromium ships the identical member, gated [RuntimeEnabled=GetDisplayMediaAudioSelection] in media_stream_constraints.idl, with the flag stable at trunk (2026-07-28).

Specification text for the member, verbatim: “If present, signals whether the application would like the user agent to steer the user towards sharing audio along with the video. The user agent MAY ignore this hint.” The enum is described as “Describes whether an application invoking getDisplayMedia() would like the user agent to prefer capturing audio along with the video”, with its single value "preferred" meaning “The application prefers that the user agent prioritize capturing audio along with the video.”

Source: Screen Capture WD — audioSelection member; Screen Capture WD — AudioSelectionPreferenceEnum (merged via PR #332); Chromium IDL

value

Value contract
TypeAudioSelectionPreferenceEnum (a WebIDL enum, i.e. a DOMString restricted to the enumerated values)
Valid values"preferred" — the only enumerated value (2026-07-28). The enum is deliberately extensible: future values could express other preferences, but none exist today
DefaultNone — the member has no default in the dictionary. Absent means no preference expressed, which is distinct from any future “exclude”-style value
Case sensitivityExact match required ("preferred", lowercase) per WebIDL enum semantics
Companion requirementMeaningful only when audio capture is also requested (audio: true or an audio constraints object). With audio not requested, no audio control exists in the picker and the hint has no observable effect in Chrome
Source: Screen Capture WD — enum; companion requirement: explainer example and desktop_media_picker_views.cc (audio controls only exist when audio was requested)

observable effect

getDisplayMedia() still returns a Promise<MediaStream>; the member introduces no new return values, events, or readable state. Its effect is on the picker the browser shows before the promise settles (desktop Chrome, verified at trunk 2026-07-28):

If the user accepts with audio on, the resolved MediaStream contains an audio track (stream.getAudioTracks().length > 0); if they decline, it does not — the promise itself settles identically in both cases, so applications must check the track list rather than infer from the hint.

Source: desktop_media_picker_views.cc; CL 8116406 — Chrome UI/Browser changes; explainer — example

errors and edge behavior

Error and edge behavior
SituationBehavior
Any string other than "preferred" (e.g. "yes", "Preferred")TypeError from WebIDL enum conversion, rejecting the getDisplayMedia() call before any picker opens — the single-value enum makes every other string invalid
Non-string values (true, 1, {})Converted to a string first per WebIDL; the result is not "preferred", so the same TypeError applies (undefined and a missing member are exempt — they mean “absent”)
Browser without the featureNo error: unknown dictionary members are ignored per WebIDL, so the call proceeds with historical picker defaults. Degradation is silent and safe
audio absent or falseNo error; the hint has no observable effect because the picker offers no audio control (Chrome behavior, trunk)
UA declines to honor the hintExplicitly allowed (“The user agent MAY ignore this hint”) — not an error path; the app observes only the final track list
User dismisses the pickerStandard getDisplayMedia rejection (NotAllowedError), unchanged by this feature
Source: enum semantics per WebIDL — enumeration types applied to the single-value enum in the Screen Capture WD; dictionary semantics per WebIDL — dictionaries; Chrome edge behavior: desktop_media_picker_views.cc

context and requirements

Source: desktop_media_picker_views.cc (request-source gate); runtime_enabled_features.json5 (both flags); ChromeStatus API record (platform milestones); Screen Capture WD

lifecycle

  1. Parse — Blink converts the options dictionary; a present audioSelection is validated against the enum (invalid strings throw TypeError here, before anything is shown).
  2. Plumb — the preference travels as audio_selection_preferred from Blink through StreamControls to the browser process's MediaStreamRequest (the blink-side change is CL 8107082).
  3. Picker construction — the desktop picker reads the preference once, when the dialog is built: screen/window audio toggles start checked, the boxed toggle style is selected, and the confirm-button label tracker is armed.
  4. User decision — toggling audio updates the button label live; turning audio off under a "preferred" hint surfaces the recommendation banner. The user may still share without audio.
  5. Settlement — the promise resolves with whatever the user approved; the hint leaves no persistent state. Each getDisplayMedia() call re-evaluates a fresh options dictionary — the hint is per-call, not sticky, and there is nothing to reset or revoke afterward.
Source: CL 8107082 (plumbing); desktop_media_picker_views.cc (dialog construction and toggle handlers); Screen Capture WD (hint semantics)

examples

Complete pattern — request, hint, and verify the outcome rather than assuming it:

async function startCoWatch() {
  const stream = await navigator.mediaDevices.getDisplayMedia({
    video: true,
    audio: true,
    audioSelection: "preferred"
  });

  if (stream.getAudioTracks().length === 0) {
    // User declined audio despite the hint. The spec allows this;
    // fall back or stop, but do not retry-prompt in a loop.
    const proceed = confirm("No audio was shared. Continue video-only?");
    if (!proceed) {
      stream.getTracks().forEach(t => t.stop());
      return null;
    }
  }
  return stream;
}

Invalid values fail fast — useful to know when building the options object dynamically:

// TypeError: "yes" is not a valid AudioSelectionPreferenceEnum
await navigator.mediaDevices.getDisplayMedia({
  video: true, audio: true, audioSelection: "yes"
});
Live example from the Chrome Platform Showcase comparing the picker with and without the hint (route HEAD-checked 200, 2026-07-28).Source: chrome-platform-showcase
Source: pattern per the explainer example; enum failure per WebIDL enum conversion; demo: chrome-platform-showcase

browser compatibility

Interim table. No BCD entry exists for audioSelection (BCD api/MediaDevices.json has no audioSelection subfeature; there is no DisplayMediaStreamOptions.json at all — verified 2026-07-28). Compiled from primary sources:

audioSelection support (interim)
BrowserSupportEvidence
Chrome (desktop)152milestone=152 listing (Enabled by default); launch CL 8138688
Chrome (Android/WebView)Not recordedNo milestone on the ChromeStatus record
EdgeNot separately reportedChromium-based; no separate record
FirefoxNo position recorded — member ignoredChromeStatus record (no Mozilla view); WebIDL dictionary semantics
SafariNo signal — member ignoredWebKit standards-positions #696 (open, unlabelled 2026-07-28)

No upstream WPT coverage exists for the member: the wpt/screen-capture/ directory contains no audioSelection test (directory listing verified 2026-07-28).

Source: as linked per row; WPT: wpt/screen-capture directory

security and privacy

Source: explainer — privacy and security considerations; CL 8116406 (banner); Screen Capture WD