Skip to main content

RecordingManager

import {RecordingManager} from "rp-recording";

Properties

active

active: boolean;

duration

duration: number;

hub

hub: StrictEventEmitter<EventEmitter, {
"cancel": void;
"capture": (key: string, data: unknown) => void;
"finalize": (key: string, data: unknown) => void;
"pause": void;
"resume": void;
"start": void;
}

paused

paused: boolean;

Methods

constructor()

constructor(player?: Player): RecordingManager;

beginRecording()

Calls beginRecording on all plugins will set paused to false and active to true. and emit start

beginRecording(plugins: RecorderPlugin[]): void;

capture()

capture(key: string, value: unknown): void;

emit capture event

endRecording()

End recording and collect finalized data from recorders.

endRecording(): Promise<unknown>;
const endTime = this.getTime();
this.duration = endTime;
const recording = {};

let startDelay = 0,
stopDelay = 0;

let promise;

// stop intransigentRecorder
if (this.intransigentRecorder) {
promise = this.intransigentRecorder.endRecording() as Promise<IntransigentReturn>;
}

// stop other recorders
for (const plugin of this.plugins) {
if (plugin.recorder === this.intransigentRecorder)
continue;
plugin.recorder.endRecording();
}

// get start/stop delays from intransigentRecorder
if (this.intransigentRecorder) {
try {
const [startTime, stopTime] = await promise;
startDelay = startTime;
stopDelay = stopTime - endTime;
this.duration = this.duration + stopDelay - startDelay;
} catch (e) {
startDelay = 0;
stopDelay = 0;
console.error(e);
}
}

// finalize
for (const plugin of this.plugins) {
recording[plugin.key] = plugin.recorder.finalizeRecording(this.captureData[plugin.key], startDelay, stopDelay);
this.hub.emit("finalize", plugin.key, recording[plugin.key]);
}

this.active = false;

this.hub.emit("finalize", undefined, undefined);

return recording;

}

getTime()

getTime(): number;

pauseRecording()

sets paused to true and emits pause event

pauseRecording(): void;

resumeRecording()

Resume recording from paused state. Calls resumeRecording on all plugins, sets paused to false, and emits resume event.

resumeRecording(): void;

setPlayer()

setPlayer(player: Player): void;