Table of Contents

Class MediaRecorder

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The MediaRecorder interface of the MediaStream Recording API provides functionality to easily record media. It is created using the MediaRecorder(MediaStream, MediaRecorderOptions) constructor.

[Value("MediaRecorder")]
public class MediaRecorder : EventTarget
Inheritance
MediaRecorder
Inherited Members

Remarks

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder + getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-Recording a media element
-simpl.info MediaStream Recording demo, by Sam Dutton.
-GetUserMedia(MediaStreamConstraints)
-OpenLang: HTML video language lab web application using MediaDevices and the MediaStream Recording API for video recording (source on GitHub)

See also on MDN

Constructors

MediaRecorder()

public MediaRecorder()

MediaRecorder(MediaStream, MediaRecorderOptions)

The MediaRecorder() constructor
creates a new MediaRecorder object that will record a specified
MediaStream.

public MediaRecorder(MediaStream stream, MediaRecorderOptions options = null)

Parameters

stream MediaStream
options MediaRecorderOptions

Remarks

The object can optionally be configured to record
using a specific media container (file type), and, further, can specify the exact codec
and codec configuration(s) to use by specifying the codecs parameter.

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-GetUserMedia(MediaStreamConstraints)

See also on MDN

Properties

AudioBitrateMode

NOTE
Experimental
The audioBitrateMode read-only property of the MediaRecorder interface returns the bitrate mode used to encode audio tracks.
[Value("audioBitrateMode")]
public BitrateMode AudioBitrateMode { get; }

Property Value

BitrateMode

One of the following:

Remarks

AudioBitsPerSecond

The audioBitsPerSecond read-only
property of the MediaRecorder interface returns the audio encoding bit
rate in use.

[Value("audioBitsPerSecond")]
public ulong AudioBitsPerSecond { get; }

Property Value

ulong

A Number (unsigned long).

Remarks

This may differ from the bit rate specified in the constructor (if
it was provided).

See also on MDN

MimeType

The mimeType read-only property of the MediaRecorder interface returns the {{Glossary("MIME")}} media type that was specified when creating the MediaRecorder object, or, if none was specified, which was chosen by the browser.
This is the file format of the file that would result from writing all of the recorded data to disk.

[Value("mimeType")]
public string MimeType { get; }

Property Value

string

The MIME media type which describes the format of the recorded media, as a string.
This string may include the codecs parameter, giving details about the codecs and the codec configurations used by the media recorder.The media type strings are standardized by the Internet Assigned Numbers Authority (IANA).
For their official list of defined media type strings, see the article Media Types on the IANA site.
See also media types to learn more about media types and how they're used in web content and by web browsers.

Remarks

Keep in mind that not all codecs are supported by a given container; if you write media using a codec that is not supported by a given media container, the resulting file may not work reliably if at all when you try to play it back.
See our media type and format guide for information about container and codec support across browsers.

NOTE

The term "MIME type" is officially considered to be historical; these strings are now officially known as media types.
MDN Web Docs content uses the terms interchangeably.

-Using the MediaStream Recording API
-Codecs in common media types
-Web Dictaphone: MediaRecorder + getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-GetUserMedia(MediaStreamConstraints)

See also on MDN

Ondataavailable

[Value("ondataavailable")]
public EventHandlerNonNull Ondataavailable { get; set; }

Property Value

EventHandlerNonNull

Onerror

[Value("onerror")]
public EventHandlerNonNull Onerror { get; set; }

Property Value

EventHandlerNonNull

Onpause

[Value("onpause")]
public EventHandlerNonNull Onpause { get; set; }

Property Value

EventHandlerNonNull

Onresume

[Value("onresume")]
public EventHandlerNonNull Onresume { get; set; }

Property Value

EventHandlerNonNull

Onstart

[Value("onstart")]
public EventHandlerNonNull Onstart { get; set; }

Property Value

EventHandlerNonNull

Onstop

[Value("onstop")]
public EventHandlerNonNull Onstop { get; set; }

Property Value

EventHandlerNonNull

State

The state read-only property of the MediaRecorder interface returns the current state of the current MediaRecorder object.

[Value("state")]
public RecordingState State { get; }

Property Value

RecordingState

A string containing one of the following values:

Remarks

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-Navigator.GetUserMedia

See also on MDN

Stream

