v149 · HTML · Media
Capability Elements <usermedia>
Chrome 151 ships the <usermedia> HTML element — a declarative, browser-controlled button for requesting camera and microphone access. It replaces ad-hoc JavaScript permission flows with a semantic, secure, and user-friendly in-page element.
concepts
-
Element vs. JS API
Side-by-side comparison of the declarative
<usermedia>element against the imperativegetUserMedia()JavaScript call — same capability, two different paradigms, showing how the element handles constraints, events, and stream lifecycle. -
Stream Controller
A practical media capture UI using
<usermedia>— request camera or microphone access, see the live stream, toggle mute/unmute, and inspect thestreamreadyanduserchangedenabledevents as they fire. -
Constraints Builder
Visual form for configuring video (facing mode, resolution, frame rate) and audio (echo cancellation, noise suppression, sample rate) constraints. Generates the
<script type="permissionconstraints">block for<usermedia>and the equivalentgetUserMedia()call side by side. -
Camera Permission Flow
A video calling onboarding flow with two approach tabs:
<usermedia>element vs.getUserMedia(). Feature-detectsHTMLUserMediaElement, probes camera availability, tracks permission state transitions, and shows the mid-session track-ended recovery path. -
Event Sequence
Visualise the full event lifecycle of a
<usermedia>interaction: click, permission prompt, thenactivate(with stream) orerror(denied). Step through the granted and denied paths with animated timeline steps and a live event log. -
Constraint Presets
Seven ready-made constraint profiles — Video Call, Podcast, Selfie Cam, Screen Share, Voice Only, Low Latency, and an overconstrained 8K Cinema probe. Select a preset to see the
<script type="permissionconstraints">block, the equivalentgetUserMedia()call, and a table explaining why each constraint is set the way it is.
why it shipped
The navigator.mediaDevices.getUserMedia() API requires developers to build their own permission request UI, manage stream state manually, and reason carefully about user activation. A malicious or careless site can present misleading button text that tricks users into granting camera or microphone access without understanding what they're consenting to. The <usermedia> element changes this: the browser controls the button's label, icon, and appearance, so users always know exactly what clicking it will do. Constraints are declared inline using a <script type="permissionconstraints"> child element rather than composed in JavaScript, making the intent readable in markup. The element also exposes the stream and mute state as first-class properties, so toggling tracks is a single property assignment rather than iterating MediaStreamTrack objects.