Проверка

This commit is contained in:
Халимов Рустам
2026-03-11 16:31:32 +03:00
parent 926482861f
commit 0f89b21dd4
3 changed files with 34 additions and 18 deletions

View File

@@ -285,12 +285,18 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
});
}
// Handle audio via stable audio element
if (remoteAudioRef.current) {
if (remoteAudioRef.current.srcObject !== stream) {
remoteAudioRef.current.srcObject = stream;
// Handle remote media via the remoteVideoRef
if (remoteVideoRef.current) {
if (remoteVideoRef.current.srcObject !== stream) {
console.log('[WebRTC] Binding stream to video element');
remoteVideoRef.current.srcObject = stream;
remoteVideoRef.current.load();
}
remoteAudioRef.current.play().catch(e => console.warn('[WebRTC] Audio play failed:', e));
// Important: Unmute for remote audio to work
remoteVideoRef.current.muted = false;
remoteVideoRef.current.play().catch(e => {
console.warn('[WebRTC] Play failed, waiting for user interaction:', e);
});
}
track.onunmute = checkVideo;
@@ -309,6 +315,10 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
endCallSafe();
}
};
pc.oniceconnectionstatechange = () => {
console.log('[WebRTC] ICE Connection state:', pc.iceConnectionState);
};
}, [endCallSafe]); // REMOVED callType dependency to prevent handler reset during call
// Start outgoing call
@@ -1429,7 +1439,7 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
return (
<AnimatePresence>
<audio key="remote-audio" ref={remoteAudioRef} autoPlay playsInline />
{/* Remote audio is handled by the video element below */}
{/* === MINIMIZED VIEW === */}
{isMinimized && callState === 'connected' ? (
@@ -1577,7 +1587,6 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
ref={remoteVideoRef}
autoPlay
playsInline
muted
className={`
bg-black transition-all duration-500
${showVideoArea