Skip to content

Commit

Permalink
[call-me] - add toggle audio/video stream
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jan 4, 2025
1 parent 114bf64 commit 6a3403b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "call-me",
"version": "1.0.39",
"version": "1.0.40",
"description": "Your Go-To for Instant Video Calls",
"author": "Miroslav Pejic - miroslav.pejic.85@gmail.com",
"license": "AGPLv3",
Expand Down
20 changes: 19 additions & 1 deletion public/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ const usernameIn = document.getElementById('usernameIn');
const signInBtn = document.getElementById('signInBtn');
const roomPage = document.getElementById('roomPage');
const callUsernameIn = document.getElementById('callUsernameIn');
const callBtn = document.getElementById('callBtn');
const hideBtn = document.getElementById('hideBtn');
const callBtn = document.getElementById('callBtn');
const videoBtn = document.getElementById('videoBtn');
const audioBtn = document.getElementById('audioBtn');
const hangUpBtn = document.getElementById('hangUpBtn');
const localVideoContainer = document.getElementById('localVideoContainer');
const localVideo = document.getElementById('localVideo');
Expand Down Expand Up @@ -281,6 +283,8 @@ function handleListeners() {
// Event listeners
signInBtn.addEventListener('click', handleSignInClick);
callBtn.addEventListener('click', handleCallClick);
videoBtn.addEventListener('click', handleVideoClick);
audioBtn.addEventListener('click', handleAudioClick);
hideBtn.addEventListener('click', toggleLocalVideo);
hangUpBtn.addEventListener('click', handleHangUpClick);
localVideoContainer.addEventListener('click', toggleFullScreen);
Expand Down Expand Up @@ -332,6 +336,20 @@ function handleCallClick() {
}
}

// Toggle video stream
function handleVideoClick() {
const videoTrack = stream.getVideoTracks()[0];
videoTrack.enabled = !videoTrack.enabled;
videoBtn.classList.toggle('btn-danger');
}

// Toggle audio stream
function handleAudioClick() {
const audioTrack = stream.getAudioTracks()[0];
audioTrack.enabled = !audioTrack.enabled;
audioBtn.classList.toggle('btn-danger');
}

// Toggle local video visibility
function toggleLocalVideo() {
localVideoContainer.classList.toggle('hide');
Expand Down
20 changes: 20 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@
>
<i class="fas fa-phone"></i>
</button>
<!-- Button to toggle video stream -->
<button
id="videoBtn"
class="btn btn-custom btn-success btn-m"
data-toggle="tooltip"
data-placement="top"
title="Toggle video"
>
<i class="fas fa-video"></i>
</button>
<!-- Button to toggle audio stream -->
<button
id="audioBtn"
class="btn btn-custom btn-success btn-m"
data-toggle="tooltip"
data-placement="top"
title="Toggle audio"
>
<i class="fas fa-microphone"></i>
</button>
<!-- Button to hang up the call -->
<button
id="hangUpBtn"
Expand Down
4 changes: 4 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,7 @@ input {
::-webkit-scrollbar-track {
background: #1a1b1f;
}

.red {
background: red !important;
}

0 comments on commit 6a3403b

Please sign in to comment.