Mux Player API Reference

View a comprehensive list of every attribute, slot, CSS part and variable, and event that can be used with Mux Player.

Attributes

AttributeTypeDescriptionDefault
autoplayboolean | "any" | "muted"For booleans, identical to the <video autoplay/> attribute. Additionally support "muted" to start autoplay with the media muted and "any" to try autoplaying "by any means necessary"false
crossoriginstring (enum)Identical to the <video crossorigin/> attribute, except default is "" (equivalent to "anonymous")""
loopbooleanIdentical to the <video loop/> attributefalse
mutedbooleanLike the <video muted/> attribute, only updates the muted property instead of the defaultMuted propertyfalse
posterstring (URL)Identical to the <video poster/> attribute. Will use the automatically generated poster based on your playback-id by default unless in audio mode. Explicitly set this attribute to show a poster in audio mode. Remove the poster by setting the value to an empty string.Derived
preloadstring (enum)Identical to the <video preload/> attribute (with an appropriate equivalent for HLS media content)Varies
volumenumber (0-1)Attribute equivalent of the volume propertyVaries
playbackratenumberAttribute equivalent of the playbackRate property1
env-keystringYour Mux Data environment key. Note that this is different than your API Key. Get your env key from the "Mux Data" part of your Mux Environments Dashboard. If unset, the environment will be inferred based on your Mux Video asset.N/A
debugbooleanEnables debug mode for the underlying playback engine (currently hls.js) and mux-embed, providing additional information in the console.false
no-volume-prefbooleanDisables storing the selected volume in localStorage.false
disable-trackingbooleanDisables Mux Data tracking. For more, check out the Mux Docsfalse
disable-cookiesbooleanDisables cookies used by Mux Data. For more, check out the Mux Docs.false
playback-idstringThe playback ID for your Mux Asset or Mux Live Stream. This will also be used for automatically assigning a poster image and thumbnail previews. For more, check out the Mux Docs.N/A
prefer-playback"mse" | "native"Specify if Mux Player should try to use Media Source Extension or native playback (if available). If no value is provided, Mux Player will choose based on what's deemed optimal for content and playback environment.Varies
max-resolution"720p" | "1080p" | "1440p" | "2160p"Specify the maximum resolution you want delivered for this video.N/A
min-resolution"480p" | "540p" | "720p" | "1080p" | "1440p" | "2160p"Specify the minimum resolution you want delivered for this video.N/A
rendition-order"desc"Change the order in which renditions are provided in the src playlist. Can impact initial segment loads. Currently only support "desc" for descending orderN/A
program-start-timenumberApply PDT-based instant clips to the beginning of the media stream.N/A
program-end-timenumberApply PDT-based instant clips to the end of the media stream.N/A
asset-start-timenumberApply media timeline-based instant clips to the beginning of the media stream.N/A
asset-end-timenumberApply media timeline-based instant clips to the end of the media stream.N/A
metadata-video-idstringThis is an arbitrary ID sent to Mux Data that should map back to a record of this video in your database.N/A
metadata-video-titlestringThis is an arbitrary title for your video that will be passed in as metadata into Mux Data. Adding a title will give you useful context in your Mux Data dashboard. (optional, but encouraged)N/A
metadata-viewer-user-idstringIf you have a logged-in user, this should be an anonymized ID value that maps back to the user in your database that will be sent to Mux Data. Take care to not expose personal identifiable information like names, usernames or email addresses. (optional, but encouraged)N/A
metadata-*stringThis metadata-* syntax can be used to pass any arbitrary Mux Data metadata fieldsN/A
beacon-collection-domainstring (domain name)Assigns a custom domain to be used for Mux Data collection.N/A
custom-domainstring (domain name)Assigns a custom domain to be used for Mux Video.N/A
stream-type"on-demand" | "live" | "ll-live" | "live:dvr" | "ll-live:dvr"The type of stream associated with your Mux Asset. Used to determine what UI/controls to show and what optimizations to make for playback."on-demand"
default-stream-type"on-demand" | "live"The default assumed stream-type before any playback-id has been loaded. Used along with target-live-window to determine what UI/controls to show by default.on-demand
target-live-windownumberAn offset representing the seekable range for live content, where Infinity means the entire live content is seekable (aka "standard DVR"). Used along with stream-type to determine what UI/controls to show.(inferred from playback-id and/or stream-type, otherwise NaN)
start-timenumber (seconds)Specify where in the media's timeline you want playback to start.0
default-hidden-captionsbooleanHide captions by default instead of showing them on initial load (when available)false
default-durationnumber (seconds)Applies a duration value before the media has loaded. Useful when used in conjunction with preload="none"N/A
primary-colorstring (Any valid CSS color style)The primary color used by the player's UIN/A
secondary-colorstring (Any valid CSS color style)The secondary color used by the player's UIN/A
accent-colorstring (Any valid CSS color style)The accent color used by the player's UIN/A
forward-seek-offsetnumber (seconds)Offset applied to the forward seek button and keyboard navigation10
backward-seek-offsetnumber (seconds)Offset applied to the backward seek button and keyboard navigation10
playback-tokenstringThe playback token for signing the src URL.N/A
thumbnail-tokenstringThe thumbnail token for signing the poster URL.N/A
storyboard-tokenstringThe storyboard token for signing the storyboard URL.N/A
drm-tokenstringThe token for signing DRM license and related URLs.N/A
storyboard-srcstring (URL) pointing to a .vtt fileFull URL string for the storyboard asset. Typically derived from the playbackId, setting this attribute will override the derived storyboard.undefined
thumbnail-timenumber (seconds)Time offset for the default poster image based on your playback-id. If no thumbnail-time is specified, start-time will be used by default. NOTE: This feature currently cannot be used with thumbnail-token.0
audiobooleanIndicate that you want an "audio only" UI/chrome. This may be used for audio-only assets or audio+video assets.false
nohotkeysbooleanToggles keyboard shortcut (hot keys) support when focus in inside the playerfalse
hotkeysDOMTokenList (space separated enum list)A blocklist of keyboard shortcuts (hotkeys) you want to disable. Based on Media Chrome's implementationN/A
playbackratesnumber[] (space separated list)A space separated string of playback rates used by the playback rate button.N/A
default-show-remaining-timebooleanShow remaining playback time (instead of current playback time) by defaultfalse
titlestringTitle text to show for your content in the Mux Player UI.""
placeholderstring (URI)Image to show as various assets load. Typically a data URI when usedN/A
cast-receiverstring (Receiver ID)The app ID to use for a custom Google cast receiver. If none is provided, the default receiver app will be used.N/A
no-tooltipsbooleanToggles disabling tooltips in the UIfalse
player-init-timenumber (timestamp)Overrides the default player initialization time, used by Mux Data for time-based quality-of-experience (QOE) metrics. It will be inferred from instantiation time by default.Varies
proudly-display-mux-badgebooleanDisplay the Mux badge in the player UI.false

