mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2025-02-23 00:15:04 +08:00
pause video, fixed routing, cleanup
This commit is contained in:
parent
72188ae78f
commit
90cd3741e4
@ -22,6 +22,7 @@
|
|||||||
<a href="/landing" class="round-button">Back</a>
|
<a href="/landing" class="round-button">Back</a>
|
||||||
<a class="round-button" onclick="{openFullscreen()}">Fullscreen</a>
|
<a class="round-button" onclick="{openFullscreen()}">Fullscreen</a>
|
||||||
<a class="round-button" onclick="{muteMicrophone()}" id="muteButton">Mute </a>
|
<a class="round-button" onclick="{muteMicrophone()}" id="muteButton">Mute </a>
|
||||||
|
<a class="round-button" onclick="{pauseVideo()}" id="videoPauseButton">Pause </a>
|
||||||
<a class="round-button" onclick="{alert('hangup')}">Share Screen </a>
|
<a class="round-button" onclick="{alert('hangup')}">Share Screen </a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,18 +1,29 @@
|
|||||||
if (window.location.pathname === "/") {
|
if (window.location.pathname === "/") {
|
||||||
// Generate random room name if needed
|
window.location.href = "/landing/newroom";
|
||||||
var adjectives = ["small", "big", "large", "smelly", "new", "happy", "shiny", "old", "clean", "nice", "bad", "cool",
|
|
||||||
"hot", "cold", "warm", "hungry", "slow", "fast", "red", "white", "black", "blue", "green"];
|
|
||||||
var nouns = ["dog", "bat", "wrench", "apple", "pear", "ghost", "cat", "wolf", "squid", "goat", "snail", "hat",
|
|
||||||
"sock", "plum", "bear", "snake", "turtle", "horse", "spoon", "fork", "spider", "tree", "chair", "table",
|
|
||||||
"couch", "towel"];
|
|
||||||
var adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
|
|
||||||
var noun = nouns[Math.floor(Math.random() * nouns.length)];
|
|
||||||
noun = noun.charAt(0).toUpperCase() + noun.substring(1);
|
|
||||||
adjective = adjective.charAt(0).toUpperCase() + adjective.substring(1);
|
|
||||||
window.location.href = window.location.href + adjective + noun;
|
|
||||||
}
|
}
|
||||||
const roomHash = window.location.pathname;
|
const roomHash = window.location.pathname;
|
||||||
|
|
||||||
|
|
||||||
|
var isWebRTCSupported =
|
||||||
|
navigator.getUserMedia ||
|
||||||
|
navigator.webkitGetUserMedia ||
|
||||||
|
navigator.mozGetUserMedia ||
|
||||||
|
navigator.msGetUserMedia ||
|
||||||
|
window.RTCPeerConnection;
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// window.RTCPeerConnection.peerConnection.addStream
|
||||||
|
// } catch (e) {
|
||||||
|
// alert("Your browser doesn't support Neon Chat. Please use Chrome or Firefox.");
|
||||||
|
// window.location.href = "/landing";
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (!isWebRTCSupported) {
|
||||||
|
alert("Your browser doesn't support Neon Chat. Please use Chrome or Firefox.");
|
||||||
|
window.location.href = "/landing";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function logIt(message, error) {
|
function logIt(message, error) {
|
||||||
// console.log(message);
|
// console.log(message);
|
||||||
// Add to logs on page
|
// Add to logs on page
|
||||||
@ -47,7 +58,9 @@ var VideoChat = {
|
|||||||
VideoChat.onMediaStream(stream);
|
VideoChat.onMediaStream(stream);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
VideoChat.noMediaStream(error);
|
console.log(error);
|
||||||
|
logIt('No media stream for us.');
|
||||||
|
alert("Please check your webcam browser privacy settings.")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -58,7 +71,9 @@ var VideoChat = {
|
|||||||
VideoChat.onMediaStream(stream);
|
VideoChat.onMediaStream(stream);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
VideoChat.noMediaStream(error);
|
console.log(error);
|
||||||
|
logIt('No media stream for us.');
|
||||||
|
alert("Please check your screen sharing browser privacy settings.")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -77,15 +92,10 @@ var VideoChat = {
|
|||||||
VideoChat.socket.on('willInitiateCall', () => VideoChat.willInitiateCall = true);
|
VideoChat.socket.on('willInitiateCall', () => VideoChat.willInitiateCall = true);
|
||||||
},
|
},
|
||||||
|
|
||||||
// There's not much to do in this demo if there is no media stream. So let's just stop.
|
|
||||||
noMediaStream: function () {
|
|
||||||
logIt('No media stream for us.');
|
|
||||||
},
|
|
||||||
|
|
||||||
chatRoomFull: function () {
|
chatRoomFull: function () {
|
||||||
alert("Chat room is full. Check to make sure you don't have multiple open tabs, or try with a new room link");
|
alert("Chat room is full. Check to make sure you don't have multiple open tabs, or try with a new room link");
|
||||||
// VideoChat.socket.disconnect()
|
window.location.href = "/landing/newroom";
|
||||||
// todo handle this better
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// When we are ready to call, enable the Call button.
|
// When we are ready to call, enable the Call button.
|
||||||
@ -125,8 +135,7 @@ var VideoChat = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
// When the peerConnection generates an ice candidate, send it over the socket
|
// When the peerConnection generates an ice candidate, send it over the socket to the peer.
|
||||||
// to the peer.
|
|
||||||
onIceCandidate: function (event) {
|
onIceCandidate: function (event) {
|
||||||
console.log("onIceCandidate");
|
console.log("onIceCandidate");
|
||||||
if (event.candidate) {
|
if (event.candidate) {
|
||||||
@ -262,6 +271,20 @@ function muteMicrophone() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pauseVideo() {
|
||||||
|
var muted = !VideoChat.localStream.getAudioTracks()[0].enabled;
|
||||||
|
var videoPaused = !VideoChat.localStream.getVideoTracks()[0].enabled;
|
||||||
|
VideoChat.localStream.getAudioTracks()[0].enabled = muted;
|
||||||
|
VideoChat.localStream.getVideoTracks()[0].enabled = videoPaused;
|
||||||
|
var pausedButton = document.getElementById("videoPauseButton");
|
||||||
|
if (!muted) {
|
||||||
|
pausedButton.innerText = "Unpause"
|
||||||
|
} else {
|
||||||
|
pausedButton.innerText = "Pause"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var timedelay = 1;
|
var timedelay = 1;
|
||||||
|
|
||||||
@ -279,5 +302,4 @@ $(document).mousemove(function () {
|
|||||||
clearInterval(_delay);
|
clearInterval(_delay);
|
||||||
_delay = setInterval(delayCheck, 500);
|
_delay = setInterval(delayCheck, 500);
|
||||||
});
|
});
|
||||||
// page loads starts delay timer
|
|
||||||
_delay = setInterval(delayCheck, 500);
|
_delay = setInterval(delayCheck, 500);
|
||||||
|
@ -16,7 +16,7 @@ app.get('/landing/newroom', function (req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/landing', function (req, res) {
|
app.get('/landing', function (req, res) {
|
||||||
res.sendFile(path.join(public, 'landing/landing2.html'));
|
res.sendFile(path.join(public, 'landing/landing.html'));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/newroom', function (req, res) {
|
app.get('/newroom', function (req, res) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user