[mirotalksfu] - add Rules Presenter/Guest

هذا الالتزام موجود في:
Miroslav Pejic
2022-08-19 09:33:25 +02:00
الأصل 4b9667864d
التزام abfdba076b
5 ملفات معدلة مع 117 إضافات و65 حذوفات

عرض الملف

@@ -14,50 +14,6 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
*
*/
// ####################################################
// SHOW HIDE DESIRED BUTTONS
// ####################################################
const BUTTONS = {
main: {
shareButton: true,
startAudioButton: true,
startVideoButton: true,
startScreenButton: true,
swapCameraButton: true,
chatButton: true,
whiteboardButton: true,
settingsButton: true,
aboutButton: true, // Please keep me always visible, thank you!
exitButton: true,
},
producerVideo: {
fullScreenButton: true,
snapShotButton: true,
muteAudioButton: true,
},
consumerVideo: {
fullScreenButton: true,
snapShotButton: true,
sendMessageButton: true,
sendFileButton: true,
sendVideoButton: true,
muteVideoButton: true,
muteAudioButton: true,
audioVolumeInput: true,
ejectButton: true,
},
videoOff: {
sendMessageButton: true,
sendFileButton: true,
sendVideoButton: true,
muteAudioButton: true,
audioVolumeInput: true,
ejectButton: true,
},
//...
};
// ####################################################
// STATIC SETTINGS
// ####################################################
@@ -672,7 +628,7 @@ function roomIsReady() {
rc.makeDraggable(sendFileDiv, imgShareSend);
rc.makeDraggable(receiveFileDiv, imgShareReceive);
if (navigator.getDisplayMedia || navigator.mediaDevices.getDisplayMedia) {
show(startScreenButton);
BUTTONS.main.startScreenButton && show(startScreenButton);
}
}
if (DetectRTC.browser.name != 'Safari') {
@@ -687,8 +643,8 @@ function roomIsReady() {
isAudioAllowed ? show(stopAudioButton) : BUTTONS.main.startAudioButton && show(startAudioButton);
isVideoAllowed ? show(stopVideoButton) : BUTTONS.main.startVideoButton && show(startVideoButton);
show(fileShareButton);
show(participantsButton);
show(lockRoomButton);
BUTTONS.settings.participantsButton && show(participantsButton);
BUTTONS.settings.lockRoomButton && show(lockRoomButton);
BUTTONS.main.aboutButton && show(aboutButton);
handleButtons();
handleSelects();
@@ -1691,7 +1647,8 @@ async function getParticipantsTable(peers) {
<th></th>
</tr>`;
table += `
if (!isRulesActive || isPresenter) {
table += `
<tr>
<td>&nbsp;<i class="fas fa-users fa-lg"></i>&nbsp;&nbsp;all</td>
<td><button id="muteAllButton" onclick="rc.peerAction('me','${rc.peer_id}','mute',true,true)">${_PEER.audioOff}</button></td>
@@ -1703,6 +1660,7 @@ async function getParticipantsTable(peers) {
<td><button id="ejectAllButton" onclick="rc.peerAction('me','${rc.peer_id}','eject',true,true)">${_PEER.ejectPeer}</button></td>
</tr>
`;
}
for (let peer of Array.from(peers.keys())) {
let peer_info = peers.get(peer).peer_info;
@@ -1729,18 +1687,33 @@ async function getParticipantsTable(peers) {
</tr>
`;
} else {
table += `
<tr id='${peer_id}'>
<td><img src='${avatarImg}'>&nbsp;&nbsp;${peer_name}</td>
<td><button id='${peer_id}___pAudio' onclick="rc.peerAction('me',this.id,'mute')">${peer_audio}</button></td>
<td><button id='${peer_id}___pVideo' onclick="rc.peerAction('me',this.id,'hide')">${peer_video}</button></td>
<td><button>${peer_hand}</button></td>
<td><button id='${peer_id}___shareFile' onclick="rc.selectFileToShare(this.id)">${peer_sendFile}</button></td>
<td><button id="${peer_id}___sendMessageTo" onclick="rc.sendMessageTo('${peer_id}','${peer_name}')">${peer_sendMsg}</button></td>
<td><button id="${peer_id}___sendVideoTo" onclick="rc.shareVideo('${peer_id}');">${_PEER.sendVideo}</button></td>
<td><button id='${peer_id}___pEject' onclick="rc.peerAction('me',this.id,'eject')">${peer_eject}</button></td>
</tr>
`;
if (isRulesActive && isPresenter) {
table += `
<tr id='${peer_id}'>
<td><img src='${avatarImg}'>&nbsp;&nbsp;${peer_name}</td>
<td><button id='${peer_id}___pAudio' onclick="rc.peerAction('me',this.id,'mute')">${peer_audio}</button></td>
<td><button id='${peer_id}___pVideo' onclick="rc.peerAction('me',this.id,'hide')">${peer_video}</button></td>
<td><button>${peer_hand}</button></td>
<td><button id='${peer_id}___shareFile' onclick="rc.selectFileToShare(this.id)">${peer_sendFile}</button></td>
<td><button id="${peer_id}___sendMessageTo" onclick="rc.sendMessageTo('${peer_id}','${peer_name}')">${peer_sendMsg}</button></td>
<td><button id="${peer_id}___sendVideoTo" onclick="rc.shareVideo('${peer_id}');">${_PEER.sendVideo}</button></td>
<td><button id='${peer_id}___pEject' onclick="rc.peerAction('me',this.id,'eject')">${peer_eject}</button></td>
</tr>
`;
} else {
table += `
<tr id='${peer_id}'>
<td><img src='${avatarImg}'>&nbsp;&nbsp;${peer_name}</td>
<td><button id='${peer_id}___pAudio'>${peer_audio}</button></td>
<td><button id='${peer_id}___pVideo'>${peer_video}</button></td>
<td><button>${peer_hand}</button></td>
<td><button id='${peer_id}___shareFile' onclick="rc.selectFileToShare(this.id)">${peer_sendFile}</button></td>
<td><button id="${peer_id}___sendMessageTo" onclick="rc.sendMessageTo('${peer_id}','${peer_name}')">${peer_sendMsg}</button></td>
<td><button id="${peer_id}___sendVideoTo" onclick="rc.shareVideo('${peer_id}');">${_PEER.sendVideo}</button></td>
<td></td>
</tr>
`;
}
}
}
table += `</table>`;

عرض الملف

@@ -275,6 +275,8 @@ class RoomClient {
async handleRoomInfo(room) {
let peers = new Map(JSON.parse(room.peers));
participantsCount = peers.size;
isPresenter = participantsCount > 1 ? false : true;
handleRules(isPresenter);
adaptAspectRatio(participantsCount);
for (let peer of Array.from(peers.keys()).filter((id) => id !== this.peer_id)) {
let peer_info = peers.get(peer).peer_info;
@@ -284,7 +286,7 @@ class RoomClient {
}
}
this.refreshParticipantsCount();
console.log('Participants Count:', participantsCount);
console.log('06.2 Participants Count ---->', participantsCount);
// notify && participantsCount == 1 ? shareRoom() : sound('joined');
if (notify && participantsCount == 1) {
shareRoom();
@@ -1207,8 +1209,10 @@ class RoomClient {
pm.appendChild(pb);
BUTTONS.consumerVideo.ejectButton && vb.appendChild(ko);
BUTTONS.consumerVideo.audioVolumeInput && vb.appendChild(pv);
BUTTONS.consumerVideo.muteAudioButton && vb.appendChild(au);
BUTTONS.consumerVideo.muteVideoButton && vb.appendChild(cm);
// BUTTONS.consumerVideo.muteAudioButton && vb.appendChild(au);
// BUTTONS.consumerVideo.muteVideoButton && vb.appendChild(cm);
vb.appendChild(au);
vb.appendChild(cm);
BUTTONS.consumerVideo.sendVideoButton && vb.appendChild(sv);
BUTTONS.consumerVideo.sendFileButton && vb.appendChild(sf);
BUTTONS.consumerVideo.sendMessageButton && vb.appendChild(sm);
@@ -1227,8 +1231,8 @@ class RoomClient {
this.handleSF(sf.id);
this.handleSM(sm.id, peer_name);
this.handleSV(sv.id);
this.handleCM(cm.id);
this.handleAU(au.id);
BUTTONS.consumerVideo.muteVideoButton && this.handleCM(cm.id);
BUTTONS.consumerVideo.muteAudioButton && this.handleAU(au.id);
this.handlePV(id + '___' + pv.id);
this.handleKO(ko.id);
this.popupPeerInfo(p.id, peer_info);

72
public/js/Rules.js Normal file
عرض الملف

@@ -0,0 +1,72 @@
'use-strict';
let isPresenter = false;
// ####################################################
// SHOW HIDE DESIRED BUTTONS BY RULES
// ####################################################
const isRulesActive = true;
const BUTTONS = {
main: {
shareButton: true,
startAudioButton: true,
startVideoButton: true,
startScreenButton: true,
swapCameraButton: true,
chatButton: true,
whiteboardButton: true,
settingsButton: true,
aboutButton: true, // Please keep me always visible, thank you!
exitButton: true,
},
settings: {
lockRoomButton: true,
participantsButton: true,
},
producerVideo: {
fullScreenButton: true,
snapShotButton: true,
muteAudioButton: true,
},
consumerVideo: {
fullScreenButton: true,
snapShotButton: true,
sendMessageButton: true,
sendFileButton: true,
sendVideoButton: true,
muteVideoButton: true,
muteAudioButton: true,
audioVolumeInput: true,
ejectButton: true,
},
videoOff: {
sendMessageButton: true,
sendFileButton: true,
sendVideoButton: true,
muteAudioButton: true,
audioVolumeInput: true,
ejectButton: true,
},
//...
};
function handleRules(isPresenter) {
console.log('06.1 ----> IsPresenter: ' + isPresenter);
if (!isRulesActive) return;
if (!isPresenter) {
BUTTONS.settings.lockRoomButton = false;
BUTTONS.videoOff.muteAudioButton = false;
BUTTONS.videoOff.ejectButton = false;
BUTTONS.consumerVideo.ejectButton = false;
BUTTONS.consumerVideo.muteAudioButton = false;
BUTTONS.consumerVideo.muteVideoButton = false;
handleNotPresenterButtons();
}
}
function handleNotPresenterButtons() {
// main. settings.
BUTTONS.settings.lockRoomButton ? show(lockRoomButton) : hide(lockRoomButton);
}