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.
let stream: MediaStream | null = null;
const mirror = getBroadcastSource();
let frameSource: HTMLCanvasElement | null = mirror;
if (mirror && typeof mirror.captureStream === 'function') {
stream = mirror.captureStream(24);
}
@@ -38,6 +39,7 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV
if (!stream || stream.getVideoTracks().length === 0) {
const canvas = document.querySelector('canvas') as HTMLCanvasElement | null;
if (canvas && typeof canvas.captureStream === 'function') {
frameSource = canvas;
stream = canvas.captureStream(30);
}
}
@@ -51,7 +53,7 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV
}
streamRef.current = stream;
const h = await startBroadcast(stream);
const h = await startBroadcast(stream, { frameSource });
setHandle(h);
onHandleChange?.(h);
h.onViewerCountChange((n) => { setViewerCount(n); onViewerCountChange?.(n); });
@@ -96,6 +98,7 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV
useEffect(() => {
if (!handle) return;
const swapTo = (canvas: HTMLCanvasElement | null) => {
handle.setFrameSource(canvas);
if (!canvas || typeof canvas.captureStream !== 'function') return;
const newStream = canvas.captureStream(24);
const oldStream = streamRef.current;