Тест 2

This commit is contained in:
Халимов Рустам
2026-03-11 16:48:09 +03:00
parent 820a7bec6a
commit 4f4813c403
+23 -8
View File
@@ -291,15 +291,25 @@ 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;
remoteVideoRef.current.load();
} }
// Important: Unmute for remote audio to work
remoteVideoRef.current.muted = false; // Ensure not muted for remote audio
if (remoteVideoRef.current.muted) {
remoteVideoRef.current.muted = false;
}
remoteVideoRef.current.play() remoteVideoRef.current.play()
.then(() => setNeedsInteraction(false)) .then(() => {
console.log('[WebRTC] Playback started successfully');
setNeedsInteraction(false);
})
.catch(e => { .catch(e => {
console.warn('[WebRTC] Play failed, waiting for user interaction:', e); if (e.name === 'NotAllowedError' || e.name === 'NotSupportedError') {
setNeedsInteraction(true); console.warn('[WebRTC] Autoplay blocked, waiting for interaction');
setNeedsInteraction(true);
} else {
console.warn('[WebRTC] Playback failed (non-autoplay error):', e);
}
}); });
} }
@@ -1621,9 +1631,14 @@ export default function CallModal({ isOpen, onClose, targetUser, callType: initi
<button <button
onClick={() => { onClick={() => {
if (remoteVideoRef.current) { if (remoteVideoRef.current) {
remoteVideoRef.current.muted = false;
remoteVideoRef.current.play() remoteVideoRef.current.play()
.then(() => setNeedsInteraction(false)) .then(() => {
.catch(console.error); setNeedsInteraction(false);
})
.catch(err => {
console.error('[WebRTC] Manual play failed:', err);
});
} }
}} }}
className="px-6 py-3 rounded-full bg-vortex-500 hover:bg-vortex-600 text-white font-bold shadow-2xl transition-all hover:scale-105 flex items-center gap-2" className="px-6 py-3 rounded-full bg-vortex-500 hover:bg-vortex-600 text-white font-bold shadow-2xl transition-all hover:scale-105 flex items-center gap-2"