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:
MoepchiandClaude Opus 5.5 committed 2026-10-03 09:19:19 +00:00
1 parent 9d736dbfdd
commit 16e3cd8dd7
1 file changed
+5 -3
+5 -3
View File
@@ -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;
}