Skip to content

openrv-web / PlaybackAPI

Class: PlaybackAPI ​

Defined in: api/PlaybackAPI.ts:13

Extends ​

  • DisposableAPI

Constructors ​

Constructor ​

new PlaybackAPI(session): PlaybackAPI

Defined in: api/PlaybackAPI.ts:17

Parameters ​

session ​

Session

Returns ​

PlaybackAPI

Overrides ​

DisposableAPI.constructor

Methods ​

dispose() ​

dispose(): void

Defined in: api/Disposable.ts:19

Mark this sub-API as disposed. After this call, assertNotDisposed() will throw on every subsequent invocation.

Returns ​

void

Inherited from ​

DisposableAPI.dispose


getClipDuration() ​

getClipDuration(): number

Defined in: api/PlaybackAPI.ts:343

Get the clip-local total frame count, regardless of playlist mode.

Always returns the current source's duration. Useful when consumers need the clip duration even during playlist playback.

Returns ​

number

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

Example ​

ts
const clipTotal = openrv.playback.getClipDuration();

getClipFrame() ​

getClipFrame(): number

Defined in: api/PlaybackAPI.ts:325

Get the clip-local frame number, regardless of playlist mode.

Always returns the session's current frame (the frame within the currently loaded clip/source). Useful when consumers need the clip-local position even during playlist playback.

Returns ​

number

The clip-local frame number (1-based).

Example ​

ts
const clipFrame = openrv.playback.getClipFrame();

getCurrentFrame() ​

getCurrentFrame(): number

Defined in: api/PlaybackAPI.ts:265

Get current frame number (1-based).

When a playlist is active, returns the global playlist frame. When no playlist is active, returns the clip-local frame.

Returns ​

number

The current frame number, starting from 1.

Example ​

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

getDroppedFrameCount() ​

getDroppedFrameCount(): number

Defined in: api/PlaybackAPI.ts:433

Get the cumulative count of dropped (skipped) frames since playback started.

In realtime mode the engine may skip frames to maintain the target FPS. This counter reflects the total number of such skips.

Returns ​

number

The number of dropped frames.

Example ​

ts
const dropped = openrv.playback.getDroppedFrameCount(); // e.g. 12

getMeasuredFPS() ​

getMeasuredFPS(): number

Defined in: api/PlaybackAPI.ts:397

Get the measured (actual) playback FPS.

During active playback, this returns the real throughput measured by the playback engine (rolling average updated every ~500 ms). When playback is stopped, returns 0.

Returns ​

number

The measured FPS as a number (0 when not playing).

Example ​

ts
const real = openrv.playback.getMeasuredFPS(); // e.g. 23.4

getPlaybackMode() ​

getPlaybackMode(): PlaybackMode

Defined in: api/PlaybackAPI.ts:378

Get the current playback mode.

Returns ​

PlaybackMode

'realtime' or 'playAllFrames'.

Example ​

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

getPlayDirection() ​

getPlayDirection(): number

Defined in: api/PlaybackAPI.ts:232

Get the current playback direction.

Returns ​

number

1 for forward, -1 for reverse.

Example ​

ts
const dir = openrv.playback.getPlayDirection(); // 1 or -1

getSpeed() ​

getSpeed(): number

Defined in: api/PlaybackAPI.ts:197

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:286

Get total number of frames.

When a playlist is active, returns the total playlist duration. When no playlist is active, returns the current source duration.

Returns ​

number

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

Example ​

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

isBuffering() ​

isBuffering(): boolean

Defined in: api/PlaybackAPI.ts:415

Check whether the playback engine is currently buffering.

Returns true when the engine is waiting for frames (e.g. play-all-frames starvation or HDR initial buffering delay).

Returns ​

boolean

true if buffering, false otherwise.

Example ​

ts
if (openrv.playback.isBuffering()) { showSpinner(); }

isPlaying() ​

isPlaying(): boolean

Defined in: api/PlaybackAPI.ts:247

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(); }

isPlaylistActive() ​

isPlaylistActive(): boolean

Defined in: api/PlaybackAPI.ts:306

Check whether playlist mode is currently active.

Returns ​

boolean

true if a playlist is loaded and enabled, false otherwise.

Example ​

ts
if (openrv.playback.isPlaylistActive()) {
  console.log('Global frame:', openrv.playback.getCurrentFrame());
}

pause() ​

pause(): void

Defined in: api/PlaybackAPI.ts:51

Pause playback at the current frame.

Returns ​

void

Example ​

ts
openrv.playback.pause();

play() ​

play(): void

Defined in: api/PlaybackAPI.ts:38

Start playback from the current frame position.

Returns ​

void

Example ​

ts
openrv.playback.play();

seek() ​

seek(frame): void

Defined in: api/PlaybackAPI.ts:93

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:360

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');

setPlayDirection() ​

setPlayDirection(direction): void

Defined in: api/PlaybackAPI.ts:214

Set the playback direction.

Parameters ​

direction ​

number

Positive values (including 0) set forward playback, negative values set reverse playback. The value is normalized to +1 or -1.

Returns ​

void

Example ​

ts
openrv.playback.setPlayDirection(-1); // reverse
openrv.playback.setPlayDirection(1);  // forward

setSpeed() ​

setSpeed(speed): void

Defined in: api/PlaybackAPI.ts:177

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:115

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:77

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

Returns ​

void

Example ​

ts
openrv.playback.stop();

toggle() ​

toggle(): void

Defined in: api/PlaybackAPI.ts:64

Toggle between play and pause states.

Returns ​

void

Example ​

ts
openrv.playback.toggle();

Released under the MIT License.