recursal/MDN huggingface dataset:
AudioWorkletProcessor: port property
====================================

 The read-only **`port`** property of the
 `AudioWorkletProcessor` interface returns the associated
 `MessagePort`. It can be used to communicate between the processor and the
 `AudioWorkletNode` to which it belongs.


**Note:** The port at the other end of the channel is
 available under the `port` property of the node.


Value
-----

The `MessagePort` object that is connecting the `AudioWorkletProcessor` and the associated `AudioWorkletNode`.

Examples
--------

See `AudioWorkletNode.port` for example code.

Specifications
--------------

| Specification |
| --- |
| Web Audio API # dom-audioworkletprocessor-port |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Audio API
* Using the Web Audio API
AudioWorkletProcessor: parameterDescriptors property
====================================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

 The read-only **`parameterDescriptors`** property of an `AudioWorkletProcessor`-derived class is a *static getter*,
 which returns an iterable of `AudioParamDescriptor`-based objects.

 The property is not a part of the `AudioWorkletProcessor`
 interface, but, if defined, it is called internally by the
 `AudioWorkletProcessor` constructor to create a list of custom
 `AudioParam` objects in the `parameters` property of the associated `AudioWorkletNode`.

Defining the getter is optional.

Value
-----

 An iterable of `AudioParamDescriptor`-based objects. The properties of
 these objects are as follows:

`name`

The string which represents the name of the `AudioParam`. Under this name the `AudioParam` will be available in the `parameters` property of the node, and under this name the `AudioWorkletProcessor.process` method will acquire the calculated values of this `AudioParam`.

`automationRate` Optional

Either `"a-rate"`, or `"k-rate"` string which represents an automation rate of this `AudioParam`. Defaults to `"a-rate"`.

`minValue` Optional

A `float` which represents minimum value of the `AudioParam`. Defaults to `-3.4028235e38`.

`maxValue` Optional

A `float` which represents maximum value of the `AudioParam`. Defaults to `3.4028235e38`.

`defaultValue` Optional

A `float` which represents initial value of the `AudioParam`. Defaults to `0`.

Examples
--------

See `AudioWorkletNode.parameters` for example code showing how to add static `parameterDescriptors` getter to a custom `AudioWorkletProcessor`.

Specifications
--------------

| Specification |
| --- |
| Web Audio API # audioworkletprocess-callback-parameters |

See also
--------

* Web Audio API
* Using the Web Audio API
MediaRecorder: audioBitsPerSecond property
==========================================

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

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

Value
-----

A `Number` (unsigned long).

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-audiobitspersecond |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
MediaRecorder: pause event
==========================

 The **`pause`** event of the `MediaRecorder` interface is fired when
 `MediaRecorder.pause()` is called.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("pause", (event) => {});

onpause = (event) => {};
```

Event type
----------

A generic `Event`.

Example
-------


```js
pause.onclick = () => {
  if (mediaRecorder.state === "recording") {
    mediaRecorder.pause();
    // recording paused
  } else if (mediaRecorder.state === "paused") {
    mediaRecorder.resume();
    // resume recording
  }
};

mediaRecorder.onpause = () => {
  // do something in response to
  // recording being paused
};

mediaRecorder.onresume = () => {
  // do something in response to
  // recording being resumed
};
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-onpause |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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`
MediaRecorder: stop() method
============================

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

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

1. If `MediaRecorder.state` is "inactive", raise a DOM
 `InvalidState` error and terminate these steps. If the
 `MediaRecorder.state` is not "inactive", continue on to the next step.
2. Set the `MediaRecorder.state` to "inactive" and stop capturing media.
3. Raise a `dataavailable` event containing the Blob of data that has been
 gathered.
4. Raise a `stop` event.
Syntax
------


```js
stop()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

`InvalidStateError` `DOMException`

 Thrown if the `MediaRecorder` is currently `"inactive"`; you cannot stop
 the recording if the `MediaRecorder` is not active.


Examples
--------


```js
stop.onclick = () => {
  mediaRecorder.stop();
  console.log("recorder stopped, data available");
};
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-stop |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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`
MediaRecorder: start event
==========================

 The **`start`** event of the `MediaRecorder` interface is fired when
 `MediaRecorder.start()` is called. At this point, the data
 starts being gathered into a `Blob`.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("start", (event) => {});

onstart = (event) => {};
```

Event type
----------

A generic `Event`.

Example
-------


```js
record.onclick = () => {
  mediaRecorder.start();
  console.log("recorder started");
};

