@videosdk.live/react-sdk 0.1.42 → 0.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +71 -8
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +71 -8
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33,7 +33,8 @@ var events = {
|
|
|
33
33
|
'hls-started': eventPrifix + "-hls-started",
|
|
34
34
|
'hls-stopped': eventPrifix + "-hls-stopped",
|
|
35
35
|
'recording-state-changed': eventPrifix + "-recording-state-changed",
|
|
36
|
-
'livestream-state-changed': eventPrifix + "-livestream-state-changed"
|
|
36
|
+
'livestream-state-changed': eventPrifix + "-livestream-state-changed",
|
|
37
|
+
'meeting-state-changed': eventPrifix + "-meeting-state-changed"
|
|
37
38
|
};
|
|
38
39
|
var eventEmitter = new EventEmitter();
|
|
39
40
|
eventEmitter.setMaxListeners(9999);
|
|
@@ -94,7 +95,9 @@ var useMeeting = function useMeeting(_temp) {
|
|
|
94
95
|
_ref$onRecordingState = _ref.onRecordingStateChanged,
|
|
95
96
|
onRecordingStateChanged = _ref$onRecordingState === void 0 ? function () {} : _ref$onRecordingState,
|
|
96
97
|
_ref$onLivestreamStat = _ref.onLivestreamStateChanged,
|
|
97
|
-
onLivestreamStateChanged = _ref$onLivestreamStat === void 0 ? function () {} : _ref$onLivestreamStat
|
|
98
|
+
onLivestreamStateChanged = _ref$onLivestreamStat === void 0 ? function () {} : _ref$onLivestreamStat,
|
|
99
|
+
_ref$onMeetingStateCh = _ref.onMeetingStateChanged,
|
|
100
|
+
onMeetingStateChanged = _ref$onMeetingStateCh === void 0 ? function () {} : _ref$onMeetingStateCh;
|
|
98
101
|
|
|
99
102
|
React.useEffect(function () {
|
|
100
103
|
eventEmitter.on(events['participant-joined'], onParticipantJoined);
|
|
@@ -124,7 +127,9 @@ var useMeeting = function useMeeting(_temp) {
|
|
|
124
127
|
eventEmitter.on(events['hls-stopped'], onHlsStopped);
|
|
125
128
|
eventEmitter.on(events['recording-state-changed'], onRecordingStateChanged);
|
|
126
129
|
eventEmitter.on(events['livestream-state-changed'], onLivestreamStateChanged);
|
|
130
|
+
eventEmitter.on(events['meeting-state-changed'], onMeetingStateChanged);
|
|
127
131
|
return function () {
|
|
132
|
+
eventEmitter.off(events['meeting-state-changed'], onMeetingStateChanged);
|
|
128
133
|
eventEmitter.off(events['participant-joined'], onParticipantJoined);
|
|
129
134
|
eventEmitter.off(events['participant-left'], onParticipantLeft);
|
|
130
135
|
eventEmitter.off(events['speaker-changed'], onSpeakerChanged);
|
|
@@ -211,8 +216,11 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
211
216
|
_ref2$onRecordingStat = _ref2.onRecordingStateChanged,
|
|
212
217
|
onRecordingStateChanged = _ref2$onRecordingStat === void 0 ? function () {} : _ref2$onRecordingStat,
|
|
213
218
|
_ref2$onLivestreamSta = _ref2.onLivestreamStateChanged,
|
|
214
|
-
onLivestreamStateChanged = _ref2$onLivestreamSta === void 0 ? function () {} : _ref2$onLivestreamSta
|
|
219
|
+
onLivestreamStateChanged = _ref2$onLivestreamSta === void 0 ? function () {} : _ref2$onLivestreamSta,
|
|
220
|
+
_ref2$onMeetingStateC = _ref2.onMeetingStateChanged,
|
|
221
|
+
onMeetingStateChanged = _ref2$onMeetingStateC === void 0 ? function () {} : _ref2$onMeetingStateC;
|
|
215
222
|
React.useEffect(function () {
|
|
223
|
+
eventEmitter.on(events['meeting-state-changed'], onMeetingStateChanged);
|
|
216
224
|
eventEmitter.on(events['participant-joined'], onParticipantJoined);
|
|
217
225
|
eventEmitter.on(events['participant-left'], onParticipantLeft);
|
|
218
226
|
eventEmitter.on(events['speaker-changed'], onSpeakerChanged);
|
|
@@ -241,6 +249,7 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
241
249
|
eventEmitter.on(events['recording-state-changed'], onRecordingStateChanged);
|
|
242
250
|
eventEmitter.on(events['livestream-state-changed'], onLivestreamStateChanged);
|
|
243
251
|
return function () {
|
|
252
|
+
eventEmitter.off(events['meeting-state-changed'], onMeetingStateChanged);
|
|
244
253
|
eventEmitter.off(events['participant-joined'], onParticipantJoined);
|
|
245
254
|
eventEmitter.off(events['participant-left'], onParticipantLeft);
|
|
246
255
|
eventEmitter.off(events['speaker-changed'], onSpeakerChanged);
|
|
@@ -273,7 +282,7 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
273
282
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MeetingProviderContex.Consumer, null, children));
|
|
274
283
|
};
|
|
275
284
|
|
|
276
|
-
var version = "0.1.
|
|
285
|
+
var version = "0.1.43";
|
|
277
286
|
|
|
278
287
|
var MeetingProvider = function MeetingProvider(_ref) {
|
|
279
288
|
var children = _ref.children,
|
|
@@ -547,6 +556,7 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
547
556
|
var _meeting$localPartici;
|
|
548
557
|
|
|
549
558
|
if (typeof (meeting === null || meeting === void 0 ? void 0 : meeting.off) === 'function') {
|
|
559
|
+
meeting.off('meeting-state-changed', _handle_meeting_state_changed);
|
|
550
560
|
meeting.off('participant-joined', _handle_participant_joined);
|
|
551
561
|
meeting.off('participant-left', _handle_participant_left);
|
|
552
562
|
meeting.off('presenter-changed', _handle_presenter_changed);
|
|
@@ -642,6 +652,10 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
642
652
|
eventEmitter.emit(events['livestream-state-changed'], data);
|
|
643
653
|
};
|
|
644
654
|
|
|
655
|
+
var _handle_meeting_state_changed = function _handle_meeting_state_changed(data) {
|
|
656
|
+
eventEmitter.emit(events['meeting-state-changed'], data);
|
|
657
|
+
};
|
|
658
|
+
|
|
645
659
|
var join = function join() {
|
|
646
660
|
var meeting = jsSdk.VideoSDK && jsSdk.VideoSDK.initMeeting(configRef.current);
|
|
647
661
|
setMeeting(meeting);
|
|
@@ -650,6 +664,7 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
650
664
|
participants.set(localParticipant.id, localParticipant);
|
|
651
665
|
setParticipants(participants);
|
|
652
666
|
setLocalParticipant(localParticipant);
|
|
667
|
+
meeting.on('meeting-state-changed', _handle_meeting_state_changed);
|
|
653
668
|
meeting.on('participant-joined', _handle_participant_joined);
|
|
654
669
|
meeting.on('participant-left', _handle_participant_left);
|
|
655
670
|
meeting.on('presenter-changed', _handle_presenter_changed);
|
|
@@ -1069,7 +1084,9 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1069
1084
|
_ref$onStreamEnabled = _ref.onStreamEnabled,
|
|
1070
1085
|
onStreamEnabled = _ref$onStreamEnabled === void 0 ? function () {} : _ref$onStreamEnabled,
|
|
1071
1086
|
_ref$onStreamDisabled = _ref.onStreamDisabled,
|
|
1072
|
-
onStreamDisabled = _ref$onStreamDisabled === void 0 ? function () {} : _ref$onStreamDisabled
|
|
1087
|
+
onStreamDisabled = _ref$onStreamDisabled === void 0 ? function () {} : _ref$onStreamDisabled,
|
|
1088
|
+
_ref$onMediaStatusCha = _ref.onMediaStatusChanged,
|
|
1089
|
+
onMediaStatusChanged = _ref$onMediaStatusCha === void 0 ? function () {} : _ref$onMediaStatusCha;
|
|
1073
1090
|
|
|
1074
1091
|
var _useState = React.useState(null),
|
|
1075
1092
|
webcamStream = _useState[0],
|
|
@@ -1112,6 +1129,14 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1112
1129
|
|
|
1113
1130
|
var participant = participants === null || participants === void 0 ? void 0 : participants.get(participantId);
|
|
1114
1131
|
|
|
1132
|
+
var _useState4 = React.useState(participant === null || participant === void 0 ? void 0 : participant.webcamOn),
|
|
1133
|
+
webcamOn = _useState4[0],
|
|
1134
|
+
setWebcamOn = _useState4[1];
|
|
1135
|
+
|
|
1136
|
+
var _useState5 = React.useState(participant === null || participant === void 0 ? void 0 : participant.micOn),
|
|
1137
|
+
micOn = _useState5[0],
|
|
1138
|
+
setMicOn = _useState5[1];
|
|
1139
|
+
|
|
1115
1140
|
var setTrack = function setTrack(stream) {
|
|
1116
1141
|
if (stream.track.readyState === 'live') {
|
|
1117
1142
|
switch (stream.kind) {
|
|
@@ -1158,6 +1183,24 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1158
1183
|
onStreamDisabled(stream);
|
|
1159
1184
|
};
|
|
1160
1185
|
|
|
1186
|
+
var _handleMediaStatusChanged = function _handleMediaStatusChanged(data) {
|
|
1187
|
+
var kind = data.kind,
|
|
1188
|
+
peerId = data.peerId,
|
|
1189
|
+
newStatus = data.newStatus;
|
|
1190
|
+
|
|
1191
|
+
if (kind == 'audio') {
|
|
1192
|
+
setMicOn(newStatus);
|
|
1193
|
+
} else if (kind == 'video') {
|
|
1194
|
+
setWebcamOn(newStatus);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
onMediaStatusChanged({
|
|
1198
|
+
kind: kind,
|
|
1199
|
+
peerId: peerId,
|
|
1200
|
+
newStatus: newStatus
|
|
1201
|
+
});
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1161
1204
|
var setQuality = function setQuality(quality) {
|
|
1162
1205
|
participant === null || participant === void 0 ? void 0 : participant.setQuality(quality);
|
|
1163
1206
|
};
|
|
@@ -1190,6 +1233,14 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1190
1233
|
participant === null || participant === void 0 ? void 0 : participant.unpin(data);
|
|
1191
1234
|
};
|
|
1192
1235
|
|
|
1236
|
+
var getAudioStats = function getAudioStats() {
|
|
1237
|
+
return Promise.resolve(participant === null || participant === void 0 ? void 0 : participant.getAudioStats());
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1240
|
+
var getVideoStats = function getVideoStats() {
|
|
1241
|
+
return Promise.resolve(participant === null || participant === void 0 ? void 0 : participant.getVideoStats());
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1193
1244
|
var consumeWebcamStreams = function consumeWebcamStreams() {
|
|
1194
1245
|
participant === null || participant === void 0 ? void 0 : participant.consumeWebcamStreams();
|
|
1195
1246
|
};
|
|
@@ -1219,11 +1270,21 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1219
1270
|
});
|
|
1220
1271
|
}
|
|
1221
1272
|
|
|
1273
|
+
if (participant !== null && participant !== void 0 && participant.micOn) {
|
|
1274
|
+
setMicOn(micOn);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
if (participant !== null && participant !== void 0 && participant.webcamOn) {
|
|
1278
|
+
setWebcamOn(webcamOn);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1222
1281
|
participant === null || participant === void 0 ? void 0 : participant.on('stream-enabled', _handleStreamEnabled);
|
|
1223
1282
|
participant === null || participant === void 0 ? void 0 : participant.on('stream-disabled', _handleStreamDisabled);
|
|
1283
|
+
participant === null || participant === void 0 ? void 0 : participant.on('media-status-changed', _handleMediaStatusChanged);
|
|
1224
1284
|
return function () {
|
|
1225
1285
|
participant === null || participant === void 0 ? void 0 : participant.off('stream-enabled', _handleStreamEnabled);
|
|
1226
1286
|
participant === null || participant === void 0 ? void 0 : participant.off('stream-disabled', _handleStreamDisabled);
|
|
1287
|
+
participant === null || participant === void 0 ? void 0 : participant.off('media-status-changed', _handleMediaStatusChanged);
|
|
1227
1288
|
};
|
|
1228
1289
|
}, [participant]);
|
|
1229
1290
|
return {
|
|
@@ -1232,8 +1293,8 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1232
1293
|
webcamStream: webcamStream,
|
|
1233
1294
|
micStream: micStream,
|
|
1234
1295
|
screenShareStream: screenShareStream,
|
|
1235
|
-
webcamOn:
|
|
1236
|
-
micOn:
|
|
1296
|
+
webcamOn: webcamOn,
|
|
1297
|
+
micOn: micOn,
|
|
1237
1298
|
screenShareOn: !!screenShareStream,
|
|
1238
1299
|
isLocal: (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.id) === participantId,
|
|
1239
1300
|
isActiveSpeaker: activeSpeakerId === participantId,
|
|
@@ -1251,7 +1312,9 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1251
1312
|
disableWebcam: disableWebcam,
|
|
1252
1313
|
pin: pin,
|
|
1253
1314
|
unpin: unpin,
|
|
1254
|
-
switchTo: switchTo
|
|
1315
|
+
switchTo: switchTo,
|
|
1316
|
+
getAudioStats: getAudioStats,
|
|
1317
|
+
getVideoStats: getVideoStats
|
|
1255
1318
|
};
|
|
1256
1319
|
};
|
|
1257
1320
|
|