# Playback

Play/pause state and actions for the player store

Controls play/pause state and tracks whether playback has started or is stalled.

## Import

```tsx
import { playbackFeature } from '@videojs/react';
```

The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://videojs.org/docs/framework/react/guides/presets) include this feature.

## API Reference

### State

| Property | Type | Description |
| --- | --- | --- |
| `paused` | `boolean` | Whether playback is paused. |
| `ended` | `boolean` | Whether playback has reached the end. |
| `started` | `boolean` | Whether playback has started (played or seeked). |
| `waiting` | `boolean` | Whether playback is stalled waiting for data. |

### Actions

| Action | Type | Description |
| --- | --- | --- |
| `play` | `() => Promise<void>` | Start playback. |
| `pause` | `() => void` | Pause playback. |
| `togglePaused` | `() => boolean` | Toggle play/pause. Returns `true` if playback started. |

### Selector

Pass `selectPlayback` to [`usePlayer`](https://videojs.org/docs/framework/react/reference/api/use-player) to subscribe to playback state. Returns `undefined` if the playback feature is not configured.

**PlayButton.tsx**

```tsx
import { selectPlayback, usePlayer } from '@videojs/react';

function PlayButton() {
  const playback = usePlayer(selectPlayback);
  if (!playback) return null;
  return <button onClick={playback.togglePaused}>{playback.paused ? 'Play' : 'Pause'}</button>;
}
```

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
