Skip to content

Commit

Permalink
[mirotalksfu] - improve VideoAI
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jul 5, 2024
1 parent c61c99e commit 23747fa
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies: {
* @license For commercial or closed source, contact us at [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.4.85
* @version 1.4.86
*
*/

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions public/js/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.4.85
* @version 1.4.86
*
*/

Expand Down Expand Up @@ -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: `
<br />
<div id="about">
Expand Down
62 changes: 61 additions & 1 deletion public/js/RoomClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.4.85
* @version 1.4.86
*
*/

Expand Down Expand Up @@ -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');
Expand All @@ -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', {
Expand Down

0 comments on commit 23747fa

Please sign in to comment.