-
Notifications
You must be signed in to change notification settings - Fork 17
/
PauseInvisibleParticipant.js
52 lines (46 loc) · 1.48 KB
/
PauseInvisibleParticipant.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { useMeeting, useParticipant } from "@videosdk.live/react-native-sdk";
import React, { useEffect } from "react";
const PauseInvisibleParticipant = ({ participantId, isVisible }) => {
const { webcamStream, webcamOn, isLocal, displayName } =
useParticipant(participantId);
useEffect(() => {
if (typeof isVisible === "string") {
if (!isLocal) {
if (isVisible) {
typeof webcamStream?.resume === "function" && webcamStream?.resume();
// consumeWebcamStreams();
} else {
typeof webcamStream?.pause === "function" && webcamStream?.pause();
// stopConsumingWebcamStreams();
}
}
} else {
if (!isLocal) {
typeof webcamStream?.pause === "function" && webcamStream?.pause();
// stopConsumingWebcamStreams();
}
}
}, [isLocal, isVisible, webcamStream]);
return <></>;
};
const PauseInvisibleParticipants = ({ visibleParticipantIds }) => {
const { participants } = useMeeting();
return (
<>
{[...participants.keys()].map((participantId) => {
return (
visibleParticipantIds.length > 0 && (
<PauseInvisibleParticipant
key={`PauseInvisibleParticipant_${participantId}`}
participantId={participantId}
isVisible={visibleParticipantIds.find(
(pId) => pId === participantId
)}
/>
)
);
})}
</>
);
};
export default PauseInvisibleParticipants;