Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CanvasRecorder

Class to record the contents of a Canvas. Some time after stopping the CanvasRecorder the recorded images will be available as Array of Blobs. The images can be retrieved by setting the onImagesAvailable callback. Exemplary usage:

const recorder = new gloperate.CanvasRecorder(canvas);
recorder.start(30, 'video/webm', 2.0 * 2**20);
...
recorder.stop();
recorder.download();

Hierarchy

  • CanvasRecorder

Index

Constructors

constructor

Properties

Protected _canvas

_canvas: Canvas

Protected _images

_images: Blob[]

Protected _mimeType

_mimeType: string

Protected _onImagesAvailable

_onImagesAvailable: undefined | ImagesAvailableCallback

Protected _recorder

_recorder: any

Protected _state

_state: State

Protected _stream

_stream: any

Accessors

blob

  • get blob(): Blob

images

  • get images(): Blob[]
  • Returns the recorded images. Note: Images are not necessarily immediately available after stopping.

    Returns Blob[]

onImagesAvailable

  • set onImagesAvailable(callback: ImagesAvailableCallback): void

state

Methods

download

  • download(fileName: string): void
  • Creates a temporary hyperlink element and triggers a download of the blob with the given file name. Both, the hyperlink element and the blob url are removed automatically shortly after the hyperlink click was triggered.

    Parameters

    • fileName: string

    Returns void

frame

  • frame(): void

pause

  • pause(): void

resume

  • resume(): void

start

  • start(fps: number, mimeType?: string, bitsPerSecond?: number): void
  • Starts recording the the canvas. If the given fps is 0 it won't automatically record. Instead frame has to be called every time a new frame should get recorded. Must not be called with negative fps, while already recording or with an unsupported MIME type.

    Parameters

    • fps: number

      Maximum fps to record in.

    • mimeType: string = 'video/webm'

      The MIME video type.

    • bitsPerSecond: number = ...

    Returns void

stop

  • stop(): void

Static isMIMETypeSupported

  • isMIMETypeSupported(type: string): boolean
  • Checks whether the given MIME type is supported.

    Parameters

    • type: string

      MIME type to check.

    Returns boolean

Static isSupported

  • isSupported(): boolean