Skip to content

Commit c509b29

Browse files
Merge pull request #37 from videosdk-live/feature/screen-share-request
screen share request changes
2 parents e737c1f + ce7b248 commit c509b29

7 files changed

Lines changed: 104 additions & 16 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "videosdk-rtc-react-prebuilt-ui",
3-
"version": "0.3.7",
3+
"version": "0.3.8",
44
"private": true,
5-
"homepage": "https://embed.videosdk.live/rtc-js-prebuilt/0.3.7/",
5+
"homepage": "https://embed.videosdk.live/rtc-js-prebuilt/0.3.8/",
66
"dependencies": {
77
"@material-ui/core": "^4.11.4",
88
"@material-ui/icons": "^4.11.2",

src/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const App = () => {
7272
participantCanLeave: "participantCanLeave",
7373
participantCanToggleOtherWebcam: "participantCanToggleOtherWebcam",
7474
participantCanToggleOtherMic: "participantCanToggleOtherMic",
75+
partcipantCanToogleOtherScreenShare:
76+
"partcipantCanToogleOtherScreenShare",
7577
participantCanToggleLivestream: "participantCanToggleLivestream",
7678
participantCanEndMeeting: "participantCanEndMeeting",
7779
//
@@ -506,6 +508,8 @@ const App = () => {
506508
paramKeys.participantCanToggleOtherMic === "true",
507509
participantCanToggleOtherWebcam:
508510
paramKeys.participantCanToggleOtherWebcam === "true",
511+
partcipantCanToogleOtherScreenShare:
512+
paramKeys.partcipantCanToogleOtherScreenShare === "true",
509513
participantCanToggleLivestream:
510514
paramKeys.participantCanToggleLivestream === "true",
511515
notificationSoundEnabled:

src/MeetingAppContextDef.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const MeetingAppProvider = ({
8181
askJoin,
8282
participantCanToggleOtherMic,
8383
participantCanToggleOtherWebcam,
84+
partcipantCanToogleOtherScreenShare,
8485
canRemoveOtherParticipant,
8586
notificationSoundEnabled,
8687
canPin,
@@ -205,6 +206,7 @@ export const MeetingAppProvider = ({
205206
askJoin,
206207
participantCanToggleOtherMic,
207208
participantCanToggleOtherWebcam,
209+
partcipantCanToogleOtherScreenShare,
208210
canRemoveOtherParticipant,
209211
notificationSoundEnabled,
210212
canToggleWhiteboard,

src/components/JoinScreen.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,11 @@ export default function JoinMeeting({
444444
style={{
445445
display: "flex",
446446
flex: 1,
447-
flexDirection:
448-
meetingUrl === "" || meetingTitle === "" ? "row" : "column",
447+
flexDirection: isXStoSM
448+
? "column"
449+
: meetingUrl === "" || meetingTitle === ""
450+
? "row"
451+
: "column",
449452
justifyContent: "center",
450453
alignItems: "center",
451454
}}
@@ -456,7 +459,11 @@ export default function JoinMeeting({
456459
style={{
457460
display: "flex",
458461
flex: isSMOnly ? 0 : 1,
459-
flexDirection: meetingUrl || meetingTitle ? "row" : "column",
462+
flexDirection: isXStoSM
463+
? "column"
464+
: meetingUrl || meetingTitle
465+
? "row"
466+
: "column",
460467
alignItems: "center",
461468
justifyContent: "center",
462469
}}
@@ -685,7 +692,7 @@ export default function JoinMeeting({
685692
<Grid
686693
item
687694
xs={12}
688-
md={meetingTitle || meetingUrl ? 5 : 6}
695+
md={isXStoSM ? 5 : meetingTitle || meetingUrl ? 5 : 6}
689696
style={{
690697
width: "100%",
691698
display: "flex",

src/components/MediaRequested.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMeeting } from "@videosdk.live/react-sdk";
1+
import { useMeeting, usePubSub } from "@videosdk.live/react-sdk";
22
import React, { useEffect, useRef, useState } from "react";
33
import ConfirmBox from "./ConfirmBox";
44

@@ -12,6 +12,8 @@ const MediaRequested = () => {
1212

1313
const [reqMicInfo, setReqMicInfo] = useState(reqInfoDefaultState);
1414
const [reqWebcamInfo, setReqWebcamInfo] = useState(reqInfoDefaultState);
15+
const [reqScreenShareInfo, setReqScreenShareInfo] =
16+
useState(reqInfoDefaultState);
1517

1618
const mMeetingRef = useRef();
1719

@@ -42,11 +44,33 @@ const MediaRequested = () => {
4244
mMeetingRef.current = mMeeting;
4345
}, [mMeeting]);
4446

47+
usePubSub(`SCR_SHR_REQ_${mMeeting?.localParticipant.id}`, {
48+
onMessageReceived: (data) => {
49+
if (data.message.setScreenShareOn) {
50+
setReqScreenShareInfo({
51+
enabled: true,
52+
participantName: "Host",
53+
accept: () => {
54+
mMeeting?.toggleScreenShare();
55+
},
56+
reject: () => {},
57+
});
58+
} else {
59+
mMeeting?.toggleScreenShare();
60+
}
61+
},
62+
});
63+
4564
return (
4665
<>
4766
{[
4867
{ ...reqMicInfo, setter: setReqMicInfo, type: "mic" },
4968
{ ...reqWebcamInfo, setter: setReqWebcamInfo, type: "webcam" },
69+
{
70+
...reqScreenShareInfo,
71+
setter: setReqScreenShareInfo,
72+
type: "screenShare",
73+
},
5074
].map(({ accept, enabled, participantName, setter, reject, type }, i) => {
5175
return (
5276
<ConfirmBox

src/meetingContainer/TopBar.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,14 +1231,16 @@ const TopBar = ({ topBarHeight }) => {
12311231
);
12321232
})}
12331233

1234-
<Box ml={2}>
1235-
<OutlineIconButton
1236-
Icon={MoreHorizIcon}
1237-
// Icon={Boolean(anchorEl) ? CloseIcon : MoreHorizIcon}
1238-
// isFocused={anchorEl}
1239-
onClick={handleClickFAB}
1240-
/>
1241-
</Box>
1234+
{excludeFirstFourElements.length >= 1 && (
1235+
<Box ml={2}>
1236+
<OutlineIconButton
1237+
Icon={MoreHorizIcon}
1238+
// Icon={Boolean(anchorEl) ? CloseIcon : MoreHorizIcon}
1239+
// isFocused={anchorEl}
1240+
onClick={handleClickFAB}
1241+
/>
1242+
</Box>
1243+
)}
12421244

12431245
<SwipeableDrawer
12441246
anchor={"bottom"}

src/meetingContainer/sideViewContainer/ParticipantsTabPanel.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { useMeeting, useParticipant } from "@videosdk.live/react-sdk";
1+
import {
2+
useMeeting,
3+
useParticipant,
4+
usePubSub,
5+
} from "@videosdk.live/react-sdk";
26
import {
37
Close,
48
MoreVert,
@@ -7,6 +11,8 @@ import {
711
Mic as MicIcon,
812
VideocamOff as VideocamOffIcon,
913
Videocam as VideocamIcon,
14+
ScreenShareOutlined,
15+
ScreenShare,
1016
} from "@material-ui/icons";
1117
import {
1218
Avatar,
@@ -35,6 +41,7 @@ function ParticipantListItem({
3541
participantExpandedId,
3642
setParticipantExpandedId,
3743
}) {
44+
const { presenterId } = useMeeting();
3845
const {
3946
participant,
4047
micOn,
@@ -53,11 +60,18 @@ function ParticipantListItem({
5360
const {
5461
participantCanToggleOtherMic,
5562
participantCanToggleOtherWebcam,
63+
partcipantCanToogleOtherScreenShare,
5664
canRemoveOtherParticipant,
5765
canPin,
5866
animationsEnabled,
5967
} = useMeetingAppContext();
6068

69+
const isParticipantPresenting = useMemo(() => {
70+
return presenterId === participantId;
71+
}, [presenterId, participantId]);
72+
73+
const { publish } = usePubSub(`SCR_SHR_REQ_${participantId}`);
74+
6175
const [isParticipantKickoutVisible, setIsParticipantKickoutVisible] =
6276
useState(false);
6377

@@ -284,6 +298,41 @@ function ParticipantListItem({
284298
</Tooltip>
285299
</Box>
286300
)}
301+
302+
<Box ml={1} mr={0}>
303+
<Tooltip title={`Screen share`}>
304+
<IconButton
305+
disabled={
306+
!(
307+
!isLocal &&
308+
partcipantCanToogleOtherScreenShare &&
309+
(presenterId ? isParticipantPresenting : true)
310+
)
311+
}
312+
style={{ padding: 0 }}
313+
onClick={() => {
314+
publish({ setScreenShareOn: !isParticipantPresenting });
315+
}}
316+
>
317+
<Box
318+
style={{
319+
display: "flex",
320+
justifyContent: "center",
321+
alignItems: "center",
322+
borderRadius: 100,
323+
}}
324+
p={0.5}
325+
>
326+
{isParticipantPresenting ? (
327+
<ScreenShare />
328+
) : (
329+
<ScreenShareOutlined color="#ffffff80" />
330+
)}
331+
</Box>
332+
</IconButton>
333+
</Tooltip>
334+
</Box>
335+
287336
{!isLocal && canRemoveOtherParticipant && (
288337
<Box ml={1} mr={0}>
289338
<Tooltip title={`Remove`}>

0 commit comments

Comments
 (0)