[call-me] - fix cam

This commit is contained in:
Miroslav Pejic
2025-10-22 08:21:47 +02:00
parent 9643325358
commit 0153e8f36a
3 changed files with 49 additions and 3 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "call-me",
"version": "1.2.68",
"version": "1.2.69",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "call-me",
"version": "1.2.68",
"version": "1.2.69",
"license": "AGPLv3",
"dependencies": {
"@ngrok/ngrok": "1.5.2",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "call-me",
"version": "1.2.68",
"version": "1.2.69",
"description": "Your Go-To for Instant Video Calls",
"author": "Miroslav Pejic - miroslav.pejic.85@gmail.com",
"license": "AGPLv3",
+46
View File
@@ -901,6 +901,21 @@ function refreshLocalVideoStream(newStream) {
return;
}
// Preserve previous video enabled state (if the user had video disabled)
let wasVideoEnabled = true;
try {
if (stream && stream.getVideoTracks().length > 0) {
wasVideoEnabled = stream.getVideoTracks()[0].enabled;
} else if (videoBtn && videoBtn.classList.contains('btn-danger')) {
wasVideoEnabled = false;
}
} catch (e) {
console.warn('Could not determine previous video enabled state:', e);
}
// Apply preserved enabled state to new track
videoTrack.enabled = wasVideoEnabled;
const audioTrack = stream.getAudioTracks()[0];
if (!audioTrack) {
handleError('No audio track available in the stream.');
@@ -916,6 +931,15 @@ function refreshLocalVideoStream(newStream) {
localVideo.classList.add('camera-feed');
localVideo.classList.remove('screen-share');
// Reflect video state in UI and overlays
if (wasVideoEnabled) {
videoBtn && videoBtn.classList.remove('btn-danger');
showCameraOffOverlay('local', false);
} else {
videoBtn && videoBtn.classList.add('btn-danger');
showCameraOffOverlay('local', true);
}
handleVideoMirror(localVideo, stream);
}
@@ -2109,6 +2133,16 @@ async function updateVideoStream() {
throw new Error('No video track found in new stream');
}
// Preserve previous video enabled state
let wasVideoEnabled = true;
if (stream && stream.getVideoTracks().length > 0) {
wasVideoEnabled = stream.getVideoTracks()[0].enabled;
} else if (videoBtn && videoBtn.classList.contains('btn-danger')) {
wasVideoEnabled = false;
}
// Apply preserved enabled state to new track
videoTrack.enabled = wasVideoEnabled;
// Update peer connection if it exists
if (thisConnection) {
const sender = thisConnection.getSenders().find((s) => s.track && s.track.kind === 'video');
@@ -2134,6 +2168,18 @@ async function updateVideoStream() {
localVideo.srcObject = stream;
handleVideoMirror(localVideo, stream);
}
// Reflect video state in UI and overlays
if (wasVideoEnabled) {
videoBtn && videoBtn.classList.remove('btn-danger');
showCameraOffOverlay('local', false);
} else {
videoBtn && videoBtn.classList.add('btn-danger');
showCameraOffOverlay('local', true);
}
// Notify server about media status change so remote user is aware
sendMediaStatusToServer();
}
// Stop other tracks from the temporary stream