<media-live-button>

The <media-live-button> component shows, via a red dot by default, whether the stream is live. It also allows viewers to seek to the most current part of the stream when clicking on the button (“seek to live”).

The behavior of the button will update automatically based on the state of the media.

  • The indicator can be configured via the indicator slot.
  • The text can be configured via the text slot.
  • A spacer between the indicator and the text can be configured via the spacer slot.
<media-controller defaultsubtitles>
  <mux-video
    playsinline muted crossorigin
    slot="media"
    src="https://stream.mux.com/v69RSHhFelSm4701snP22dYz2jICy4E4FUyk02rW4gxRM.m3u8"
  >
  </mux-video>
  <media-control-bar>
    <media-play-button></media-play-button>
    <media-live-button></media-live-button>
  </media-control-bar>
</media-controller>

You can modify the contents of the <media-live-button> component using slots. This is useful if you’d like to use your own custom indicators and text instead of the default one provided by media-chrome.

Here’s an example of how you can replace the default indicator with a custom SVG and the text with the words “Live Button”

<media-controller defaultsubtitles>
  <mux-video
    playsinline muted crossorigin
    slot="media"
    src="https://stream.mux.com/v69RSHhFelSm4701snP22dYz2jICy4E4FUyk02rW4gxRM.m3u8"
  >
  </mux-video>
  <media-control-bar>
    <media-play-button></media-play-button>
    <media-live-button>
      <svg slot="indicator" width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="8"></circle></svg>
      <span slot="text">Live Button</span>
    </media-live-button>
  </media-control-bar>
</media-controller>

The <media-live-button> doesn’t expose any configuration attributes. However, it will be updated with Media UI Attributes any time the paused state or the live state of the media changes.

You can use these attributes to style the button. For example, if the media is live, set the color to green instead of red:

media-live-button[mediatimeislive] {
  --media-live-button-indicator-color: green;
}
Name Description
indicator The default is an SVG of a circle that changes to red when the video or audio is live. Can be replaced with your own SVG or font icon.
spacer A simple text space (&nbsp;) between the indicator and the text.
text The text content of the button, with a default of “LIVE”.
Name Type Description
disabled boolean The Boolean disabled attribute makes the element not mutable or focusable.
mediacontroller string The 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.

Name Type Description
mediapaused boolean Present if the media is paused.
mediatimeislive boolean Present if the media playback is live.
Name Default Description
--media-live-button-display inline-flex `display` property of button.
--media-live-button-icon-color rgb(140, 140, 140) `fill` and `color` of not live button icon.
--media-live-button-indicator-color rgb(255, 0, 0) `fill` and `color` of live button icon.
--media-primary-color rgb(238 238 238) Default color of text and icon.
--media-secondary-color rgb(20 20 30 / .7) Default color of button background.
--media-text-color var(--media-primary-color, rgb(238 238 238)) `color` of button text.
--media-icon-color var(--media-primary-color, rgb(238 238 238)) `fill` color of button icon.
--media-control-display `display` property of control.
--media-control-background var(--media-secondary-color, rgb(20 20 30 / .7)) `background` of control.
--media-control-hover-background rgba(50 50 70 / .7) `background` of control hover state.
--media-control-padding 10px `padding` of control.
--media-control-height 24px `line-height` of control.
--media-font var(--media-font-weight, bold) 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-weight bold `font-weight` property.
--media-font-family helvetica neue, segoe ui, roboto, arial, sans-serif `font-family` property.
--media-font-size 14px `font-size` property.
--media-text-content-height var(--media-control-height, 24px) `line-height` of button text.
--media-button-icon-width `width` of button icon.
--media-button-icon-height var(--media-control-height, 24px) `height` of button icon.
--media-button-icon-transform `transform` of button icon.
--media-button-icon-transition `transition` of button icon.