MediaRecorder: state property

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

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

{{APIRef("MediaStream Recording")}}

The **state** read-only property of the {{domxref("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 {{glossary("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

{{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()")}}