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:
Chapters
Chapters are set by providing a WebVTT file that specifies the time ranges and respective chapter titles. It should look something like this:
The time slider supports showing the current chapters text track that has a mode
of showing:
Title
The chapter-title
part attribute can be added to any element inside the time slider. When found, the current chapter title that is active or being previewed will be inserted inside of it:
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
Chapters
CSS Variables
See the slider CSS variables for simple customization of the default slider styles.
Tailwind
A complete time slider example built with Tailwind:
Component API
Props
Name | Type |
---|---|
|
string
|
|
string
|
|
string
|
|
boolean
|
|
number
|
|
string
|
|
string
|
|
string
|
|
string
|
|
string
|
|
number
|
|
number
|
|
boolean
|
|
number
|
|
number
|
|
number
|
|
number
|
Events
Name | Type |
---|---|
|
SliderDragStartEvent
|
|
SliderDragEndEvent
|
|
SliderValueChangeEvent
|
|
SliderDragValueChangeEvent
|
|
SliderPointerValueChangeEvent
|
Name | Description |
---|---|
|
Used to insert a slider preview. |
CSS VarsLearn more about cssVars
Name | Type |
---|---|
|
readonly
string
|
|
string | number
|
|
string | number
|
|
string | number
|
|
string | number
|
|
string | number
|
|
readonly
string
|
|
readonly
string
|
CSS PartsLearn more about cssParts
Name | Description |
---|
Instance Props
Name | Type |
---|---|
|
readonly
SliderState
|
Instance Methods
Name | Type |
---|---|
|
(callback: (state: SliderState) => Maybe<Dispose>) => Unsubscribe
|