MediaSourceRecorder class

Records the video produced by an O3hMediaSource to a video asset that can be played back or exported.

Signature:

export declare class MediaSourceRecorder extends ExternalObject 

Extends: ExternalObject

Remarks

Use O3hMediaSource.createVideoRecorder() to create an instance of this class.

Methods

MethodModifiersDescription
addHighlight(type, level)Associate a highlight of the given type at the current moment in the video capture
pause()Pause the recording, does nothing if already paused.
reset()Prepares the recorder for another recording after stopping a recording.
resume()Resume a paused recording, does nothing if not paused.
setMicrophoneVolume(volume)Set the volume of the microphone input in real time.
setRecordingSpeed(speed)Control the timing of adding frames to the video recording.
startRecording()Starts recording.
stopRecording(delaySeconds)Stop the video recording, must occur after a call to startRecording.

MediaSourceRecorder.addHighlight() method

Associate a highlight of the given type at the current moment in the video capture

Signature:

addHighlight(type: Enum<typeof HighlightType>, level: number): void;

Parameters

ParameterTypeDescription
typeEnum<typeof HighlightType>The classification of what makes this moment special
levelnumberA value between 1 and 100 that describes how strong the highlight moment is

Returns:

void

MediaSourceRecorder.pause() method

Pause the recording, does nothing if already paused.

Signature:

pause(): void;

Returns:

void

MediaSourceRecorder.reset() method

Prepares the recorder for another recording after stopping a recording.

Signature:

reset(): Promise<void>;

Returns:

Promise<void>

Remarks

This will not start the new recording, you must call MediaSourceRecorder.startRecording() after the promise returned resolves to start recording.

Calling this during an ongoing recording will cancel it.

MediaSourceRecorder.resume() method

Resume a paused recording, does nothing if not paused.

Signature:

resume(): void;

Returns:

void

MediaSourceRecorder.setMicrophoneVolume() method

Set the volume of the microphone input in real time.

Signature:

setMicrophoneVolume(volume: number): void;

Parameters

ParameterTypeDescription
volumenumberThe desired microphone input volume, with normal values between 0 and 1. Volume defaults to 1 if this isn't called

Returns:

void

Remarks

Calling this has no effect if the recorder was created when MediaSourceRecorderConfig.recordMicrophone set to false.

MediaSourceRecorder.setRecordingSpeed() method

Control the timing of adding frames to the video recording.

Signature:

setRecordingSpeed(speed: number): void;

Parameters

ParameterTypeDescription
speednumberSlow motion capture for values between 0 and 1 or time lapse for values > 1.

Returns:

void

Remarks

If this is not called recording defaults to a value of 1 which is real time.

For values other then 1 it's suggested you disable microphone recording or set the volume to 0. Otherwise the audio is out of sync with slow mo recordings and chopping for time lapse ones.

MediaSourceRecorder.startRecording() method

Starts recording.

Signature:

startRecording(): Promise<boolean>;

Returns:

Promise<boolean>

A promise that resolves with true if recording started or false if an error occurred.

MediaSourceRecorder.stopRecording() method

Stop the video recording, must occur after a call to startRecording.

Signature:

stopRecording(delaySeconds?: number): Promise<VideoAsset>;

Parameters

ParameterTypeDescription
delaySecondsnumber(Optional)

Returns:

Promise<VideoAsset>

The video created during the recording process.

Remarks

This call can take more than half a second to run, try to perform this operation behind the scenes.

Once the recording has been stopped you must call MediaSourceRecorder.reset() if you want to reuse the recorder for another recording.