Recorder

interface Recorder extends HybridObject

Represents an instance that can record videos to a file.

A single Recorder instance records to a single video file. To record multiple videos, you will need to create multiple Recorder instances.

Properties

filePath

readonly filePath: string

Returns the absolute path to the file that this Recorder is recording- or will record- to.


isPaused

readonly isPaused: boolean

Returns whether the current recording is paused.


isRecording

readonly isRecording: boolean

Returns whether the output is currently recording.


recordedDuration

readonly recordedDuration: number

Returns the currently recorded duration, in seconds. If isRecording is false, this returns 0.


recordedFileSize

readonly recordedFileSize: number

Returns the currently recorded file size, in bytes. If isRecording is false, this returns 0.

Methods

cancelRecording()

cancelRecording(): Promise<void>

Cancels the current recording and deletes the video file.


pauseRecording()

pauseRecording(): Promise<void>

Requests the Video recording to be paused. Once the recording has actually been paused, the onRecordingPaused callback passed to startRecording will be called.


resumeRecording()

resumeRecording(): Promise<void>

Requests the currently paused Video recording to be resumed. Once the recording has actually been resumed, the onRecordingResumed callback passed to startRecording will be called.


startRecording()

startRecording(
   onRecordingFinished: (filePath: string) => void, 
   onRecordingError: (error: Error) => void, 
   onRecordingPaused?: () => void, 
onRecordingResumed?: () => void): Promise<void>

Start the Video recording to a temporary file.

This Promise resolves once the Recording has been successfully started, and returns the temporary file URL it is currently recording to.

Parameters

onRecordingFinished

Called when the Recording has successfully finished via a stopRecording() call, or when the max file-size has been reached.

onRecordingError

Called when an unexpected error occurred while recording.

onRecordingPaused

Called when the recording has been paused.

onRecordingResumed

Called when the paused recording has been resumed.

Throws

If called twice on the same Recorder instance.


stopRecording()

stopRecording(): Promise<void>

Requests the Video recording to be stopped. Once the recording has actually been stopped, the onRecordingFinished callback passed to startRecording will be called.