MediaRecorder: pause() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{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.

  1. Set {{domxref("MediaRecorder.state")}} to "paused".
  2. Stop gathering data into the current {{domxref("Blob")}}, but keep it available so

that recording can be resumed later on.

  1. 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
  • Web Dictaphone: MediaRecorder +

getUserMedia + Web Audio API visualization demo, by Chris Mills (source on GitHub.)

  • simpl.info MediaStream Recording demo, by Sam Dutton.
  • {{domxref("Navigator.getUserMedia")}}