web api instance method
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:
- If
stateis “inactive”, raise a DOMInvalidStateerror and terminate these steps. If thestateis not “inactive”, continue on to the next step. - Set the
stateto “inactive” and stop capturing media. - Raise a
dataavailableevent containing the Blob of data that has been gathered. - Raise a
stopevent.
Syntax
stop()
Parameters
None.
Return value
None (undefined).
Exceptions
InvalidStateErrorDOMException- : Thrown if the
MediaRecorderis currently"inactive"; you cannot stop the recording if theMediaRecorderis not active.
- : Thrown if the
Examples
stop.onclick = () => {
mediaRecorder.stop();
console.log("recorder stopped, data available");
};
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
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.
getUserMedia