From 5676cfbd2c0fdc0e9f379067c0ea9aaa06b4cf5a Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Thu, 7 Nov 2024 20:12:13 +0100 Subject: [PATCH] [mirotalksfu] - #180 start shared media on join room --- app/src/Room.js | 12 ++++++++++++ app/src/Server.js | 4 +++- package.json | 2 +- public/js/Room.js | 4 ++-- public/js/RoomClient.js | 19 ++++++++++++++----- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/src/Room.js b/app/src/Room.js index acf53b2b..402dda3f 100644 --- a/app/src/Room.js +++ b/app/src/Room.js @@ -67,6 +67,9 @@ module.exports = class Room { this.polls = []; this.isHostProtected = config.host.protected; + + // Share Media + this.shareMediaData = {}; } // #################################################### @@ -95,10 +98,19 @@ module.exports = class Room { redirect: this.redirect, videoAIEnabled: this.videoAIEnabled, thereIsPolls: this.thereIsPolls(), + shareMediaData: this.shareMediaData, peers: JSON.stringify([...this.peers]), }; } + // ############################################## + // SHARE MEDIA + // ############################################## + + updateShareMedia(data) { + this.shareMediaData = data; + } + // ############################################## // POLLS // ############################################## diff --git a/app/src/Server.js b/app/src/Server.js index e0765430..da96ed4f 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -55,7 +55,7 @@ dev 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.6.25 + * @version 1.6.26 * */ @@ -2086,6 +2086,8 @@ function startServer() { const room = getRoom(socket); + room.updateShareMedia(data); + data.peer_id == 'all' ? room.broadCast(socket.id, 'shareVideoAction', data) : room.sendTo(data.peer_id, 'shareVideoAction', data); diff --git a/package.json b/package.json index 2b9a4e7e..b9efe816 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalksfu", - "version": "1.6.25", + "version": "1.6.26", "description": "WebRTC SFU browser-based video calls", "main": "Server.js", "scripts": { diff --git a/public/js/Room.js b/public/js/Room.js index dd7dcae6..bc643e3c 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.6.25 + * @version 1.6.26 * */ @@ -4564,7 +4564,7 @@ function showAbout() { imageUrl: image.about, customClass: { image: 'img-about' }, position: 'center', - title: 'WebRTC SFU v1.6.25', + title: 'WebRTC SFU v1.6.26', html: `
diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index cd9c151d..05009975 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -601,6 +601,15 @@ class RoomClient { if (room.hostProtected) { RoomURL = window.location.origin + '/join/?room=' + room_id; } + + // Share Media Data on Join + if ( + room.shareMediaData && + Object.keys(room.shareMediaData).length !== 0 && + room.shareMediaData.action === 'open' + ) { + this.shareVideoAction(room.shareMediaData); + } } // PARTICIPANTS @@ -6093,9 +6102,9 @@ class RoomClient { }).then((result) => { if (result.value) { result.value = filterXSS(result.value); - if (!this.thereAreParticipants()) { - return userLog('info', 'No participants detected', 'top-end'); - } + // if (!this.thereAreParticipants()) { + // return userLog('info', 'No participants detected', 'top-end'); + // } if (!this.isVideoTypeSupported(result.value)) { return userLog('warning', 'Something wrong, try with another Video or audio URL'); } @@ -6169,8 +6178,8 @@ class RoomClient { } shareVideoAction(data) { - let peer_name = data.peer_name; - let action = data.action; + const { peer_name, action } = data; + switch (action) { case 'open': this.userLog('info', `${peer_name} opened the video`, 'top-end');