Исправить интерфейс видеозвонка

This commit is contained in:
AidarKC
2026-11-30 12:33:29 +03:00
parent 1e52b4dd2a
commit e32d424eda
6 changed files with 73 additions and 88 deletions
+4 -20
View File
@@ -2265,34 +2265,20 @@ async function applyCameraState(call) {
videoTrack.enabled = true;
}
} else {
const blackTrack = ensureBlackVideoTrack(call);
if (hadSlotBefore) {
if (call.localStream && blackTrack) {
const existingVideoTracks = call.localStream.getVideoTracks?.() || [];
existingVideoTracks.forEach((track) => {
if (track.id !== blackTrack.id) {
try { call.localStream.removeTrack(track); } catch {}
}
});
if (!existingVideoTracks.some((track) => track.id === blackTrack.id)) {
call.localStream.addTrack(blackTrack);
}
}
try {
if (videoTransceiver && videoTransceiver.direction !== 'sendrecv') {
videoTransceiver.direction = 'sendrecv';
}
} catch {}
if (videoTransceiver?.sender) {
try { await videoTransceiver.sender.replaceTrack(blackTrack || null); } catch {}
// A black placeholder is still an active video track for the peer and leaves
// its call UI on a black screen. Removing the source makes the remote track
// mute, which restores the regular avatar call stage until video returns.
try { await videoTransceiver.sender.replaceTrack(null); } catch {}
call.videoSender = videoTransceiver.sender;
bindVideoSenderStream(call, videoTransceiver.sender);
await applyVideoSenderEncodingProfile(videoTransceiver.sender, 'placeholder');
}
} else {
if (call.localStream && blackTrack) {
syncLocalStreamVideoTrack(call, blackTrack, { stopRemoved: false });
}
try {
if (videoTransceiver && videoTransceiver.direction !== 'sendrecv') {
videoTransceiver.direction = 'sendrecv';
@@ -2301,8 +2287,6 @@ async function applyCameraState(call) {
if (hadReservedBefore && videoTransceiver?.sender) {
try { await videoTransceiver.sender.replaceTrack(null); } catch {}
call.videoSender = videoTransceiver.sender;
} else if (call.videoTransportMode === VIDEO_TRANSPORT_SLOT && blackTrack) {
await ensureVideoSenderSlot(call, { sourceTrack: blackTrack, profile: 'placeholder' });
}
}
await disableCameraTrack(call);
+8 -5
View File
@@ -166,7 +166,10 @@ function getIconSvg(name) {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="3.5" width="6" height="11" rx="3" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M6 11.5a6 6 0 0 0 7.2 5.88" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M12 17.5v3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M8.5 20.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M5 5l14 14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/></svg>';
}
if (name === 'hangup') {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/></svg>';
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5.1 8.5c3.8-3.1 10-3.1 13.8 0l-2 2.4a1.3 1.3 0 0 1-1.6.3l-1.6-.8a1.3 1.3 0 0 0-1.2 0l-1.6.8a1.3 1.3 0 0 1-1.6-.3z" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"/></svg>';
}
if (name === 'answer') {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5.1 8.5c3.8-3.1 10-3.1 13.8 0l-2 2.4a1.3 1.3 0 0 1-1.6.3l-1.6-.8a1.3 1.3 0 0 0-1.2 0l-1.6.8a1.3 1.3 0 0 1-1.6-.3z" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" transform="rotate(180 12 12)"/></svg>';
}
if (name === 'minimize') {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 6v12M7.5 10.5 12 6l4.5 4.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
@@ -455,16 +458,16 @@ function ensureUi() {
acceptBtn = document.createElement('button');
acceptBtn.type = 'button';
acceptBtn.className = 'call-accept-btn';
acceptBtn.textContent = t('remaining.call_ui.answer');
acceptBtn.className = 'call-call-action-btn call-call-action-btn--accept';
setButtonIcon(acceptBtn, 'answer', t('remaining.call_ui.answer'));
acceptBtn.addEventListener('click', async () => {
await acceptIncomingCall();
});
declineBtn = document.createElement('button');
declineBtn.type = 'button';
declineBtn.className = 'destructive-btn call-decline-btn';
declineBtn.textContent = t('remaining.call_ui.decline');
declineBtn.className = 'call-call-action-btn call-call-action-btn--decline';
setButtonIcon(declineBtn, 'hangup', t('remaining.call_ui.decline'));
declineBtn.addEventListener('click', async () => {
await declineIncomingCall();
});