This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexample_Foundations.js
152 lines (142 loc) · 5.49 KB
/
example_Foundations.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// The components below are from our UIKit library,
// You can discover more about our UI Kit components [here](https://github.com/DolbyIO/comms-uikit-react/tree/main/documentation)
import {
CommsProvider,
Session,
JoinConferenceButton,
Conference,
ParticipantsList,
ParticipantsGrid,
LocalToggleAudioButton,
LocalToggleVideoButton,
LeaveConferenceButton,
CameraSelect,
MicrophoneSelect,
SpeakersSelect,
InfoBar,
} from '@dolbyio/comms-uikit-react';
import VoxeetSDK from '@voxeet/voxeet-web-sdk';
import React, { useEffect, useState } from 'react';
// `CommsProvider` configuration: we need two props, a `token` and an async function that refreshes it
const token = 'YOUR_CLIENT_ACCESS_TOKEN_HERE';
const refreshToken = async () => token;
// Create AppBase component which bundles CommsProvider
const AppBase = ({ children }) => {
return (
<CommsProvider token={token} refreshToken={refreshToken}>
{children}
</CommsProvider>
);
};
// Create Content component to bundle all of the fundamental parts of the UIKit to serve a basic video call app
const Content = () => {
// Define the state for the conference ID. We await a response from an API call that will return conferenceID value once the participant joins an active conference. The state is removed once the participant leaves the conference.
const [conferenceId, setConferenceId] = useState();
// Define the `Session` configuration: you should provide a name using a `participantInfo` object
// Refer to docs: https://docs.dolby.io/communications-apis/docs/js-client-sdk-model-participantinfo
const participantInfo = { name: 'John Doe' };
// Define the `JoinConferenceButton` configuration: you can specify whether to join the conference with audio and/or video enabled, in addition to a meetingName and username (usually the name of current user) which can be made visible to all participants.
// Refer to docs: https://docs.dolby.io/communications-apis/docs/js-client-sdk-model-joinoptions
const joinOptions = {
constraints: {
audio: true,
video: true,
},
};
// Define styles for the containers
const contentContainerStyle = {
minHeight: '100vh',
gap: '10px',
display: 'flex',
flexDirection: 'column',
alignItems: 'stretch',
justifyContent: 'center',
backgroundColor: '#14141A',
padding: '20px 0',
boxSizing: 'border-box',
};
const buttonContainerStyle = {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
};
// We are using conference service of VoxeetSDK here to observe the participants' status
useEffect(() => {
// Define the event handler here
const handler = (participant) => {
console.log(participant.info.name, 'status:', participant.status);
console.log(participant.info.name, 'has audio enabled:', participant.audioTransmitting);
};
// Register the handler for 'participantUpdated' event
VoxeetSDK.conference.on('participantUpdated', handler);
return () => {
// Unregister the handler
VoxeetSDK.conference.removeListener('participantUpdated', handler);
};
}, []);
return (
<div className="App" style={contentContainerStyle}>
<InfoBar text="Voxeet Web SDK has been initialized." style={{ margin: '0 auto' }} />
<Session participantInfo={participantInfo}>
<InfoBar text="Session has been created." style={{ margin: '0 auto' }} />
{!conferenceId ? (
<div style={buttonContainerStyle}>
<JoinConferenceButton
joinOptions={joinOptions}
meetingName="My meeting"
username="John Doe"
tooltipText="Join meeting"
onSuccess={(id) => setConferenceId(id)}
>
Join Video Call
</JoinConferenceButton>
</div>
) : (
/* IMPORTANT: Rendering a <Conference /> component will establish a call using Dolby.io - if you're using your free minutes for this demo, remember to leave the conference or close the browser tab when you're done! */
<div>
<Conference id={conferenceId}>
<ParticipantsList
localText="you"
muteText="mute"
unmuteText="unmute"
soundOnText="sound on"
soundOffText="sound off"
/>
<ParticipantsGrid localText="you" additionalContainerStyle={{ height: 400 }} />
<div style={{ ...buttonContainerStyle, gap: '10px' }}>
<LocalToggleAudioButton />
<LocalToggleVideoButton />
</div>
<CameraSelect label="Camera" placeholder="Choose a camera" labelColor="white" />
<MicrophoneSelect label="Microphone" placeholder="Choose a microphone" labelColor="white" />
<SpeakersSelect label="Speaker" placeholder="Choose a speaker" labelColor="white" />
<div style={buttonContainerStyle}>
<LeaveConferenceButton tooltipText="Leave meetings" onSuccess={() => setConferenceId(undefined)} />
</div>
</Conference>
</div>
)}
</Session>
</div>
);
};
// Connect AppBase component with Content
const App = () => {
// Define styles for the containers
const appContainerStyles = `
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
`;
return (
<>
<style>{appContainerStyles}</style>
<AppBase>
<Content />
</AppBase>
</>
);
};
export default App;