Methods

MethodDescription
play()Identical to the native play() method.
pause()Identical to the native pause() method.
addCuePoints()Add an array of CuePoints with the shape { startTime: number; endTime?: number, value: any; } to the Mux Player instance
addChapters()Add an array of chapters with the shape { startTime: number; endTime?: number, value: string; } to the Mux Player instance
getStartDate()Will return a Date that matches the earliest PDT in your stream. Identical to native getStartDate() method, if exists.

Properties

PropTypeDescriptionDefault
paused Read onlybooleanIdentical to the native paused propertytrue
duration Read onlynumberIdentical to the native duration propertyNaN
ended Read onlybooleanIdentical to the native ended propertyfalse
buffered Read onlyTimeRangesIdentical to the native buffered property(empty TimeRanges instance)
seekable Read onlyTimeRangesIdentical to the native seekable property(empty TimeRanges instance)
readyState Read onlynumber (enum)Identical to the native readyState propertyNaN
videoWidth Read onlynumberIdentical to the native videoWidth property0
videoHeight Read onlynumberIdentical to the native videoHeight property0
currentTimenumberIdentical to the native currentTime property0
currentPdtDateWill return a Date that matches current PDT in your stream. Accounting for currentTime.0
volumenumberIdentical to the native volume property1
noVolumePrefbooleanDisables storing the selected volume in localStorage.false
posterstring (URL)Identical to the native poster property. Will use the automatically generated poster based on your playback-id by default. Remove the poster by setting the value to an empty string.Derived
storyboardstring (URL)URL for the Mux Storyboard. Will automatically generate the url based on your playback-id and token. Will not be set if the provided storyboardToken is invalid.Derived
playbackRatenumberIdentical to the native playbackRate property1
defaultPlaybackRatenumberIdentical to the native defaultPlaybackRate property1
crossOriginstringIdentical to the native crossOrigin property, except default is "" (equivalent to "anonymous")""
autoplayboolean | "any" | "muted"For booleans, identical to the native autoplay property. Additionally support "muted" to start autoplay with the media muted and "any" to try autoplaying "by any means necessary"false
loopbooleanIdentical to the native loop propertyfalse
mutedbooleanIdentical to the native muted propertyfalse
defaultMutedbooleanIdentical to the native defaultMuted propertyfalse
preloadstring (enum)Identical to the native preload property (with an appropriate equivalent for HLS media content)undefined
hasPlayed Read onlybooleanIndicates whether playback has begun for the current media asset associated with the playback-idfalse
inLiveWindow Read onlybooleanIndicates whether the playback time is currently near the live edge (only relevant for live/dvr content)false
audiobooleanIndicate that you want an "audio only" UI/chrome. This may be used for audio-only assets or audio+video assets.false
hotkeys Read only*DOMTokenListA DOMTokenList (similar to classList) blocklist of keyboard shortcuts (hotkeys) you want to disable. Based on Media Chrome's implementation''
nohotkeysbooleanToggles keyboard shortcut (hot keys) support when focus in inside the playerfalse
thumbnailTimenumber (seconds)Time offset for the default poster image based on your playback-id. If no thumbnail-time is specified, start-time will be used by default. NOTE: This feature currently cannot be used with thumbnail-token.0
titlestringTitle text to show for your content in the Mux Player UI.""
placeholderstring (URI)Image to show as various assets load. Typically a data URI when usedN/A
primaryColorstring (Any valid CSS color style)The primary color used by the player's UIundefined
secondaryColorstring (Any valid CSS color style)The secondary color used by the player's UIundefined
accentColorstring (Any valid CSS color style)The accent color used by the player's UIundefined
defaultShowRemainingTimebooleanShow remaining playback time (instead of current playback time) by defaultfalse
playbackRatesnumber[]Array of numbers used by the playback rate button.N/A
forwardSeekOffsetnumber (seconds)Offset applied to the forward seek button and keyboard navigation10
backwardSeekOffsetnumber (seconds)Offset applied to the backward seek button and keyboard navigation10
defaultHiddenCaptionsbooleanHide captions by default instead of showing them on initial load (when available)false
defaultDurationnumber (seconds)Applies a duration value before the media has loaded. Useful when used in conjunction with preload="none"N/A
beaconCollectionDomainstring (domain name)Assigns a custom domain to be used for Mux Data collection. NOTE: Must be set before playbackId to apply to Mux Data monitoring.undefined ("litix.io")
playbackIdstringThe playback ID for your Mux Asset or Mux Live Stream. This will also be used for automatically assigning a poster image and thumbnail previews. For more, check out the Mux Docs.undefined
customDomainstring (domain name)Assigns a custom domain to be used for Mux Video.undefined ("mux.com")
envKeystringYour Mux Data environment key. Note that this is different than your API Key. Get your env key from the "Mux Data" part of your Mux Environments Dashboard. If undefined, the environment will be inferred based on your Mux Video asset.undefined (inferred)
debugbooleanEnables debug mode for the underlying playback engine (currently hls.js) and mux-embed, providing additional information in the console. NOTE: Must be set before playbackId to fully apply to debug logging contexts.false
disableTrackingbooleanDisables Mux Data tracking. For more, check out the Mux Docsfalse
disableCookiesbooleanDisables cookies used by Mux Data. For more, check out the Mux Docs.false
streamType"on-demand" | "live" | "ll-live" | "live:dvr" | "ll-live:dvr"The type of stream associated with your Mux Asset. Used to determine what UI/controls to show and what optimizations to make for playback."on-demand"
defaultStreamType"on-demand" | "live"The default assumed stream-type before any playback-id has been loaded. Used along with target-live-window to determine what UI/controls to show by default.on-demand
targetLiveWindownumberAn offset representing the seekable range for live content, where Infinity means the entire live content is seekable (aka "standard DVR"). Used along with stream-type to determine what UI/controls to show.(inferred from playback-id and/or stream-type, otherwise NaN)
liveEdgeOffset Read onlynumberthe earliest playback time that will be treated as playing "at the live edge" for live content.(inferred from playback-id and/or stream-type, otherwise NaN)
startTimenumber (seconds)Specify where in the media's timeline you want playback to start.0
preferPlayback"mse" | "native"Specify if Mux Player should try to use Media Source Extension or native playback (if available). If no value is provided, Mux Player will choose based on what's deemed optimal for content and playback environment.Varies
proudlyDisplayMuxBadgebooleanDisplay the Mux badge in the player UI.false
maxResolution"720p" | "1080p" | "1440p" | "2160p"Specify the maximum resolution you want delivered for this video.N/A
minResolution"480p" | "540p" | "720p" | "1080p" | "1440p" | "2160p"Specify the minimum resolution you want delivered for this video.N/A
renditionOrder"desc"Change the order in which renditions are provided in the src playlist. Can impact initial segment loads. Currently only support "desc" for descending orderN/A
programStartTimenumberApply PDT-based instant clips to the beginning of the media stream.N/A
programEndTimenumberApply PDT-based instant clips to the end of the media stream.N/A
assetStartTimenumberApply media timeline-based instant clips to the beginning of the media stream.N/A
assetEndTimenumberApply media timeline-based instant clips to the end of the media stream.N/A
renditionOrder"desc"Change the order in which renditions are provided in the src playlist. Can impact initial segment loads. Currently only support "desc" for descending orderN/A
metadataobject*An object for configuring any metadata you'd like to send to Mux Data. If any metadata-* attributes are set, they will take precedence.undefined
playbackTokenstringThe playback token for signing the src URL.undefined
thumbnailTokenstringThe thumbnail token for signing the poster URL.undefined
storyboardTokenstringThe storyboard token for signing the storyboard URL.undefined
drmTokenstringThe token for signing DRM license and related URLs.undefined
storyboardSrcstring (URL)Full URL string for the storyboard asset. Setting this will override the storyboard URL derived from the playback ID.undefined
tokensobject*An object for setting all signed URL tokens with the signature { playback?: string; thumbnail?: string; storyboard?: string; drm?: string; }. If any *token properties or *-token attributes are set, they will take precedence.undefined
textTracksTextTrackListIdentical to the native textTracks property(empty TextTrackList instance)
cuePoints Read onlyArray<{ startTime: number; endTime?: number, value: any; }>The array of CuePoints for the current media, added via addCuePoints(cuePoints).[]
chapters Read onlyArray<{ startTime: number; endTime?: number, value: string; }>The array of Chapters for the current media, added via addChapters(chapters).[]
activeCuePoint Read only{ startTime: number; endTime?: number, value: any; }The current active CuePoint, determined based on the player's currentTime.undefined
activeChapter Read only{ startTime: number; endTime?: number, value: string; }The current active Chapter, determined based on the player's currentTime.undefined
castReceiverstring (Receiver ID)The app ID to use for a custom Google cast receiver. If none is provided, the default receiver app will be used.undefined
castCustomDataobject (JSON-serializable)Custom Data to send to your Google cast receiver on initial load. If none is provided, various Mux key/value pairs will be sent.Mux-specific object
playerInitTimenumber (timestamp)Overrides the default player initialization time, used by Mux Data for time-based quality-of-experience (QOE) metrics. It will be inferred from instantiation time by default.Varies

