FrameworkStyle

SeekButton

A button component for seeking media playback forward or backward by a specified number of seconds

Anatomy

<SeekButton />

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>
  );
}

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.

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".
VideoJS