Replay: pause() method
Available since
@irtio/client 5.0BrowsersNodeThe pause() method of the Replay interface stops playback at the tick shown.
Syntax
pause()
Parameters
None.
Return value
None (undefined).
Exceptions
None.
Description
The replay keeps showing the tick it paused at, and play() carries on from there. pause() does nothing while the replay isn’t playing.
Examples
Pausing when the tab is hidden
A replay viewer pauses when the player switches tabs, and resumes when they come back if it was playing.
// hidden-pause.ts
import type { Replay } from "@irtio/client/replay";
export function pauseWhenHidden(replay: Replay): void {
let resume = false;
document.addEventListener("visibilitychange", () => {
if (document.hidden) {
resume = replay.playing;
replay.pause();
} else if (resume) {
replay.play();
}
});
}
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
pause() | 5.0 | 5.0 |