Loading...
const recorder = new MediaRecorder(stream, { mimeType: 'audio/webm' });
recorder.ondataavailable = (e) => upload(e.data);const type = ['audio/webm', 'audio/mp4'].find((t) => MediaRecorder.isTypeSupported(t));
const recorder = new MediaRecorder(stream, { mimeType: type });
const chunks = [];
recorder.ondataavailable = (e) => chunks.push(e.data);
recorder.onstop = () => upload(new Blob(chunks, { type }));Pick a supported format at runtime and build one Blob from all chunks after stop.
MediaRecorder.isTypeSupported() before recording.dataavailable are collected and combined into one Blob after stop.Data arrives in dataavailable events. Combine the chunks in the stop event handler, not right after calling stop().
Pass a timeslice in milliseconds to start(), like recorder.start(1000), to get a dataavailable event about every second.
Yes. Pass the stream from getDisplayMedia() to MediaRecorder like any other MediaStream.