Skip to content

Commit

Permalink
[mirotalkc2c] - refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jan 8, 2025
1 parent d24eb75 commit 25f777c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For private project or commercial purposes contact us at: license.mirotalk@gmail.com or purchase it directly via Code Canyon:
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.1.56
* @version 1.1.57
*/

require('dotenv').config();
Expand Down
26 changes: 10 additions & 16 deletions frontend/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For private project or commercial purposes contact us at: license.mirotalk@gmail.com or purchase it directly via Code Canyon:
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.1.56
* @version 1.1.57
*/

const roomId = new URLSearchParams(window.location.search).get('room');
Expand Down Expand Up @@ -148,21 +148,22 @@ const chatInputEmoji = {
':J': '🥴',
};

const parser = new UAParser();
const isWebRTCSupported = checkWebRTCSupported();
const userAgent = navigator.userAgent;
const parser = new UAParser(userAgent);
const result = parser.getResult();
const deviceType = result.device.type || 'desktop';
const isMobileDevice = deviceType === 'mobile';
const isTabletDevice = deviceType === 'tablet';
const isIPadDevice = result.device.model?.toLowerCase() === 'ipad';
const isDesktopDevice = deviceType === 'desktop';
const osName = result.os.name;
const osVersion = result.os.version;
const browserName = result.browser.name;
const browserVersion = result.browser.version;
const isFirefox = browserName === 'Firefox';
const isFirefox = browserName.toLowerCase().includes('firefox');

let userAgent;
let isWebRTCSupported = false;
let isVideoPIPSupported = document.pictureInPictureEnabled;
let isMobileDevice = false;
let isTabletDevice = false;
let isIPadDevice = false;
let isDesktopDevice = false;
let isCamMirrored = false;
let myVideoChange = false;
let isVideoStreaming = true;
Expand Down Expand Up @@ -237,17 +238,10 @@ function initClient() {
console.log('RoomURL', roomURL);
console.log('Location', window.location);

isWebRTCSupported = IsSupportedWebRTC();
if (!isWebRTCSupported) {
return popupMessage('warning', 'WebRTC', 'This browser seems not supported WebRTC!');
}

userAgent = navigator.userAgent.toLowerCase();
isMobileDevice = isMobile(userAgent);
isTabletDevice = isTablet(userAgent);
isIPadDevice = isIpad(userAgent);
isDesktopDevice = isDesktop();

tooltips.forEach(({ element, text, position }) => {
setTippy(element, text, position);
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function openURL(url, blank = false) {
blank ? window.open(url, '_blank') : (window.location.href = url);
}

function IsSupportedWebRTC() {
function checkWebRTCSupported() {
let isWebRTCSupported = false;
['RTCPeerConnection', 'webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].forEach(function (item) {
if (isWebRTCSupported) return;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalkc2c",
"version": "1.1.56",
"version": "1.1.57",
"description": "A free WebRTC Cam-2-Cam browser-based video calls",
"main": "server.js",
"scripts": {
Expand Down

0 comments on commit 25f777c

Please sign in to comment.