<media-time-display>

The <media-time-display> component is used to show the current or remaining time of media playback, optionally showing the media duration as well. Clicking the component will toggle between showing the current vs. the remaining time.

<media-controller>
  <video
    slot="media"
    src="https://stream.mux.com/A3VXy02VoUinw01pwyomEO3bHnG4P32xzV7u1j1FSzjNg/low.mp4"
    playsinline
    muted
  >
  </video>
  <media-control-bar>
    <media-play-button></media-play-button>
    <media-time-display></media-time-display>
  </media-control-bar>
</media-controller>

Showing the duration can be configured with the showduration attribute.

Media Controller also sets the defaultduration to use before the media is loaded.

<media-controller defaultduration="134">
  <video
    slot="media"
    src="https://stream.mux.com/A3VXy02VoUinw01pwyomEO3bHnG4P32xzV7u1j1FSzjNg/low.mp4"
    playsinline
    muted
    preload="none"
  >
  </video>
  <media-control-bar>
    <media-play-button></media-play-button>
    <media-time-display showduration></media-time-display>
  </media-control-bar>
</media-controller>

Show the remaining time by default

Section titled Show the remaining time by default

Showing the remaining time by default can be configured with the remaining attribute.

<media-controller>
  <video
    slot="media"
    src="https://stream.mux.com/A3VXy02VoUinw01pwyomEO3bHnG4P32xzV7u1j1FSzjNg/low.mp4"
    playsinline
    muted
  >
  </video>
  <media-control-bar>
    <media-play-button></media-play-button>
    <media-time-display remaining></media-time-display>
  </media-control-bar>
</media-controller>
NameTypeDescription
disabledbooleanThe Boolean disabled attribute makes the element not mutable or focusable.
remainingbooleanToggle on to show the remaining time instead of elapsed time.
showdurationbooleanToggle on to show the duration.
notogglebooleanSet this to disable click or tap behavior that toggles between remaining and current time.
mediacontrollerstringThe element `id` of the media controller to connect to (if not nested within).

The media UI attributes will be set automatically by the controller if they are connected via nesting or the mediacontroller attribute. Only set these attributes manually if you know what you're doing.

NameTypeDescription
mediacurrenttimestring Set to the current media time.
mediadurationstring Set to the media duration.
mediaseekablestring Set to the seekable time ranges.
NameDefaultDescription
--media-time-display-displayinline-flexdisplay property of display.
--media-control-hover-backgroundbackground of control hover state.
--media-primary-colorrgb(238 238 238)Default color of text.
--media-secondary-colorrgb(20 20 30 / .7)Default color of background.
--media-text-colorvar(--media-primary-color, rgb(238 238 238))color of text.
--media-control-displaydisplay property of control.
--media-control-backgroundvar(--media-secondary-color, rgb(20 20 30 / .7))background of control.
--media-control-padding10pxpadding of control.
--media-control-height24pxline-height of control.
--media-fontvar(--media-font-weight, normal) var(--media-font-size, 14px) / var(--media-text-content-height, var(--media-control-height, 24px)) var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)font shorthand property.
--media-font-weightnormalfont-weight property.
--media-font-familyhelvetica neue, segoe ui, roboto, arial, sans-seriffont-family property.
--media-font-size14pxfont-size property.
--media-text-content-heightvar(--media-control-height, 24px)line-height of text.