Fix video 1

This commit is contained in:
Халимов Рустам
2026-03-11 01:42:33 +03:00
parent e0aa5d6b14
commit f40b53247f

View File

@@ -257,15 +257,21 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
if (remoteVideoRef.current.srcObject !== stream) {
console.log('[WebRTC] Binding stream to video element');
remoteVideoRef.current.srcObject = stream;
// Force load to ensure browser picks up streams properly
remoteVideoRef.current.load();
}
// Try to play. If fails, it's usually autoplay policy
remoteVideoRef.current.play().catch(() => {
console.warn('[WebRTC] Autoplay blocked, waiting for interaction');
// Important: we keep trying to play because users often click the UI
const retryPlay = () => {
remoteVideoRef.current?.play().then(() => {
if (!remoteVideoRef.current) return;
remoteVideoRef.current.play().then(() => {
console.log('[WebRTC] Video started after retry');
}).catch(() => setTimeout(retryPlay, 2000));
}).catch(() => {
// If blocked, ensure it's muted and try again
if (remoteVideoRef.current) remoteVideoRef.current.muted = true;
setTimeout(retryPlay, 2000);
});
};
retryPlay();
});
@@ -295,7 +301,7 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
endCallSafe();
}
};
}, [callType, endCallSafe]);
}, [endCallSafe]); // REMOVED callType dependency to prevent handler reset during call
// Start outgoing call
const startCall = useCallback(async () => {