mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
fix: keep the capture's video track alive while sharing tab audio
Stopping it right away may end or silence the capture session the audio track belongs to (suspected with Windows system audio in Edge). It runs at 1 fps and stops together with the audio. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
9d736dbfdd
commit
16e3cd8dd7
1 file changed
+5
-3
+5
-3
@@ -8719,14 +8719,16 @@ function AppInner() {
|
||||
}
|
||||
let stream: MediaStream;
|
||||
try {
|
||||
// Browsers only offer audio together with a video capture.
|
||||
stream = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: true });
|
||||
// Browsers only offer audio together with a video capture. The video
|
||||
// track stays alive (at 1 fps) until sharing stops: stopping it right
|
||||
// away may end or silence the capture session the audio belongs to.
|
||||
stream = await navigator.mediaDevices.getDisplayMedia({ video: { frameRate: 1 }, audio: true });
|
||||
} catch {
|
||||
return; // picker cancelled
|
||||
}
|
||||
stream.getVideoTracks().forEach((track) => track.stop());
|
||||
const track = stream.getAudioTracks()[0];
|
||||
if (!track) {
|
||||
stream.getTracks().forEach((track) => track.stop());
|
||||
appendLog({ text: t("tabAudio.noAudio"), kind: "error" });
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user