media-seek-button
A button component for seeking media playback forward or backward by a specified number of seconds
Anatomy
<SeekButton /><media-seek-button></media-seek-button>Behavior
Seeks media by a configurable number of seconds (default 30). Positive values seek forward, negative values seek backward. The seek is clamped to media bounds (0 to duration).
Accessibility
Renders a <button> with an automatic aria-label describing the action, e.g. “Seek forward 30 seconds” or “Seek backward 10 seconds”. Override with the label prop. Keyboard activation: Enter / Space.
Examples
Basic Usage
import { createPlayer, features, SeekButton } from '@videojs/react';
import { Video } from '@videojs/react/video';
import './BasicUsage.css';
const Player = createPlayer({ features: [...features.video] });
export default function BasicUsage() {
return (
<Player.Provider>
<Player.Container className="react-seek-button-basic">
<Video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoPlay
muted
playsInline
loop
/>
<div className="react-seek-button-basic__buttons">
<SeekButton
seconds={-5}
className="react-seek-button-basic__button"
render={(props, state) => (
<button {...props}>
{state.direction === 'backward' ? '\u23EA' : '\u23E9'} {5}s
</button>
)}
/>
<SeekButton
seconds={10}
className="react-seek-button-basic__button"
render={(props, state) => (
<button {...props}>
{10}s {state.direction === 'forward' ? '\u23E9' : '\u23EA'}
</button>
)}
/>
</div>
</Player.Container>
</Player.Provider>
);
}
.react-seek-button-basic {
position: relative;
}
.react-seek-button-basic video {
width: 100%;
}
.react-seek-button-basic__buttons {
display: flex;
gap: 8px;
position: absolute;
bottom: 10px;
left: 10px;
}
.react-seek-button-basic__button {
padding-block: 8px;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
color: black;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 9999px;
padding-inline: 20px;
white-space: nowrap;
cursor: pointer;
}
<video-player class="html-seek-button-basic">
<video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoplay
muted
playsinline
loop
></video>
<div class="html-seek-button-basic__buttons">
<media-seek-button seconds="-5" class="html-seek-button-basic__button">
<span class="show-when-backward">⏪ 5s</span>
</media-seek-button>
<media-seek-button seconds="10" class="html-seek-button-basic__button">
<span class="show-when-forward">10s ⏩</span>
</media-seek-button>
</div>
</video-player>
.html-seek-button-basic {
position: relative;
}
.html-seek-button-basic video {
width: 100%;
}
.html-seek-button-basic__buttons {
display: flex;
gap: 8px;
position: absolute;
bottom: 10px;
left: 10px;
}
.html-seek-button-basic__button {
padding-block: 8px;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
color: black;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 9999px;
padding-inline: 20px;
white-space: nowrap;
cursor: pointer;
}
.html-seek-button-basic__button .show-when-backward {
display: none;
}
.html-seek-button-basic__button .show-when-forward {
display: none;
}
.html-seek-button-basic__button[data-direction="backward"] .show-when-backward {
display: inline;
}
.html-seek-button-basic__button[data-direction="forward"] .show-when-forward {
display: inline;
}
import '@videojs/html/video/player';
import '@videojs/html/ui/seek-button';
API Reference
Props
| Prop | Type | Default | |
|---|---|---|---|
disabled | boolean | false | |
| |||
label | string | function | '' | |
| |||
seconds | number | 30 | |
| |||
State
State is accessible via the
render, className, and style props.
State is reflected as data attributes for CSS styling.
| Property | Type | |
|---|---|---|
seeking | boolean | |
| ||
direction | 'forward' | 'backward' | |
| ||
Data attributes
| Attribute | Description |
|---|---|
data-seeking | Present when a seek is in progress. |
data-direction | Indicates the seek direction: "forward" or "backward". |