The stream read-only property of the MediaRecorder interface returns the stream that was passed into the MediaRecorder(MediaStream, MediaRecorderOptions) constructor when the MediaRecorder was created.

[Value("stream")]
public MediaStream Stream { get; }

Property Value

MediaStream

The MediaStream passed into the MediaRecorder() constructor when the MediaRecorder was originally created.

Remarks

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-Navigator.GetUserMedia

See also on MDN

VideoBitsPerSecond

The videoBitsPerSecond read-only
property of the MediaRecorder interface returns the video encoding
bit rate in use.

[Value("videoBitsPerSecond")]
public ulong VideoBitsPerSecond { get; }

Property Value

ulong

A Number (unsigned long).

Remarks

This may differ from the bit rate specified in the
constructor, if it was provided.

See also on MDN

Methods

IsTypeSupported(string)

The isTypeSupported() static method of the MediaRecorder interface returns a {{jsxref("Boolean")}} which is true if the MIME media type specified is one the user agent should be able to successfully record.

[Value("isTypeSupported")]
public static bool IsTypeSupported(string type)

Parameters

type string

Returns

bool

A Boolean, true if the MediaRecorder implementation is capable of recording Blob objects for the specified MIME type.
Recording may still fail if there are insufficient resources to support the recording and encoding process.
If the value is false, the user agent is incapable of recording the specified format.

Remarks

Pause()

The pause() method of the MediaRecorder interface is used
to pause recording of media streams.

[Value("pause")]
public GlobalObject.Undefined Pause()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

When a MediaRecorder object's pause() method is called, the
browser queues a task that runs the below steps:

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-Navigator.GetUserMedia

See also on MDN

RequestData()

The requestData()
method of the MediaRecorder interface is used to raise a MediaRecorder.Dataavailable event containing a
Blob object of the captured media as it was when the method was
called. This can then be grabbed and manipulated as you wish.

[Value("requestData")]
public GlobalObject.Undefined RequestData()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

When the requestData() method is invoked, the browser queues a task that
runs the following steps:

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-Navigator.GetUserMedia

See also on MDN

Resume()

The resume() method of the MediaRecorder interface is used to resume media recording when it has been previously paused.

[Value("resume")]
public GlobalObject.Undefined Resume()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

If State is already "recording", calling resume() has no effect.

When the resume() method is invoked, the browser queues a task that runs
the following steps:

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-Navigator.GetUserMedia

See also on MDN

Start(ulong)

The start() method of the MediaRecorder interface begins recording media into one or more Blob objects.

[Value("start")]
public GlobalObject.Undefined Start(ulong timeslice = 0)

Parameters

timeslice ulong

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

You can
record the entire duration of the media into a single Blob (or until you
call RequestData()), or you can specify the
number of milliseconds to record at a time. Then, each time that amount of media has
been recorded, an event will be delivered to let you act upon the recorded media, while
a new Blob is created to record the next slice of the media.

Assuming the MediaRecorder's State
is inactive, start() sets the state to
recording, then begins capturing media from the input stream. A
Blob is created and the data is collected in it until the time slice period
elapses or the source media ends. Each time a Blob is filled up to that
point (the timeslice duration or the end-of-media, if no slice duration was provided), a
MediaRecorder.Dataavailable event is sent to the MediaRecorder with the
recorded data. If the source is still playing, a new Blob is created and
recording continues into that, and so forth.

When the source stream ends, state is set to inactive and
data gathering stops. A final MediaRecorder.Dataavailable event is sent to the
MediaRecorder, followed by a MediaRecorderstop event.

NOTE

If the browser is unable to start recording or continue
recording, it will raise an MediaRecorder.Error event, followed by a
MediaRecorder.Dataavailable event containing the Blob it
has gathered, followed by the MediaRecorderstop event.

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-GetUserMedia(MediaStreamConstraints)

See also on MDN

Stop()

The stop() method of the MediaRecorder interface is
used to stop media capture.

[Value("stop")]
public GlobalObject.Undefined Stop()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

When the stop() method is invoked, the UA queues a task that runs the
following steps:

-Using the MediaStream Recording API
-Web Dictaphone: MediaRecorder +
getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)
-simpl.info MediaStream Recording demo, by Sam Dutton.
-Navigator.GetUserMedia

See also on MDN