forked from zoom/videosdk-ui-toolkit-javascript-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
59 lines (52 loc) · 1.49 KB
/
scripts.js
File metadata and controls
59 lines (52 loc) · 1.49 KB
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
var sessionContainer = document.getElementById('sessionContainer')
var authEndpoint = ''
var config = {
videoSDKJWT: '',
sessionName: 'test',
userName: 'JavaScript',
sessionPasscode: '123',
featuresOptions: {
virtualBackground: {
enable: true,
virtualBackgrounds: [
{
url: 'https://images.unsplash.com/photo-1715490187538-30a365fa05bd?q=80&w=1945&auto=format&fit=crop'
},
],
},
},
};
var role = 1
window.getVideoSDKJWT = getVideoSDKJWT
function getVideoSDKJWT() {
document.getElementById('join-flow').style.display = 'none'
fetch(authEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
sessionName: config.sessionName,
role: role,
})
}).then((response) => {
return response.json()
}).then((data) => {
if(data.signature) {
console.log(data.signature)
config.videoSDKJWT = data.signature
joinSession()
} else {
console.log(data)
}
}).catch((error) => {
console.log(error)
})
}
function joinSession() {
uitoolkit.joinSession(sessionContainer, config)
uitoolkit.onSessionClosed(sessionClosed)
}
var sessionClosed = (() => {
console.log('session closed')
uitoolkit.closeSession(sessionContainer)
document.getElementById('join-flow').style.display = 'block'
})