MediaRecorder: stop-Ereignis
Das stop
-Ereignis der MediaRecorder
-Schnittstelle wird ausgelöst, wenn MediaRecorder.stop()
aufgerufen wird oder wenn der aufgenommene Medienstream endet. In jedem Fall geht dem stop
-Ereignis ein dataavailable
-Ereignis voraus, was den bis zu diesem Punkt aufgenommenen Blob
verfügbar macht, damit Sie ihn in Ihrer Anwendung nutzen können.
Syntax
Verwenden Sie den Ereignisnamen in Methoden wie addEventListener()
oder setzen Sie eine Ereignis-Handler-Eigenschaft.
js
addEventListener("stop", (event) => {});
onstop = (event) => {};
Ereignistyp
Ein generisches Event
.
Beispiel
js
mediaRecorder.onstop = (e) => {
console.log("data available after MediaRecorder.stop() called.");
const audio = document.createElement("audio");
audio.controls = true;
const blob = new Blob(chunks, { type: "audio/ogg; codecs=opus" });
const audioURL = window.URL.createObjectURL(blob);
audio.src = audioURL;
console.log("recorder stopped");
};
mediaRecorder.ondataavailable = (e) => {
chunks.push(e.data);
};
Spezifikationen
Specification |
---|
MediaStream Recording # dom-mediarecorder-onstop |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
stop event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on 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.
Siehe auch
- Verwendung der MediaStream Recording API
- Web Dictaphone: MediaRecorder + getUserMedia + Web Audio API Visualisierungsdemo, von Chris Mills (Source auf GitHub.)
- simpl.info MediaStream Recording Demo, von Sam Dutton.
Navigator.getUserMedia