mediaRecorder.onstart = () => {
  // do something in response to
  // recording being started
};
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-onstart |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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`
MediaRecorder: resume() method
==============================

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

If `MediaRecorder.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:

1. If `MediaRecorder.state` is "inactive", raise a DOM
 `InvalidStateError` exception and terminate these steps. If
 `MediaRecorder.state` is not "inactive", continue to the next step.
2. Set `MediaRecorder.state` to "recording".
3. Continue gathering data into the current `Blob`.
4. Raise a `resume` event.
Syntax
------


```js
resume()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

`InvalidStateError` `DOMException`

Thrown if the `MediaRecorder` is currently `"inactive"`.

Examples
--------


```js
pause.onclick = () => {
  if (MediaRecorder.state === "recording") {
    mediaRecorder.pause();
    // recording paused
  } else if (MediaRecorder.state === "paused") {
    mediaRecorder.resume();
    // resume recording
  }
};
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-resume |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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`
MediaRecorder: state property
=============================

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

Value
-----

A string containing one of the following values:

`inactive`

Recording is not occurring — it has either not been started yet, or it has been started and then stopped.

`recording`

Recording has been started and the user agent is capturing data.

`paused`

Recording has been started, then paused, but not yet stopped or resumed.

Examples
--------


```js
record.onclick = () => {
  mediaRecorder.start();
  console.log(mediaRecorder.state);
  // Will return "recording"
  console.log("recorder started");
};
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-state |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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()`
MediaRecorder: mimeType property
================================

 The **`mimeType`** read-only property of the `MediaRecorder` interface returns the 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.

 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.


Value
-----

 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.

Examples
--------


```js
if (navigator.mediaDevices) {
  console.log("getUserMedia supported.");

  const constraints = { audio: true, video: true };
  const chunks = [];

  navigator.mediaDevices
    .getUserMedia(constraints)
    .then((stream) => {
      const options = {
        audioBitsPerSecond: 128000,
        videoBitsPerSecond: 2500000,
        mimeType: "video/mp4",
      };
      const mediaRecorder = new MediaRecorder(stream, options);
      m = mediaRecorder;

      m.mimeType; // would return 'video/mp4'
      // …
    })
    .catch((error) => {
      console.error(error.message);
    });
}
```


Changing line 14 to the following causes `MediaRecorder` to try to use AVC Constrained Baseline Profile Level 4 for video and AAC-LC (Low Complexity) for audio, which is good for mobile and other possible resource-constrained situations.


```js
mimeType: 'video/mp4; codecs="avc1.424028, mp4a.40.2"';
```


 Assuming this configuration is acceptable to the user agent, the value returned later
 by `m.mimeType` would then be
 `video/mp4; codecs="avc1.424028, mp4a.40.2"`.

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-mimetype |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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.
* `MediaDevices.getUserMedia()`
MediaRecorder: stream property
==============================

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

Value
-----

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

Examples
--------


```js
if (navigator.getUserMedia) {
  console.log("getUserMedia supported.");
  navigator.getUserMedia(
    // constraints - only audio needed for this app
    {
      audio: true,
    },

    // Success callback
    (stream) => {
      const mediaRecorder = new MediaRecorder(stream);

      const myStream = mediaRecorder.stream;
      console.log(myStream);
    },
  );
}
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-stream |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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`
MediaRecorder: requestData() method
===================================

 The **`requestData()`**
 method of the `MediaRecorder` interface is used to raise a `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.

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

1. If `MediaRecorder.state` is "inactive", raise a DOM
 `InvalidState` error and terminate these steps. If
 `MediaRecorder.state` is not "inactive", continue to the next step.
2. Raise a `dataavailable` event containing a `Blob` of the
 currently captured data (the Blob is available under the event's `data`
 attribute.)
3. Create a new Blob and place subsequently captured data into it.
Syntax
------


