-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
69 lines (49 loc) · 1.98 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: "MediaRecorder: pause() method"
short-title: pause()
slug: Web/API/MediaRecorder/pause
page-type: web-api-instance-method
browser-compat: api.MediaRecorder.pause
---
{{APIRef("MediaStream Recording")}}
The **`pause()`** method of the {{domxref("MediaRecorder")}} interface is used
to pause recording of media streams.
When a `MediaRecorder` object's `pause()` method is called, the
browser queues a task that runs the below steps:
1. If {{domxref("MediaRecorder.state")}} is "inactive", raise a DOM
`InvalidState` error and terminate these steps. If not, continue to the
next step.
2. Set {{domxref("MediaRecorder.state")}} to "paused".
3. Stop gathering data into the current {{domxref("Blob")}}, but keep it available so
that recording can be resumed later on.
4. Raise a {{domxref("MediaRecorder/pause_event", "pause")}} event.
## Syntax
```js-nolint
pause()
```
### Parameters
None.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- `InvalidStateError` {{domxref("DOMException")}}
- : Thrown if the `MediaRecorder` is currently `"inactive"`; you cannot pause
the recording if the `MediaRecorder` is not active. If you call `pause()` while already paused,
the method silently does nothing.
## Examples
```js
pause.onclick = () => {
mediaRecorder.pause();
console.log("recording paused");
};
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API)
- [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder +
getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).)
- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton).
- {{domxref("Navigator.getUserMedia")}}