Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-14 19:05:04 +00:00
parent 63852195fc
commit b60ee133ac
+4 -1
View File
@@ -30,6 +30,7 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV
// Prefer the XR broadcast mirror (opaque) if active — required during AR passthrough. // Prefer the XR broadcast mirror (opaque) if active — required during AR passthrough.
let stream: MediaStream | null = null; let stream: MediaStream | null = null;
const mirror = getBroadcastSource(); const mirror = getBroadcastSource();
let frameSource: HTMLCanvasElement | null = mirror;
if (mirror && typeof mirror.captureStream === 'function') { if (mirror && typeof mirror.captureStream === 'function') {
stream = mirror.captureStream(24); stream = mirror.captureStream(24);
} }
@@ -38,6 +39,7 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV
if (!stream || stream.getVideoTracks().length === 0) { if (!stream || stream.getVideoTracks().length === 0) {
const canvas = document.querySelector('canvas') as HTMLCanvasElement | null; const canvas = document.querySelector('canvas') as HTMLCanvasElement | null;
if (canvas && typeof canvas.captureStream === 'function') { if (canvas && typeof canvas.captureStream === 'function') {
frameSource = canvas;
stream = canvas.captureStream(30); stream = canvas.captureStream(30);
} }
} }
@@ -51,7 +53,7 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV
} }
streamRef.current = stream; streamRef.current = stream;
const h = await startBroadcast(stream); const h = await startBroadcast(stream, { frameSource });
setHandle(h); setHandle(h);
onHandleChange?.(h); onHandleChange?.(h);
h.onViewerCountChange((n) => { setViewerCount(n); onViewerCountChange?.(n); }); h.onViewerCountChange((n) => { setViewerCount(n); onViewerCountChange?.(n); });
@@ -96,6 +98,7 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV
useEffect(() => { useEffect(() => {
if (!handle) return; if (!handle) return;
const swapTo = (canvas: HTMLCanvasElement | null) => { const swapTo = (canvas: HTMLCanvasElement | null) => {
handle.setFrameSource(canvas);
if (!canvas || typeof canvas.captureStream !== 'function') return; if (!canvas || typeof canvas.captureStream !== 'function') return;
const newStream = canvas.captureStream(24); const newStream = canvas.captureStream(24);
const oldStream = streamRef.current; const oldStream = streamRef.current;