feat: capture display media audio

This commit is contained in:
Timothy Jaeryang Baek
2025-05-04 00:14:19 +04:00
parent 4cfb99248d
commit 9c4a931d22
7 changed files with 189 additions and 49 deletions

View File

@@ -10,6 +10,8 @@
export let recording = false;
export let transcribe = true;
export let displayMedia = false;
export let className = ' p-2.5 w-full max-w-full';
export let onCancel = () => {};
@@ -175,13 +177,34 @@
const startRecording = async () => {
loading = true;
stream = await navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true
try {
if (displayMedia) {
stream = await navigator.mediaDevices.getDisplayMedia({
video: {
mediaSource: 'screen'
},
audio: {
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true
}
});
} else {
stream = await navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true
}
});
}
});
} catch (err) {
console.error('Error accessing media devices.', err);
toast.error($i18n.t('Error accessing media devices.'));
loading = false;
recording = false;
return;
}
mediaRecorder = new MediaRecorder(stream);
mediaRecorder.onstart = () => {