MediaRecorder Class
Records the tracks of a MediaStream (https://w3c.github.io/mediacapture-record/): the video and the audio are encoded by the codecs of BrowsingContextOptions.MediaCodecs (VP8 and Opus) and muxed into a WebM stream, delivered in dataavailable events. The video frames are sampled at the frame rate of the track (30 frames per second by default), on the clock of the event loop.
public sealed class MediaRecorder : EventTarget- Inheritance
EventTargetMediaRecorder
Constructors
| Name | Description |
|---|---|
| MediaRecorder(MediaStream, MediaRecorderOptions?) | Creates a recorder (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-mediarecorder). |
MediaRecorder(MediaStream, MediaRecorderOptions?)
MediaRecorder.csCreates a recorder (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-mediarecorder).
public MediaRecorder(MediaStream stream, MediaRecorderOptions? options = null)Parameters
streamMediaStream- The stream to record.
optionsMediaRecorderOptions?- The type, the bitrates and the key frame interval of the recording.
Exceptions
DomException- A
NotSupportedErrorwhen the type is not supported, the options give both key frame intervals, or the document is not fully active.
See also
Properties
| Name | Description |
|---|---|
| AudioBitrateMode | Gets how the audio encoder controls its bitrate. |
| AudioBitsPerSecond | Gets the target bitrate of the audio, in bits per second. |
| MimeType | Gets the type of the recording: the one of the options, or the one chosen when the recording starts. |
| OnDataAvailable | Gets or sets the event handler of the dataavailable event. |
| OnError | Gets or sets the event handler of the error event. |
| OnPause | Gets or sets the event handler of the pause event. |
| OnResume | Gets or sets the event handler of the resume event. |
| OnStart | Gets or sets the event handler of the start event. |
| OnStop | Gets or sets the event handler of the stop event. |
| State | Gets the state of the recorder. |
| Stream | Gets the recorded stream. |
| VideoBitsPerSecond | Gets the target bitrate of the video, in bits per second. |
AudioBitrateMode
MediaRecorder.csGets how the audio encoder controls its bitrate.
public BitrateMode AudioBitrateMode { get; }Property value
See also
AudioBitsPerSecond
MediaRecorder.csGets the target bitrate of the audio, in bits per second.
public uint AudioBitsPerSecond { get; }Property value
See also
MimeType
MediaRecorder.csGets the type of the recording: the one of the options, or the one chosen when the recording starts.
public string MimeType { get; }OnDataAvailable
MediaRecorder.csGets or sets the event handler of the dataavailable event.
OnError
MediaRecorder.csGets or sets the event handler of the error event.
Property value
See also
OnPause
MediaRecorder.csGets or sets the event handler of the pause event.
Property value
See also
OnResume
MediaRecorder.csGets or sets the event handler of the resume event.
Property value
See also
OnStart
MediaRecorder.csGets or sets the event handler of the start event.
Property value
See also
OnStop
MediaRecorder.csGets or sets the event handler of the stop event.
Property value
See also
State
MediaRecorder.csStream
MediaRecorder.csVideoBitsPerSecond
MediaRecorder.csGets the target bitrate of the video, in bits per second.
public uint VideoBitsPerSecond { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| IsTypeSupported(string) | Returns whether the recorder can record a type (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-istypesupported). |
| Pause() | Pauses the recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-pause). |
| RequestData() | Delivers the data recorded so far in a dataavailable event (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-requestdata). |
| Resume() | Resumes a paused recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-resume). |
| Start(uint?) | Starts the recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-start). |
| Stop() | Stops the recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-stop): the data is delivered, then a stop event is fired. |
IsTypeSupported(string)
MediaRecorder.csReturns whether the recorder can record a type (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-istypesupported).
Parameters
typestring- The MIME type (e.g.
video/webm;codecs=vp8,opus), or an empty string.
Returns
See also
Pause()
MediaRecorder.csPauses the recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-pause).
public void Pause()RequestData()
MediaRecorder.csDelivers the data recorded so far in a dataavailable event (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-requestdata).
public void RequestData()Resume()
MediaRecorder.csResumes a paused recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-resume).
public void Resume()Start(uint?)
MediaRecorder.csStarts the recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-start).
Parameters
timesliceuint?- The duration in milliseconds of the data of each
dataavailableevent, or null to deliver all the data when the recording stops.
Exceptions
DomException- An
InvalidStateErrorwhen the recorder is recording, aNotSupportedErrorwhen the stream is inactive, aSecurityErrorwhen a track is not origin-clean.
See also
Stop()
MediaRecorder.csStops the recording (https://w3c.github.io/mediacapture-record/#dom-mediarecorder-stop): the data is delivered, then a stop event is fired.
public void Stop()