Skip to content

UniRecorder

Recorder helper (one layer verstion)

Records a video of a layer of the ResponsiveCanvas backing a CanvasRenderer. Simple and straightforward recording of a canvas. Encoded video chunks are cached to later be merged into one blob containing the final video file.

Constructors

new UniRecorder()

new UniRecorder(renderer, layer, type, bitRate?): UniRecorder

Constructor

Parameters

renderer: CanvasRenderer<object>

Renderer to record video from

layer: number = 0

Layer that will be recorded

type: string = "video/webm"

Media/video type

bitRate?: number

Video stream bit rate

Returns

UniRecorder

Properties

bitRate?

protected optional bitRate: number

Video stream bit rate


layer

protected layer: number = 0

Layer that will be recorded


recorder?

protected optional recorder: MediaRecorder

Video recorder


records

protected records: Blob[] = []

Record chunks


renderer

protected renderer: CanvasRenderer<object>

Renderer to record video from


stream?

protected optional stream: MediaStream

Video stream


type

protected type: string = "video/webm"

Media/video type

Methods

start()

start(): boolean

Start video recording

Recorder encodes video stream associated with the canvas layer. Chunks of encoded media stream are cached to later be merged into one blob on stop().

Returns

boolean

True if recording started, False otherwise


stop()

stop(): Promise<undefined | Blob>

Stop video recording

Renderer stops recording and then merges encoded video stream chunks into one blob returned to user.

Returns

Promise<undefined | Blob>

Promise resolved to Blob containing encoded video