Events

<mux-player> has a number of events for media loading, playback, and the player itself. Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of <mux-player>.

EventDescription
abortIdentical to the native abort event
canplayIdentical to the native canplay event
canplaythroughIdentical to the native canplaythrough event
durationchangeIdentical to the native durationchange event
emptiedIdentical to the native emptied event
endedIdentical to the native ended event
errorIdentical to the native error event
loadeddataIdentical to the native loadeddata event
loadedmetadataIdentical to the native loadedmetadata event
loadstartIdentical to the native loadstart event
pauseIdentical to the native loadstart event
playIdentical to the native play event
playingIdentical to the native playing event
progressIdentical to the native progress event
ratechangeIdentical to the native ratechange event
resizeIdentical to the native resize event
seekedIdentical to the native seeked event
seekingIdentical to the native seeking event
stalledIdentical to the native stalled event
suspendIdentical to the native suspend event
timeupdateIdentical to the native timeupdate event
volumechangeIdentical to the native volumechange event
waitingIdentical to the native waiting event
cuepointchangeSimilar to the native TextTrack cuechange event, only the event's detail will be the activeCuePoint
chapterchangeSimilar to the native TextTrack cuechange event, only the event's detail will be the activeChapter

CSS Variables

This is the list of CSS variables for showing/hiding specific controls.

