Skip to content
FrameworkStyle

media-error-dialog

An alert dialog that presents and dismisses playback errors

Import

import '@videojs/html/ui/error-dialog';

Anatomy

<media-error-dialog>
  <media-dialog-backdrop></media-dialog-backdrop>
  <media-dialog-popup>
    <media-dialog-title></media-dialog-title>
    <media-dialog-description></media-dialog-description>
    <media-dialog-close></media-dialog-close>
  </media-dialog-popup>
</media-error-dialog>

Behavior

ErrorDialog is a specialized root driven by the player’s error feature. It uses alert semantics and reuses the backdrop, popup, title, description, and close parts from Dialog; it is not nested inside AlertDialog. It opens when the attached media reports an error and stays hidden otherwise. Closing it dismisses the current error in the player store.

The title, description, and close label use localized default text. Provide children to any of those parts to replace its default content. Known media error codes use the matching translated message, while custom error messages are shown as written.

The included player skins already render an error dialog. Compose this component directly when building a custom skin.

Styling

Use data-open, data-starting-style, and data-ending-style to style visibility and transitions.

media-dialog-backdrop:not([data-open]),
media-dialog-popup:not([data-open]) {
  display: none;
}

media-dialog-backdrop[data-starting-style],
media-dialog-backdrop[data-ending-style],
media-dialog-popup[data-starting-style],
media-dialog-popup[data-ending-style] {
  opacity: 0;
}

Accessibility

The popup uses role="alertdialog". Its title and description are connected with aria-labelledby and aria-describedby.

Modality is scoped to the player container rather than the page. While the error is open, the rest of the container is inert and focus that lands elsewhere inside it returns to the popup, but content outside the player stays interactive and aria-modal is omitted. Only when the popup renders outside the container does the dialog fall back to document-wide modality: aria-modal="true", Tab cycling within the popup, and everything outside it inert.

Pressing Escape or activating the close part dismisses the error.

Examples

The example replaces the video source with invalid local data so the media element reports an error without making a failing network request.

Basic usage

<video-player class="html-error-dialog-basic">
  <media-container class="html-error-dialog-basic__container">
    <video
      class="html-error-dialog-basic__video"
      src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
      autoplay
      muted
      playsinline
      loop
    ></video>
    <button class="html-error-dialog-basic__trigger" type="button">Trigger a playback error</button>
    <media-error-dialog>
      <media-dialog-backdrop class="html-error-dialog-basic__backdrop"></media-dialog-backdrop>
      <media-dialog-popup class="html-error-dialog-basic__dialog">
        <media-dialog-title class="html-error-dialog-basic__title"></media-dialog-title>
        <media-dialog-description class="html-error-dialog-basic__description"></media-dialog-description>
        <media-dialog-close class="html-error-dialog-basic__close"></media-dialog-close>
      </media-dialog-popup>
    </media-error-dialog>
  </media-container>
</video-player>

API Reference

media-error-dialog

Opens from player error state and provides it to the shared dialog parts.

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
transitionStartingboolean
transitionEndingboolean
openboolean
status'idle' | 'starting' | 'ending'
titleIdstring | undefined
descriptionIdstring | undefined

media-dialog-backdrop

Presentational layer behind a dialog while it is rendered, including its exit transition.

Data attributes

AttributeTypeDetails
data-open
data-starting-style
data-ending-style

Renders the modal dialog while it is open.

AttributeTypeDetails
data-open
data-starting-style
data-ending-style