Fix video 1
This commit is contained in:
@@ -257,15 +257,21 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
|
|||||||
if (remoteVideoRef.current.srcObject !== stream) {
|
if (remoteVideoRef.current.srcObject !== stream) {
|
||||||
console.log('[WebRTC] Binding stream to video element');
|
console.log('[WebRTC] Binding stream to video element');
|
||||||
remoteVideoRef.current.srcObject = stream;
|
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
|
// Try to play. If fails, it's usually autoplay policy
|
||||||
remoteVideoRef.current.play().catch(() => {
|
remoteVideoRef.current.play().catch(() => {
|
||||||
console.warn('[WebRTC] Autoplay blocked, waiting for interaction');
|
console.warn('[WebRTC] Autoplay blocked, waiting for interaction');
|
||||||
// Important: we keep trying to play because users often click the UI
|
|
||||||
const retryPlay = () => {
|
const retryPlay = () => {
|
||||||
remoteVideoRef.current?.play().then(() => {
|
if (!remoteVideoRef.current) return;
|
||||||
|
remoteVideoRef.current.play().then(() => {
|
||||||
console.log('[WebRTC] Video started after retry');
|
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();
|
retryPlay();
|
||||||
});
|
});
|
||||||
@@ -295,7 +301,7 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
|
|||||||
endCallSafe();
|
endCallSafe();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [callType, endCallSafe]);
|
}, [endCallSafe]); // REMOVED callType dependency to prevent handler reset during call
|
||||||
|
|
||||||
// Start outgoing call
|
// Start outgoing call
|
||||||
const startCall = useCallback(async () => {
|
const startCall = useCallback(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user