-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevents.js
103 lines (78 loc) · 3.45 KB
/
events.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
// When a video stream is added to the conference
VoxeetSDK.conference.on('streamAdded', (participant, stream) => {
// logMessage(`Event - streamAdded from ${participant.info.name} (${participant.id})`);
if (stream.type === 'ScreenShare') {
return addScreenShareNode(participant, stream);
}
if (stream.getVideoTracks().length) {
// Only add the video node if there is a video track
addVideoNode(participant, stream);
}
});
// When a video stream is updated from the conference´
VoxeetSDK.conference.on('streamUpdated', (participant, stream) => {
// logMessage(`Event - streamUpdated from ${participant.info.name} (${participant.id})`);
if (stream.type === 'ScreenShare') return;
if (stream.getVideoTracks().length) {
// Only add the video node if there is a video track
addVideoNode(participant, stream);
updateVideoMessage(participant, stream);
} else {
removeVideoNode(participant);
}
});
// When a video stream is removed from the conference
VoxeetSDK.conference.on('streamRemoved', (participant, stream) => {
// logMessage(`Event - streamRemoved from ${participant.info.name} (${participant.id})`);
if (stream.type === 'ScreenShare') {
return removeScreenShareNode();
}
removeVideoNode(participant);
});
VoxeetSDK.conference.on('participantAdded', (participant) => {
logMessage(`${participant.info.name} has joined the ClickShare`);
addUpdateParticipantNode(participant);
});
VoxeetSDK.conference.on('participantUpdated', (participant) => {
// logMessage(`Event - participantUpdated from ${participant.info.name} (${participant.id}) - Status: ${participant.status}`);
if (participant.status === 'Decline' ||
participant.status === 'Error' ||
participant.status === 'Kicked' ||
participant.status === 'Left') {
removeParticipantNode(participant);
} else {
addUpdateParticipantNode(participant);
}
});
VoxeetSDK.videoPresentation.on('started', (vp) => {
// logMessage(`Event - videoPresentation started ${vp.url}`);
addVideoPlayer(vp.url);
$(`#stream-video video`)[0].currentTime = vp.timestamp;
});
VoxeetSDK.videoPresentation.on('paused', (vp) => {
// logMessage(`Event - videoPresentation paused at ${vp.timestamp}ms`);
$(`#stream-video video`)[0].pause();
$(`#stream-video video`)[0].currentTime = vp.timestamp / 1000;
});
VoxeetSDK.videoPresentation.on('played', (vp) => {
// logMessage('Event - videoPresentation played');
$(`#stream-video video`)[0].play();
});
VoxeetSDK.videoPresentation.on('sought', (vp) => {
// logMessage(`Event - videoPresentation sought to ${vp.timestamp}ms`);
$(`#stream-video video`)[0].currentTime = vp.timestamp / 1000;
});
VoxeetSDK.videoPresentation.on('stopped', () => {
// logMessage('Event - videoPresentation stopped');
$(`#stream-video`).remove();
});
// Invitation to join a conference received
VoxeetSDK.notification.on("invitation", (invite) => {
// logMessage(`Event - invitation to join the conference ${invite.conferenceAlias} (${invite.conferenceId}) received from ${invite.participant.info.name}`);
$('#conference-alias-input').val(invite.conferenceAlias);
conferenceAccessToken = invite.conferenceAccessToken;
});
// When other participants send a command
VoxeetSDK.command.on('received', (participant, message) => {
// logMessage(`Event - command received from ${participant.info.name}: ${message}`);
});