The Media.pause() method (part of the MediaRecorder API) 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:
- If
MediaRecorder.stateis "inactive", raise a DOMInvalidStateerror and terminate these steps. If not, continue to the next step. - Set
MediaRecorder.stateto "paused". - Stop gathering data into the current
Blob, but keep it available so that recording can be resumed later on. - Raise a
pauseevent.
Syntax
MediaRecorder.pause()
Return value
undefined.
Exceptions
InvalidStateError- The
MediaRecorderis currently"inactive"; you can't pause recording if it's not active. If you callpause()while already paused, it silently does nothing.
Example
...
pause.onclick = function() {
mediaRecorder.pause();
console.log("recording paused");
}
...
Specifications
| Specification | Status | Comment |
|---|---|---|
| MediaStream Recording The definition of 'MediaRecorder.pause()' in that specification. |
Working Draft | Initial definition |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
pause | Chrome Full support 49 | Edge Full support 79 | Firefox Full support 25 | IE No support No | Opera Full support 36 | Safari No support No | WebView Android Full support 49 | Chrome Android Full support 49 | Firefox Android Full support 25 | Opera Android Full support 36 | Safari iOS No support No | Samsung Internet Android Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
See also
- Using the MediaRecorder 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
