Skip to content

openrv-web / PlaybackAPI

Class: PlaybackAPI

Defined in: api/PlaybackAPI.ts:11

Constructors

Constructor

new PlaybackAPI(session): PlaybackAPI

Defined in: api/PlaybackAPI.ts:14

Parameters

session

Session

Returns

PlaybackAPI

Methods

getCurrentFrame()

getCurrentFrame(): number

Defined in: api/PlaybackAPI.ts:189

Get current frame number (1-based).

Returns

number

The current frame number, starting from 1.

Example

ts
const frame = openrv.playback.getCurrentFrame();

getPlaybackMode()

getPlaybackMode(): PlaybackMode

Defined in: api/PlaybackAPI.ts:236

Get the current playback mode.

Returns

PlaybackMode

'realtime' or 'playAllFrames'.

Example

ts
const mode = openrv.playback.getPlaybackMode(); // e.g. 'realtime'

getSpeed()

getSpeed(): number

Defined in: api/PlaybackAPI.ts:161

Get current playback speed multiplier.

Returns

number

The current speed multiplier (between 0.1 and 8.0).

Example

ts
const speed = openrv.playback.getSpeed(); // e.g. 1.0

getTotalFrames()

getTotalFrames(): number

Defined in: api/PlaybackAPI.ts:203

Get total number of frames in the current source.

Returns

number

The total frame count, or 0 if no source is loaded.

Example

ts
const total = openrv.playback.getTotalFrames();

isPlaying()

isPlaying(): boolean

Defined in: api/PlaybackAPI.ts:175

Check if playback is currently active.

Returns

boolean

true if playing, false if paused or stopped.

Example

ts
if (openrv.playback.isPlaying()) { openrv.playback.pause(); }

pause()

pause(): void

Defined in: api/PlaybackAPI.ts:38

Pause playback at the current frame.

Returns

void

Example

ts
openrv.playback.pause();

play()

play(): void

Defined in: api/PlaybackAPI.ts:26

Start playback from the current frame position.

Returns

void

Example

ts
openrv.playback.play();

seek()

seek(frame): void

Defined in: api/PlaybackAPI.ts:78

Seek to a specific frame number.

Parameters

frame

number

Frame number (1-based, clamped to valid range by the session).

Returns

void

Throws

If frame is not a valid number or is NaN.

Example

ts
openrv.playback.seek(100);

setPlaybackMode()

setPlaybackMode(mode): void

Defined in: api/PlaybackAPI.ts:219

Set the playback mode.

Parameters

mode

PlaybackMode

Either 'realtime' (frames may be skipped to maintain target FPS) or 'playAllFrames' (every frame is displayed, effective FPS may drop).

Returns

void

Throws

If mode is not a valid playback mode.

Example

ts
openrv.playback.setPlaybackMode('playAllFrames');

setSpeed()

setSpeed(speed): void

Defined in: api/PlaybackAPI.ts:142

Set playback speed multiplier.

Parameters

speed

number

Speed multiplier, clamped to the range 0.1 (slow) to 8.0 (fast). A value of 1.0 is normal speed.

Returns

void

Throws

If speed is not a valid number or is NaN.

Example

ts
openrv.playback.setSpeed(2.0); // 2x speed

step()

step(direction?): void

Defined in: api/PlaybackAPI.ts:99

Step forward or backward by the given number of frames.

Parameters

direction?

number = 1

Positive for forward, negative for backward (default: 1). Zero is a no-op. The magnitude determines how many frames to step. The value is rounded to the nearest integer.

Returns

void

Throws

If direction is not a valid number or is NaN.

Example

ts
openrv.playback.step();    // step forward 1 frame
openrv.playback.step(-5);  // step backward 5 frames

stop()

stop(): void

Defined in: api/PlaybackAPI.ts:62

Stop playback and seek to the start (in point).

Returns

void

Example

ts
openrv.playback.stop();

toggle()

toggle(): void

Defined in: api/PlaybackAPI.ts:50

Toggle between play and pause states.

Returns

void

Example

ts
openrv.playback.toggle();

Released under the MIT License.