From 23747fa75dc22ac83793d57668fc5a0cb068ee09 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Fri, 5 Jul 2024 23:26:02 +0200 Subject: [PATCH] [mirotalksfu] - improve VideoAI --- app/src/Server.js | 2 +- package.json | 2 +- public/js/Room.js | 4 +-- public/js/RoomClient.js | 62 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/app/src/Server.js b/app/src/Server.js index 728c5d72..fde8275a 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -44,7 +44,7 @@ dependencies: { * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase 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.4.85 + * @version 1.4.86 * */ diff --git a/package.json b/package.json index a7ab5bb5..b8cbe850 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalksfu", - "version": "1.4.85", + "version": "1.4.86", "description": "WebRTC SFU browser-based video calls", "main": "Server.js", "scripts": { diff --git a/public/js/Room.js b/public/js/Room.js index 9885a733..4ce19475 100644 --- a/public/js/Room.js +++ b/public/js/Room.js @@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase 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.4.85 + * @version 1.4.86 * */ @@ -4092,7 +4092,7 @@ function showAbout() { imageUrl: image.about, customClass: { image: 'img-about' }, position: 'center', - title: 'WebRTC SFU v1.4.85', + title: 'WebRTC SFU v1.4.86', html: `
diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index 8146a879..2459e575 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -9,7 +9,7 @@ * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase 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.4.85 + * @version 1.4.86 * */ @@ -7336,6 +7336,14 @@ class RoomClient { this.startRendering(); + if (!this.isMobileDevice) { + // Handle desktop or non-mobile device + this.handleDesktopChat(); + } else { + // Handle mobile device + this.handleMobileChat(); + } + VideoAI.active = true; this.userLog('info', 'Video AI streaming started', 'top-end'); @@ -7344,6 +7352,58 @@ class RoomClient { } } + // Method for handling desktop or non-mobile device chat logic + handleDesktopChat() { + if (!this.isChatOpen) { + this.toggleChat(); + } + this.sendMessageToVideoAi(); + } + + // Method for handling mobile device chat logic + handleMobileChat() { + if (this.videoMediaContainer.childElementCount <= 2) { + isHideMeActive = !isHideMeActive; + this.handleHideMe(); + } + setTimeout(() => { + this.streamingTask( + `Welcome to ${BRAND.app.name}! Please Open the Chat and navigate to the ChatGPT section. Feel free to ask me any questions you have.`, + ); + }, 2000); + } + + sendMessageToVideoAi() { + const tasks = [ + { delay: 1000, action: () => this.chatPin() }, + { delay: 1200, action: () => this.toggleShowParticipants() }, + { delay: 1400, action: () => this.showPeerAboutAndMessages('ChatGPT', 'ChatGPT') }, + { delay: 1600, action: () => this.streamingTask(`Welcome to ${BRAND.app.name}!`) }, + { + delay: 2000, + action: () => { + chatMessage.value = 'Hello!'; + this.sendMessage(); + }, + }, + ]; + this.executeTasksSequentially(tasks); + } + + executeTasksSequentially(tasks) { + tasks.reduce((promise, task) => { + return promise.then( + () => + new Promise((resolve) => { + setTimeout(() => { + task.action(); + resolve(); + }, task.delay); + }), + ); + }, Promise.resolve()); + } + streamingTask(message) { if (VideoAI.enabled && VideoAI.active && message) { const response = this.socket.request('streamingTask', {