Skip to content

Streamer

Streamer helper

Streams video of the ResponsiveCanvas backing a CanvasRenderer. ResponsiveCanvas is multi-layer, Every rendering update Streamer merges all snapshots onto the recording canvas. MediaStream instance is created for this canvas and provides access the generated video stream. There’re several modes for resolution of the streamed video: “video” - streams in the same resolution as the video stream, “max”/“min” - in maximum/minimum size among layers of canvas. Additionally one can limit maximum resolution of the stream.

Constructors

new Streamer()

new Streamer(renderer, mirror, sizeMode, sizeMax?): Streamer

Constructor

Parameters

renderer: CanvasRenderer<object>

Renderer to record video from

mirror: boolean = false

Mirror captured images

sizeMode: "video" | "max" | "min" = "video"

Video size mode

sizeMax?: number

Maximum video size

Returns

Streamer

Properties

canvas

protected canvas: HTMLCanvasElement

Canvas to capture video


context

protected context: null | CanvasRenderingContext2D = null

Drawing context of capturing canvas


mirror

protected mirror: boolean = false

Mirror captured images


renderer

protected renderer: CanvasRenderer<object>

Renderer to record video from


sizeMax?

protected optional sizeMax: number

Maximum video size


sizeMode

protected sizeMode: "video" | "max" | "min" = "video"

Video size mode


stream?

protected optional stream: MediaStream

Output video stream

Methods

mediaStream()

mediaStream(): undefined | MediaStream

Media stream of generated video

Returns

undefined | MediaStream

Media stream


pause()

pause(): void

Pause video streaming

Stops drawing Renderer layers onto recording canvas.

Returns

void


render()

protected render(): void

Render

Every Renderer update Streamer merges snapshots of multilayer ResponsiveCanvas onto recording canvas.

Returns

void


start()

start(): boolean

Start video streaming

On every Renderer update Streamer draws all layers onto recording canvas. The canvas is a source of video stream.

Returns

boolean

True if recording started, False otherwise