mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2024-11-17 07:39:21 +08:00
commit
f4f9d053b5
@ -97,7 +97,6 @@ var VideoChat = {
|
|||||||
Snackbar.close();
|
Snackbar.close();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
VideoChat.localVideo.srcObject = stream;
|
VideoChat.localVideo.srcObject = stream;
|
||||||
|
|
||||||
// Now we're ready to join the chat room.
|
// Now we're ready to join the chat room.
|
||||||
@ -137,12 +136,11 @@ var VideoChat = {
|
|||||||
VideoChat.remoteVideoWrapper.removeChild(
|
VideoChat.remoteVideoWrapper.removeChild(
|
||||||
document.querySelectorAll(`[uuid="${uuid}"]`)[0]
|
document.querySelectorAll(`[uuid="${uuid}"]`)[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete connection & metadata
|
// Delete connection & metadata
|
||||||
VideoChat.connected.delete(uuid);
|
VideoChat.connected.delete(uuid);
|
||||||
|
VideoChat.peerConnections.get(uuid).close(); // This is necessary, because otherwise the RTC connection isn't closed
|
||||||
VideoChat.peerConnections.delete(uuid);
|
VideoChat.peerConnections.delete(uuid);
|
||||||
dataChannel.delete(uuid);
|
dataChannel.delete(uuid);
|
||||||
|
|
||||||
if (VideoChat.peerConnections.size === 0) {
|
if (VideoChat.peerConnections.size === 0) {
|
||||||
displayWaitingCaption();
|
displayWaitingCaption();
|
||||||
}
|
}
|
||||||
@ -699,7 +697,7 @@ function switchStreamHelper(stream) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Update local video stream
|
// Update local video stream
|
||||||
VideoChat.localStream = videoTrack;
|
VideoChat.localStream = stream;
|
||||||
// Update local video object
|
// Update local video object
|
||||||
VideoChat.localVideo.srcObject = stream;
|
VideoChat.localVideo.srcObject = stream;
|
||||||
// Unpause video on swap
|
// Unpause video on swap
|
||||||
@ -821,39 +819,6 @@ function recieveCaptions(captions) {
|
|||||||
}
|
}
|
||||||
// End Live caption
|
// End Live caption
|
||||||
|
|
||||||
// Translation
|
|
||||||
// function translate(text) {
|
|
||||||
// let fromLang = "en";
|
|
||||||
// let toLang = "zh";
|
|
||||||
// // let text = "hello how are you?";
|
|
||||||
// const API_KEY = "APIKEYHERE";
|
|
||||||
// let gurl = `https://translation.googleapis.com/language/translate/v2?key=${API_KEY}`;
|
|
||||||
// gurl += "&q=" + encodeURI(text);
|
|
||||||
// gurl += `&source=${fromLang}`;
|
|
||||||
// gurl += `&target=${toLang}`;
|
|
||||||
// fetch(gurl, {
|
|
||||||
// method: "GET",
|
|
||||||
// headers: {
|
|
||||||
// "Content-Type": "application/json",
|
|
||||||
// Accept: "application/json",
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// .then((res) => res.json())
|
|
||||||
// .then((response) => {
|
|
||||||
// // console.log("response from google: ", response);
|
|
||||||
// // return response["data"]["translations"][0]["translatedText"];
|
|
||||||
// logIt(response);
|
|
||||||
// var translatedText =
|
|
||||||
// response["data"]["translations"][0]["translatedText"];
|
|
||||||
// console.log(translatedText);
|
|
||||||
// dataChanel.send("cap:" + translatedText);
|
|
||||||
// })
|
|
||||||
// .catch((error) => {
|
|
||||||
// console.log("There was an error with the translation request: ", error);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// End Translation
|
|
||||||
|
|
||||||
// Text Chat
|
// Text Chat
|
||||||
// Add text message to chat screen on page
|
// Add text message to chat screen on page
|
||||||
function addMessageToScreen(msg, border, isOwnMessage) {
|
function addMessageToScreen(msg, border, isOwnMessage) {
|
||||||
|
Loading…
Reference in New Issue
Block a user