Sliders
Time Slider
This component is used to create a range input for controlling the current time of playback.
📖 The <media-slider>
guide contains background documentation that can be used when working with the time slider component.
Usage
The <media-time-slider>
component receives time updates from the provider through the media store, and actively dispatches a media-seeking-request
event (throttled to once per 100ms
) as the slider value changes.
Seeking requests let the player know that the user is actively seeking but they haven't determined the final playback position they want to seek to. When the user stops dragging the slider, a media-seek-request
event will be fired to request updating the current playback time to the slider's value.
The time slider's range is represented as a percentage 0%
(min) and 100%
(max). Internally percentages are used to calculate time positions where 100%
is equal to the length of the media (i.e., duration).
Preview
The preview
slot enables passing in any element to be displayed above the slider thumb when being interacted with:
Grouping
Previews can be grouped by using a parent container element for the preview
slot:
Keyboard
The time slider will receive keyboard input when focused. The interaction keys are based on standard accessibility guidelines.
The key-step
and shift-key-multiplier
can be used to configure how much to seek backward/forward by on key press like so:
In the snippet above, each keyboard step (e.g., pressing left or right arrow key) will respectively seek backward/forward by 5 seconds. Holding shift
will multiply by the step by 2, so a change of 10 seconds.
👉 You can configure global seek keys on the player.
Styling
You can override the default styles with CSS like so:
Parts
Focus
Previews
Tailwind
A complete time slider example built with Tailwind:
- 📖 The
<media-slider>
Tailwind guide contains background documentation on working with sliders. - All of this code is reusable across other slider implementations. The time slider example only contains an additional
track-progress
div.