```js
requestData()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

`InvalidStateError` `DOMException`

 Thrown if the `MediaRecorder` is currently `"inactive"`; you cannot capture
 the recording if the `MediaRecorder` is not active.


Examples
--------


```js
captureMedia.onclick = () => {
  mediaRecorder.requestData();
  // makes snapshot available of data so far
  // ondataavailable fires, then capturing continues
  // in new Blob
};
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-requestdata |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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()`
MediaRecorder: audioBitrateMode property
========================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`audioBitrateMode`** read-only property of the `MediaRecorder` interface returns the bitrate mode used to encode audio tracks.

Value
-----

One of the following:

`constant`

The `MediaRecorder` encodes at this constant bitrate.

`variable`

The `MediaRecorder` encodes using this variable bitrate, allowing more space to be used for complex signals and less space for less complex signals.

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-audiobitratemode |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
MediaRecorder: videoBitsPerSecond property
==========================================

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

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

Value
-----

A `Number` (unsigned long).

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-videobitspersecond |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
MediaRecorder: stop event
=========================

 The **`stop`** event of the `MediaRecorder` interface is fired when
 `MediaRecorder.stop()` is called, or when the media stream being
 captured ends. In each case, the `stop` event is preceded by a
 `dataavailable` event, making the `Blob` captured up to that
 point available for you to use in your application.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("stop", (event) => {});

onstop = (event) => {};
```

Event type
----------

A generic `Event`.

Example
-------


```js
mediaRecorder.onstop = (e) => {
  console.log("data available after MediaRecorder.stop() called.");

  const audio = document.createElement("audio");
  audio.controls = true;
  const blob = new Blob(chunks, { type: "audio/ogg; codecs=opus" });
  const audioURL = window.URL.createObjectURL(blob);
  audio.src = audioURL;
  console.log("recorder stopped");
};

mediaRecorder.ondataavailable = (e) => {
  chunks.push(e.data);
};
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-onstop |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* 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`
MediaRecorder: isTypeSupported() static method
==============================================

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

Syntax
------


```js
MediaRecorder.isTypeSupported(mimeType)
```

### Parameters

`mimeType`

The MIME media type to check.

### Return value

 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.

Examples
--------


```js
const types = [
  "video/webm",
  "audio/webm",
  "video/webm;codecs=vp8",
  "video/webm;codecs=daala",
  "video/webm;codecs=h264",
  "audio/webm;codecs=opus",
  "video/mpeg",
];

for (const type of types) {
  console.log(
    `Is ${type} supported? ${
 MediaRecorder.isTypeSupported(type) ? "Maybe!" : "Nope :("
 }`,
  );
}
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-istypesupported |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* MediaStream Recording API
* Using the MediaStream Recording API
* Guide to media types and formats on the web
* Codecs in common media types
* `MediaStreamTrack`
* `MediaStream`
* `MediaCapabilities`
MediaRecorder: error event
==========================

The **`error`** event of the `MediaRecorder` interface is fired when an error occurs: for example because recording wasn't allowed or was attempted using an unsupported codec.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("event", (event) => {});

onevent = (event) => {};
```

Event type
----------

A `MediaRecorderErrorEvent`. Inherits from `Event`.

Event properties
----------------

*Inherits properties from its parent interface, `Event`*.

`error` Read only 

A `DOMException` containing information about the error that occurred.

Description
-----------

### Trigger

 A function to be called whenever an error occurs during the recorder's lifetime. In
 addition to other general errors that might occur, the following errors are specifically
 possible when using the MediaStream Recording API; to determine which occurred, check
 the value of `MediaRecorderErrorEvent.error.name`.

`SecurityError`

 The `MediaStream` is configured to disallow recording. This may be the
 case, for example, with sources obtained using `getUserMedia()` when the user denies permission to use an input device.


`InvalidModificationError`

 The number of tracks on the stream being recorded has changed. You can't add or
 remove tracks while recording media.


`UnknownError`

 An non-security related error occurred that cannot otherwise be categorized.
 Recording stops, the `MediaRecorder`'s `state` becomes `inactive`, one last `dataavailable` event is
 sent to the `MediaRecorder` with the remaining received data, and finally a
 `stop` event is sent.


Examples
--------

Using `addEventListener()` to listen for `error` events:


```js
async function record() {
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
  const recorder = new MediaRecorder(stream);
  recorder.addEventListener("error", (event) => {
    console.error(`error recording stream: ${event.error.name}`);
  });
  recorder.start();
}

record();
```


The same, but using the `onerror` event handler property:


```js
async function record() {
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
  const recorder = new MediaRecorder(stream);
  recorder.onerror = (event) => {
    console.error(`error recording stream: ${event.error.name}`);
  };
  recorder.start();
}

record();
```

Specifications
--------------

| Specification |
| --- |
| MediaStream Recording # dom-mediarecorder-onerror |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using the MediaStream Recording API