[mirotalksfu] - add screen query param

هذا الالتزام موجود في:
Miroslav Pejic
2022-05-20 21:40:11 +02:00
الأصل 94a2d85908
التزام 9d8b2f31ac
9 ملفات معدلة مع 82 إضافات و9 حذوفات

عرض الملف

@@ -43,9 +43,9 @@ let isEnumerateAudioDevices = false;
let isEnumerateVideoDevices = false;
let isAudioAllowed = false;
let isVideoAllowed = false;
let isScreenAllowed = getScreen();
let isAudioVideoAllowed = false;
let joinRoomWithoutAudioVideo = true;
let isScreenAllowed = false;
let initAudioButton = null;
let initVideoButton = null;
let initAudioVideoButton = null;
@@ -252,10 +252,23 @@ function appenChild(device, el) {
// API CHECK
// ####################################################
function getScreen() {
let qs = new URLSearchParams(window.location.search);
let screen = qs.get('screen');
if (screen) {
screen = screen.toLowerCase();
let queryScreen = screen === '1' || screen === 'true';
if (queryScreen != null && (navigator.getDisplayMedia || navigator.mediaDevices.getDisplayMedia))
return queryScreen;
}
return false;
}
function getNotify() {
let qs = new URLSearchParams(window.location.search);
let notify = qs.get('notify');
if (notify) {
notify = notify.toLowerCase();
let queryNotify = notify === '1' || notify === 'true';
if (queryNotify != null) return queryNotify;
}
@@ -460,6 +473,10 @@ async function shareRoom(useNavigator = false) {
};
shareRoomByEmail(message);
}
// share screen on join
if (isScreenAllowed) {
rc.shareScreen();
}
});
makeRoomQR();
}
@@ -518,6 +535,7 @@ function joinRoom(peer_name, room_id) {
peer_info,
isAudioAllowed,
isVideoAllowed,
isScreenAllowed,
roomIsReady,
);
handleRoomClientEvents();

عرض الملف

@@ -81,6 +81,7 @@ class RoomClient {
peer_info,
isAudioAllowed,
isVideoAllowed,
isScreenAllowed,
successCallback,
) {
this.remoteAudioEl = remoteAudioEl;
@@ -96,6 +97,7 @@ class RoomClient {
this.isAudioAllowed = isAudioAllowed;
this.isVideoAllowed = isVideoAllowed;
this.isScreenAllowed = isScreenAllowed;
this.producerTransport = null;
this.consumerTransport = null;
this.device = null;
@@ -242,7 +244,15 @@ class RoomClient {
}
this.refreshParticipantsCount();
console.log('Participants Count:', participantsCount);
notify && participantsCount == 1 ? shareRoom() : sound('joined');
// notify && participantsCount == 1 ? shareRoom() : sound('joined');
if (notify && participantsCount == 1) {
shareRoom();
} else {
if (this.isScreenAllowed) {
this.shareScreen();
}
sound('joined');
}
}
async loadDevice(routerRtpCapabilities) {
@@ -563,6 +573,9 @@ class RoomClient {
this.setVideoOff(this.peer_info, false);
this.sendVideoOff();
}
// if (this.isScreenAllowed) {
// this.shareScreen();
// }
}
// ####################################################
@@ -1231,6 +1244,42 @@ class RoomClient {
}
}
// ####################################################
// SHARE SCREEN ON JOIN
// ####################################################
shareScreen() {
if (!this.isMobileDevice && (navigator.getDisplayMedia || navigator.mediaDevices.getDisplayMedia)) {
this.sound('open');
// startScreenButton.click(); // Chrome - Opera - Edge - Brave
// handle error: getDisplayMedia requires transient activation from a user gesture on Safari - FireFox
Swal.fire({
background: swalBackground,
position: 'center',
icon: 'question',
text: 'Do you want to share your screen?',
showDenyButton: true,
confirmButtonText: `Yes`,
denyButtonText: `No`,
showClass: {
popup: 'animate__animated animate__fadeInDown',
},
hideClass: {
popup: 'animate__animated animate__fadeOutUp',
},
}).then((result) => {
if (result.isConfirmed) {
startScreenButton.click();
console.log('10 ----> Screen is on');
} else {
console.log('10 ----> Screen is on');
}
});
} else {
console.log('10 ----> Screen is off');
}
}
// ####################################################
// EXIT ROOM
// ####################################################