# Playback

Play/pause state and actions for the player store

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

## Import

```ts
import { playbackFeature } from '@videojs/html';
```

The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](../../guides/presets.md) 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 [`PlayerController`](./player-controller.md) to subscribe to playback state. Returns `undefined` if the playback feature is not configured.

**play-button.ts**

```ts
import { createPlayer, UIElement, selectPlayback } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';

const { PlayerController } = createPlayer({ features: videoFeatures });

class PlayButton extends UIElement {
  readonly #playback = new PlayerController(this, selectPlayback);
}
```