MediaRecorderCapture class

Lightweight wrapper around the browser MediaRecorder API.

Handles the encode + mux pipeline for browsers that lack WebCodecs (Firefox < 130, older Safari, etc.).

Each recorded chunk is delivered to onChunk as a Uint8List. The accumulated bytes form a valid WebM or MP4 file depending on the browser.

Constructors

MediaRecorderCapture({required MediaStream stream, required void onChunk(Uint8List chunk), String? mimeType, int videoBitsPerSecond = 6000000, int audioBitsPerSecond = 128000, int timesliceMs = 1000})

Properties

audioBitsPerSecond → int
final
hashCode → int
The hash code for this object.
no setterinherited
isRecording → bool
Whether this capture is currently recording.
no setter
mimeType → String
The mime type that will be (or is being) used.
no setter
onChunk → void Function(Uint8List chunk)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
timesliceMs → int
final
videoBitsPerSecond → int
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
requestData() → void
Request the recorder to emit any buffered data immediately.
start() → Future<void>
Start recording. Throws if already recording.
stop() → Future<void>
Stop recording and wait for the final chunk to be delivered.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

preferredMimeType → String
Returns the first MIME type from _kPreferredTypes that the current browser supports via MediaRecorder.isTypeSupported().
no setter