mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-27 13:29:34 +07:00
Add microphone input to tabcapture sample for crbug/1400269
This commit is contained in:
@@ -56,7 +56,22 @@ async function startRecording(streamId) {
|
||||
source.connect(output.destination);
|
||||
|
||||
// Start recording.
|
||||
recorder = new MediaRecorder(media, { mimeType: 'video/webm' });
|
||||
const microphone = await navigator.mediaDevices.getUserMedia({
|
||||
audio: { echoCancellation: false }
|
||||
});
|
||||
|
||||
const mixedContext = new AudioContext();
|
||||
const mixedDest = mixedContext.createMediaStreamDestination();
|
||||
|
||||
mixedContext.createMediaStreamSource(microphone).connect(mixedDest);
|
||||
mixedContext.createMediaStreamSource(media).connect(mixedDest);
|
||||
|
||||
const combinedStream = new MediaStream([
|
||||
media.getVideoTracks()[0],
|
||||
mixedDest.stream.getTracks()[0]
|
||||
]);
|
||||
|
||||
recorder = new MediaRecorder(combinedStream, { mimeType: 'video/webm' });
|
||||
recorder.ondataavailable = (event) => data.push(event.data);
|
||||
recorder.onstop = () => {
|
||||
const blob = new Blob(data, { type: 'video/webm' });
|
||||
|
||||
Reference in New Issue
Block a user