Media Element
Media Chrome will work with any element that exposes the same API as the
HTML media elements (<video>
and <audio>
). This means that you can replace
these elements with your own if they conform to the same API.
You can read more about the
HTMLMediaElement API on MDN.
Media Slot
Section titled Media SlotThe simplest media slot is the browser’s native <video>
tag. For example:
<media-controller>
<video slot="media" src="https://....mp4" >
</media-controller>
In this example, Media controller will:
- Listen for events emitted from the
<video>
element - Understand the current state of the
<video>
element by using the known props - Call methods on the
<video>
element likeplay()
,pause()
, etc.
Minimal media element
Section titled Minimal media elementThe slotted media element is not required to support the complete HTMLMediaElement
API.
Each Media Chrome component requires different API’s, for example to get the play
button working the media element requirements might be:
- Provide a
play()
andpause()
method - Fire
play
,playing
andpause
events - Provide a
paused
getter
Here’s an example of how such a custom media element could look like:
Custom media element
Section titled Custom media elementIf you’d like to add some extra behavior to the native <video>
or <audio>
element,
have a look at custom-media-element.
The HTMLVideoElement
API will be automatically added to any custom element that
extends from CustomVideoElement
.
hls-video-element is a good example making use of this library.
Compatible media elements
Section titled Compatible media elementsHere are some of the custom media elements that have been built that are compatible with Media Chrome.
-
<cloudflare-video>
Play videos hosted by Cloudflare -
<dash-video>
Play arbitrary DASH videos with Dash.js -
<hls-video>
Play arbitrary HLS videos with Hls.js -
<jwplayer-video>
Play videos that are hosted on JW Player -
<mux-video>
Play videos hosted by Mux -
<shaka-video>
Play videos with Shaka Player playback engine -
<spotify-audio>
Play audio hosted by Spotify -
<videojs-video>
Play videos with the Video.js playback engine -
<vimeo-video>
Play videos that are hosted on Vimeo -
<wistia-video>
Play videos that are hosted on Wistia -
<youtube-video>
Play videos that are hosted on YouTube