# media-seek-button

Accessible seek button for skipping forward or backward by a configurable number of seconds

## Import

```ts
import '@videojs/html/ui/seek-button';
```

## Anatomy

```html
<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

**index.html**

```html
<video-player class="video-player">
  <media-container>
    <video src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4" autoplay muted playsinline loop></video>
    <div class="buttons">
      <media-seek-button seconds="-5" class="media-seek-button">
        <span class="backward">&#9194; 5s</span>
      </media-seek-button>
      <media-seek-button seconds="10" class="media-seek-button">
        <span class="forward">10s &#9193;</span>
      </media-seek-button>
    </div>
  </media-container>
</video-player>
```

**index.css**

```css
.video-player media-container {
  position: relative;
}

.video-player media-container video {
  width: 100%;
}

.buttons {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
}

.media-seek-button {
  padding-block: 8px;
  padding-inline: 20px;
  color: black;
  white-space: nowrap;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 9999px;
  backdrop-filter: blur(10px);
}

.media-seek-button .backward {
  display: none;
}
.media-seek-button .forward {
  display: none;
}
.media-seek-button[data-direction="backward"] .backward {
  display: inline;
}
.media-seek-button[data-direction="forward"] .forward {
  display: inline;
}
```

**index.ts**

```ts
import '@videojs/html/video/player';
import '@videojs/html/ui/container';
import '@videojs/html/ui/seek-button';
```

## API Reference

### Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `disabled` | `boolean` | `false` | Whether the button is disabled. |
| `label` | `{ key: string; text: string } \| string \| ((state: SeekButtonState) => Text \| string)` | `''` | Custom label for the button. |
| `seconds` | `number` | `30` | Seconds to seek. Positive = forward, negative = backward. Default `30`. |

### State

State is reflected as data attributes for CSS styling.

| Property | Type | Description |
| --- | --- | --- |
| `label` | `{ key: string; text: string } \| string` | |
| `seeking` | `boolean` | Whether a seek is in progress. |
| `direction` | `'forward' \| 'backward'` | Whether the button seeks forward or backward. |

### Data attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `data-seeking` | — | Present when a seek is in progress. |
| `data-direction` | `'forward' \| 'backward'` | Indicates the seek direction: `"forward"` or `"backward"`. |