Skip to content

Commit b7ba473

Browse files
authored
fix: ensure audio-only streams trigger onStreamReady (yondonfu#206)
During recent changes in yondonfu#38, the audio-only ability was broken because handleCanvasStreamReady (which calls onStreamReady) is not called when the user only supplies audio. This commit ensures that in the audio-only case, onStreamReady is called directly, so localStream is set and offer negotiation is started.
1 parent 83796b0 commit b7ba473

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ui/src/components/webcam.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ export function Webcam({
336336
const hasVideo = stream && stream.getVideoTracks().length > 0;
337337
const hasAudio = stream && stream.getAudioTracks().length > 0;
338338

339+
// Ensure audio only stream is passed to parent component.
340+
useEffect(() => {
341+
if (stream && !hasVideo && hasAudio) {
342+
onStreamReady(stream);
343+
}
344+
}, [stream, hasVideo, hasAudio, onStreamReady]);
345+
339346
// Return audio-only placeholder if we have audio but no video
340347
if (!hasVideo && hasAudio) {
341348
return (

0 commit comments

Comments
 (0)