[mirotalksfu] - improvements for mobile

هذا الالتزام موجود في:
Miroslav Pejic
2024-10-21 14:38:46 +02:00
الأصل 12fad5668d
التزام 6d54f0df09

عرض الملف

@@ -10,6 +10,8 @@ console.log('Settings', settings);
const autoJoinRoom = false; // automatically join the guest to the meeting
const intervalTime = 5000; // check room status every 5 seconds
const presenterLoginBtn = document.getElementById('presenterLoginButton');
const guestJoinRoomBtn = document.getElementById('guestJoinRoomButton');
@@ -18,6 +20,7 @@ guestJoinRoomBtn.classList.add('disabled');
const pathParts = window.location.pathname.split('/');
const roomId = filterXSS(pathParts[pathParts.length - 1]);
let intervalId;
let roomActive = false;
presenterLoginBtn.onclick = () => {
@@ -74,4 +77,36 @@ checkRoomStatus(roomId);
mediaQuery.addEventListener('change', handleScreenResize);
setInterval(() => checkRoomStatus(roomId), 5000); // Start checking room status every 5 seconds
function startCheckingRoomStatus() {
// Function to run every 5 seconds
intervalId = setInterval(() => {
if (document.visibilityState === 'visible') {
checkRoomStatus(roomId);
}
}, intervalTime);
}
// Fallback to setTimeout if needed for better control
function fallbackCheckRoomStatus() {
if (document.visibilityState === 'visible') {
checkRoomStatus(roomId);
}
setTimeout(fallbackCheckRoomStatus, intervalTime);
}
// Use Page Visibility API to pause/resume the checks
document.addEventListener('visibilitychange', () => {
checkRoomStatus(roomId);
//
if (document.visibilityState === 'visible') {
console.log('Page is visible. Resuming room status checks.');
if (!intervalId) startCheckingRoomStatus();
} else {
console.log('Page is hidden. Pausing room status checks.');
clearInterval(intervalId);
intervalId = null;
}
});
// Start checking room status when the page is first loaded
startCheckingRoomStatus();