diff --git a/app/src/Server.js b/app/src/Server.js
index 554bbd6a..eae2a19e 100644
--- a/app/src/Server.js
+++ b/app/src/Server.js
@@ -34,9 +34,10 @@ dependencies: {
* @link GitHub: https://github.com/miroslavpejic85/mirotalksfu
* @link Live demo: https://sfu.mirotalk.com
* @license For open source use: AGPLv3
- * @license For commercial or closed source, contact us at info.mirotalk@gmail.com
+ * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or buy directly via CodeCanyon
+ * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
- * @version 1.0.0
+ * @version 1.0.1
*
*/
diff --git a/package.json b/package.json
index e7a29cf4..b628cd7c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mirotalksfu",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "WebRTC SFU browser-based video calls",
"main": "Server.js",
"scripts": {
diff --git a/public/css/Room.css b/public/css/Room.css
index c7b4bfeb..e2d2941e 100644
--- a/public/css/Room.css
+++ b/public/css/Room.css
@@ -81,7 +81,8 @@ body {
width: 100%;
height: 100%;
overflow: hidden;
- background: url('../images/background.jpg');
+ /* background: url('../images/background.jpg'); */
+ background: var(--body-bg);
}
/*--------------------------------------------------------------
@@ -97,27 +98,22 @@ body {
}
/*--------------------------------------------------------------
-# Loading...
+# Init User
--------------------------------------------------------------*/
-#loadingDiv {
- color: #fff;
- padding: 30px;
- border-radius: 10px;
- background: transparent;
+.init-user {
+ display: block;
+ padding: 5px;
}
-#loadingDiv h1 {
+
+.init-user select {
+ margin-top: 15px;
padding: 10px;
- font-size: 60px;
- font-family: 'Comfortaa';
- background: rgba(0, 0, 0, 0.7);
- border-radius: 10px;
+ cursor: pointer;
}
-#loadingDiv p {
- padding: 10px;
- font-family: 'Comfortaa';
- background: rgba(0, 0, 0, 0.7);
- border-radius: 10px;
+
+.init-user button {
+ margin-top: 15px;
}
/*--------------------------------------------------------------
diff --git a/public/js/LocalStorage.js b/public/js/LocalStorage.js
new file mode 100644
index 00000000..cc6fffcb
--- /dev/null
+++ b/public/js/LocalStorage.js
@@ -0,0 +1,62 @@
+'use-strict';
+
+class LocalStorage {
+ constructor() {
+ this.MEDIA_TYPE = {
+ audio: 'audio',
+ video: 'video',
+ speaker: 'speaker',
+ };
+
+ this.DEVICES_COUNT = {
+ audio: 0,
+ speaker: 0,
+ video: 0,
+ };
+
+ this.LOCAL_STORAGE_DEVICES = {
+ audio: {
+ count: 0,
+ index: 0,
+ select: null,
+ },
+ speaker: {
+ count: 0,
+ index: 0,
+ select: null,
+ },
+ video: {
+ count: 0,
+ index: 0,
+ select: null,
+ },
+ };
+ }
+
+ setLocalStorageDevices(type, index, select) {
+ switch (type) {
+ case this.MEDIA_TYPE.audio:
+ this.LOCAL_STORAGE_DEVICES.audio.count = this.DEVICES_COUNT.audio;
+ this.LOCAL_STORAGE_DEVICES.audio.index = index;
+ this.LOCAL_STORAGE_DEVICES.audio.select = select;
+ break;
+ case this.MEDIA_TYPE.video:
+ this.LOCAL_STORAGE_DEVICES.video.count = this.DEVICES_COUNT.video;
+ this.LOCAL_STORAGE_DEVICES.video.index = index;
+ this.LOCAL_STORAGE_DEVICES.video.select = select;
+ break;
+ case this.MEDIA_TYPE.speaker:
+ this.LOCAL_STORAGE_DEVICES.speaker.count = this.DEVICES_COUNT.speaker;
+ this.LOCAL_STORAGE_DEVICES.speaker.index = index;
+ this.LOCAL_STORAGE_DEVICES.speaker.select = select;
+ break;
+ default:
+ break;
+ }
+ localStorage.setItem('LOCAL_STORAGE_DEVICES', JSON.stringify(this.LOCAL_STORAGE_DEVICES));
+ }
+
+ getLocalStorageDevices() {
+ return JSON.parse(localStorage.getItem('LOCAL_STORAGE_DEVICES'));
+ }
+}
diff --git a/public/js/Room.js b/public/js/Room.js
index dea4afac..61578fda 100644
--- a/public/js/Room.js
+++ b/public/js/Room.js
@@ -8,9 +8,10 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
* @link GitHub: https://github.com/miroslavpejic85/mirotalksfu
* @link Live demo: https://sfu.mirotalk.com
* @license For open source use: AGPLv3
- * @license For commercial or closed source, contact us at info.mirotalk@gmail.com
+ * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or buy directly via CodeCanyon
+ * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
- * @version 1.0.0
+ * @version 1.0.1
*
*/
@@ -53,6 +54,8 @@ const wbHeight = 600;
const swalImageUrl = '../images/pricing-illustration.svg';
+const lS = new LocalStorage();
+
// ####################################################
// DYNAMIC SETTINGS
// ####################################################
@@ -109,6 +112,8 @@ let isButtonsBarOver = false;
let isRoomLocked = false;
+let initStream = null;
+
// ####################################################
// INIT ROOM
// ####################################################
@@ -223,31 +228,27 @@ function makeId(length) {
async function initEnumerateDevices() {
console.log('01 ----> init Enumerate Devices');
- await initEnumerateAudioDevices();
+ whoAreYou();
await initEnumerateVideoDevices();
+ await initEnumerateAudioDevices();
+ if (!isVideoAllowed) {
+ hide(initVideo);
+ hide(initVideoSelect);
+ }
+ if (!isAudioAllowed) {
+ hide(initMicrophoneSelect);
+ hide(initSpeakerSelect);
+ }
if (!isAudioAllowed && !isVideoAllowed && !joinRoomWithoutAudioVideo) {
openURL(`/permission?room_id=${room_id}&message=Not allowed both Audio and Video`);
} else {
- hide(loadingDiv);
+ setButtonsInit();
+ setSelectsInit();
+ handleSelectsInit();
getPeerGeoLocation();
- whoAreYou();
}
}
-async function initEnumerateAudioDevices() {
- if (isEnumerateAudioDevices) return;
- // allow the audio
- await navigator.mediaDevices
- .getUserMedia({ audio: true })
- .then((stream) => {
- enumerateAudioDevices(stream);
- isAudioAllowed = true;
- })
- .catch(() => {
- isAudioAllowed = false;
- });
-}
-
async function initEnumerateVideoDevices() {
if (isEnumerateVideoDevices) return;
// allow the video
@@ -262,31 +263,6 @@ async function initEnumerateVideoDevices() {
});
}
-function enumerateAudioDevices(stream) {
- console.log('02 ----> Get Audio Devices');
- navigator.mediaDevices
- .enumerateDevices()
- .then((devices) =>
- devices.forEach((device) => {
- let el = null;
- if ('audioinput' === device.kind) {
- el = microphoneSelect;
- RoomClient.DEVICES_COUNT.audio++;
- } else if ('audiooutput' === device.kind) {
- el = speakerSelect;
- RoomClient.DEVICES_COUNT.speaker++;
- }
- if (!el) return;
- addChild(device, el);
- }),
- )
- .then(() => {
- stopTracks(stream);
- isEnumerateAudioDevices = true;
- speakerSelect.disabled = !('sinkId' in HTMLMediaElement.prototype);
- });
-}
-
function enumerateVideoDevices(stream) {
console.log('03 ----> Get Video Devices');
navigator.mediaDevices
@@ -294,12 +270,14 @@ function enumerateVideoDevices(stream) {
.then((devices) =>
devices.forEach((device) => {
let el = null;
+ let eli = null;
if ('videoinput' === device.kind) {
el = videoSelect;
- RoomClient.DEVICES_COUNT.video++;
+ eli = initVideoSelect;
+ lS.DEVICES_COUNT.video++;
}
if (!el) return;
- addChild(device, el);
+ addChild(device, [el, eli]);
}),
)
.then(() => {
@@ -308,17 +286,76 @@ function enumerateVideoDevices(stream) {
});
}
+async function initEnumerateAudioDevices() {
+ if (isEnumerateAudioDevices) return;
+ // allow the audio
+ await navigator.mediaDevices
+ .getUserMedia({ audio: true })
+ .then((stream) => {
+ enumerateAudioDevices(stream);
+ isAudioAllowed = true;
+ })
+ .catch(() => {
+ isAudioAllowed = false;
+ });
+}
+
+function enumerateAudioDevices(stream) {
+ console.log('02 ----> Get Audio Devices');
+ navigator.mediaDevices
+ .enumerateDevices()
+ .then((devices) =>
+ devices.forEach((device) => {
+ let el = null;
+ let eli = null;
+ if ('audioinput' === device.kind) {
+ el = microphoneSelect;
+ eli = initMicrophoneSelect;
+ lS.DEVICES_COUNT.audio++;
+ } else if ('audiooutput' === device.kind) {
+ el = speakerSelect;
+ eli = initSpeakerSelect;
+ lS.DEVICES_COUNT.speaker++;
+ }
+ if (!el) return;
+ addChild(device, [el, eli]);
+ }),
+ )
+ .then(() => {
+ stopTracks(stream);
+ isEnumerateAudioDevices = true;
+ const sinkId = 'sinkId' in HTMLMediaElement.prototype;
+ speakerSelect.disabled = !sinkId;
+ if (!sinkId) hide(initSpeakerSelect);
+ });
+}
+
function stopTracks(stream) {
stream.getTracks().forEach((track) => {
track.stop();
});
}
-function addChild(device, el) {
- let option = document.createElement('option');
- option.value = device.deviceId;
- option.innerText = device.label;
- el.appendChild(option);
+function addChild(device, els) {
+ let kind = device.kind;
+ els.forEach((el) => {
+ let option = document.createElement('option');
+ option.value = device.deviceId;
+ switch (kind) {
+ case 'videoinput':
+ option.innerHTML = `📹 ` + device.label || `📹 camera ${el.length + 1}`;
+ break;
+ case 'audioinput':
+ option.innerHTML = `🎤 ` + device.label || `🎤 microphone ${el.length + 1}`;
+ break;
+ case 'audiooutput':
+ option.innerHTML = `🔈 ` + device.label || `🔈 speaker ${el.length + 1}`;
+ break;
+ default:
+ break;
+ }
+ el.appendChild(option);
+ });
}
// ####################################################
@@ -407,6 +444,7 @@ function getPeerGeoLocation() {
function whoAreYou() {
console.log('04 ----> Who are you');
+ sound('open');
if (peer_name) {
checkMedia();
@@ -420,21 +458,18 @@ function whoAreYou() {
default_name = getCookie(room_id + '_name');
}
+ const initUser = document.getElementById('initUser');
+ initUser.classList.toggle('hidden');
+
Swal.fire({
allowOutsideClick: false,
allowEscapeKey: false,
background: swalBackground,
- imageAlt: 'mirotalksfu-username',
- imageUrl: image.username,
+ title: 'MiroTalk SFU',
input: 'text',
inputPlaceholder: 'Enter your name',
inputValue: default_name,
- html: `
-
Please allow the camera or microphone access to use this app.
-