# Replay: play() method

> The play() method of the Replay interface plays the replay from the tick shown until the last tick or pause().

The **`play()`** method of the [`Replay`](/docs/client/replay) interface plays the replay from the tick shown, a tick at a time at [`speed`](/docs/client/replay/speed) times the room's tick rate, until the last tick or [`pause()`](/docs/client/replay/pause).

## Syntax

```ts
play()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

None.

## Description

Each tick played is shown as [`step()`](/docs/client/replay/step) shows it: a [`message` event](/docs/client/replay/message-event) fires for each broadcast recorded in it, then the entity and presence callbacks, then the [`tick` event](/docs/client/replay/tick-event). At the last tick, playback stops and the [`ended` event](/docs/client/replay/ended-event) fires.

`play()` does nothing while the replay is playing or at its last tick. To play again from the start, [`seek()`](/docs/client/replay/seek) to [`firstTick`](/docs/client/replay/firsttick) first. A change to `speed` takes effect from the next tick.

## Examples

### Toggling playback with the space bar

A replay viewer plays and pauses with the space bar, and starts over once the replay has ended.

```ts
// space-to-play.ts
import type { Replay } from "@irtio/client/replay";

export function bindSpace(replay: Replay): void {
  addEventListener("keydown", (e) => {
    if (e.code !== "Space") return;
    e.preventDefault();
    if (replay.playing) return replay.pause();
    if (replay.tick === replay.lastTick) replay.seek(replay.firstTick);
    replay.play();
  });
}
```

## See also

- [`Replay.pause()`](/docs/client/replay/pause)
- [`Replay.speed`](/docs/client/replay/speed)
- [`Replay.step()`](/docs/client/replay/step)
