Replay: ended event

Available since @irtio/client 5.0BrowsersNode

The ended event of the Replay interface fires when playback reaches lastTick, by play() or step().

Syntax

addEventListener("ended", (event) => {})

Event type

A generic Event.

Description

Playback has stopped by the time the event fires, after the last tick’s tick event. A seek() to the last tick doesn’t fire it.

Examples

Showing a replay button at the end

When a clip ends, the viewer offers to watch it again.

// watch-again.ts
import type { Replay } from "@irtio/client/replay";

export function offerRewatch(replay: Replay, button: HTMLButtonElement): void {
  button.hidden = true;
  button.addEventListener("click", () => {
    button.hidden = true;
    replay.seek(replay.firstTick);
    replay.play();
  });
  replay.addEventListener("ended", () => (button.hidden = false));
}

See also

Runtime availability

BrowsersNode
ended event5.05.0