mux-player {
  /* Hide all controls at once */
  --controls: none;

  /* Target all sections by excluding the section prefix */
  --play-button: none;
  --live-button: none;
  --seek-backward-button: none;
  --seek-forward-button: none;
  --mute-button: none;
  --captions-button: none;
  --airplay-button: none;
  --pip-button: none;
  --fullscreen-button: none;
  --cast-button: none;
  --playback-rate-button: none;
  --volume-range: none;
  --time-range: none;
  --time-display: none;
  --title-display: none;
  --duration-display: none;
}

Each of the above can be paired with a prefix for top, center, bottom

mux-player {
  /* Target a specific section by prefixing the CSS var with (top|center|bottom) */
  --center-controls: none;
  --bottom-play-button: none;
}

Other CSS variables:

mux-player {
  /* The controls backdrop color */
  --controls-backdrop-color: rgb(0 0 0 / 0%);

  /*
   * Controls how the media is sized and positioned inside of the <video> element
   * Supports everything the standard CSS properties support
   */
  --media-object-size: cover;
  --media-object-position: center;
}

Turning this off completely has implications on the accessibility of the controls as they may not meet the contrast ratio requirements for WCAG 2.1 without it.

CSS Parts

Mux Player uses a shadow DOM to encapsulate its styles and behaviors. As a result, it's not possible to target its internals with the usual CSS selectors. Instead, some components expose parts that can be targeted with the CSS part selector, or ::part().

<style>
  mux-player::part(center play button) {
    display: none;
  }
</style>
<mux-player playback-id="DS00Spx1CV902MCtPj5WknGlR102V5HFkDe"></mux-player>

Supported parts: top, center, bottom, layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer, poster, live, play, button, seek-backward, seek-forward, mute, captions, airplay, pip, fullscreen, cast, playback-rate, volume, range, time, display, video

CSS parts allow you to style each part individually with a selector like ::part(center play button) or target multiple elements if the part is assigned to multiple elements internally, usage ::part(button). Every CSS property can be declared in the selector, this makes it a very powerful API.

Slots

Mux player can accept a slotted element as a poster image. The HTML would look similar to the following snippet:

<mux-player playback-id="VcmKA6aqzIzlg3MayLJDnbF55kX00mds028Z65QxvBYaA">
  <img slot="poster" src="https://image.mux.com/VcmKA6aqzIzlg3MayLJDnbF55kX00mds028Z65QxvBYaA/thumbnail.webp">
</mux-player>

The markup is more verbose but it comes with some benefits:

  • The poster image loads faster as it's picked up by the browser earlier.
  • Allows you to use responsive images with the img srcset attribute.

Was this page helpful?