@videosdk.live/react-sdk 0.2.1 → 0.2.3
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 +291 -18
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +290 -20
- package/dist/index.modern.js.map +1 -1
- package/dist/types/index.d.ts +164 -1
- package/dist/types/meeting.d.ts +24 -0
- package/package.json +3 -3
package/dist/index.modern.js
CHANGED
|
@@ -1,8 +1,56 @@
|
|
|
1
|
-
import React, { createContext, useEffect, useContext, useState, useRef, useMemo } from 'react';
|
|
1
|
+
import React, { createContext, useEffect, useContext, useState, useRef, useMemo, forwardRef } from 'react';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
import { VideoSDK } from '@videosdk.live/js-sdk';
|
|
4
4
|
export { CameraDeviceInfo, DeviceInfo, MicrophoneDeviceInfo } from '@videosdk.live/js-sdk';
|
|
5
5
|
|
|
6
|
+
function _arrayLikeToArray(r, a) {
|
|
7
|
+
(null == a || a > r.length) && (a = r.length);
|
|
8
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
12
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
13
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
14
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
15
|
+
t && (r = t);
|
|
16
|
+
var o = 0;
|
|
17
|
+
return function () {
|
|
18
|
+
return o >= r.length ? {
|
|
19
|
+
done: !0
|
|
20
|
+
} : {
|
|
21
|
+
done: !1,
|
|
22
|
+
value: r[o++]
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
27
|
+
}
|
|
28
|
+
function _extends() {
|
|
29
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
30
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
31
|
+
var t = arguments[e];
|
|
32
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
33
|
+
}
|
|
34
|
+
return n;
|
|
35
|
+
}, _extends.apply(null, arguments);
|
|
36
|
+
}
|
|
37
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
38
|
+
if (null == r) return {};
|
|
39
|
+
var t = {};
|
|
40
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
41
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
42
|
+
t[n] = r[n];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
}
|
|
46
|
+
function _unsupportedIterableToArray(r, a) {
|
|
47
|
+
if (r) {
|
|
48
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
49
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
50
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
6
54
|
var eventPrifix = 'videosdk-live-react-sdk';
|
|
7
55
|
var events = {
|
|
8
56
|
'participant-joined': eventPrifix + "-participant-joined",
|
|
@@ -45,6 +93,19 @@ var events = {
|
|
|
45
93
|
};
|
|
46
94
|
var eventEmitter = new EventEmitter();
|
|
47
95
|
eventEmitter.setMaxListeners(9999);
|
|
96
|
+
function debounce(func, delay) {
|
|
97
|
+
var timeout;
|
|
98
|
+
return function () {
|
|
99
|
+
var _this = this;
|
|
100
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
101
|
+
args[_key] = arguments[_key];
|
|
102
|
+
}
|
|
103
|
+
clearTimeout(timeout);
|
|
104
|
+
timeout = setTimeout(function () {
|
|
105
|
+
return func.apply(_this, args);
|
|
106
|
+
}, delay);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
48
109
|
|
|
49
110
|
var MeetingProviderContex = createContext();
|
|
50
111
|
var useMeeting = function useMeeting(_temp) {
|
|
@@ -320,7 +381,7 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
320
381
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MeetingProviderContex.Consumer, null, children));
|
|
321
382
|
};
|
|
322
383
|
|
|
323
|
-
var version = "0.2.
|
|
384
|
+
var version = "0.2.2";
|
|
324
385
|
|
|
325
386
|
var MeetingProvider = function MeetingProvider(_ref) {
|
|
326
387
|
var children = _ref.children,
|
|
@@ -558,12 +619,19 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
558
619
|
eventEmitter.emit(events['mic-requested'], data);
|
|
559
620
|
};
|
|
560
621
|
var _handle_meeting_joined = function _handle_meeting_joined(data) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
622
|
+
if (data.switchRoomId) {
|
|
623
|
+
setMessages(function (s) {
|
|
624
|
+
return [].concat(s, data.messages);
|
|
625
|
+
});
|
|
626
|
+
eventEmitter.emit(events['meeting-joined'], data);
|
|
627
|
+
} else {
|
|
628
|
+
joinedOnFirstRender.current = true;
|
|
629
|
+
setMessages(function (s) {
|
|
630
|
+
return [].concat(s, data.messages);
|
|
631
|
+
});
|
|
632
|
+
eventEmitter.emit(events['meeting-joined'], data);
|
|
633
|
+
setIsMeetingJoined(true);
|
|
634
|
+
}
|
|
567
635
|
};
|
|
568
636
|
var _handle_meeting_left2 = function _handle_meeting_left() {
|
|
569
637
|
eventEmitter.emit(events['meeting-left']);
|
|
@@ -858,6 +926,17 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
858
926
|
enableWebcam(customVideoTrack);
|
|
859
927
|
}
|
|
860
928
|
};
|
|
929
|
+
var switchTo = function switchTo(_ref3) {
|
|
930
|
+
var meetingId = _ref3.meetingId,
|
|
931
|
+
token = _ref3.token;
|
|
932
|
+
var meeting = meetingRef.current;
|
|
933
|
+
if (meeting) {
|
|
934
|
+
meeting.switchTo({
|
|
935
|
+
meetingId: meetingId,
|
|
936
|
+
token: token
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
};
|
|
861
940
|
var disableScreenShare = function disableScreenShare() {
|
|
862
941
|
var meeting = meetingRef.current;
|
|
863
942
|
if (meeting) {
|
|
@@ -944,8 +1023,8 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
944
1023
|
meeting.changeMic(obj);
|
|
945
1024
|
}
|
|
946
1025
|
};
|
|
947
|
-
var startVideo = function startVideo(
|
|
948
|
-
var link =
|
|
1026
|
+
var startVideo = function startVideo(_ref4) {
|
|
1027
|
+
var link = _ref4.link;
|
|
949
1028
|
var meeting = meetingRef.current;
|
|
950
1029
|
if (meeting) {
|
|
951
1030
|
meeting.startVideo({
|
|
@@ -965,8 +1044,8 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
965
1044
|
meeting.resumeVideo();
|
|
966
1045
|
}
|
|
967
1046
|
};
|
|
968
|
-
var pauseVideo = function pauseVideo(
|
|
969
|
-
var currentTime =
|
|
1047
|
+
var pauseVideo = function pauseVideo(_ref5) {
|
|
1048
|
+
var currentTime = _ref5.currentTime;
|
|
970
1049
|
var meeting = meetingRef.current;
|
|
971
1050
|
if (meeting) {
|
|
972
1051
|
meeting.pauseVideo({
|
|
@@ -974,8 +1053,20 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
974
1053
|
});
|
|
975
1054
|
}
|
|
976
1055
|
};
|
|
977
|
-
var
|
|
978
|
-
var
|
|
1056
|
+
var enableAdaptiveSubscription = function enableAdaptiveSubscription() {
|
|
1057
|
+
var meeting = meetingRef.current;
|
|
1058
|
+
if (meeting) {
|
|
1059
|
+
meeting.enableAdaptiveSubscription();
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
var disableAdaptiveSubscription = function disableAdaptiveSubscription() {
|
|
1063
|
+
var meeting = meetingRef.current;
|
|
1064
|
+
if (meeting) {
|
|
1065
|
+
meeting.disableAdaptiveSubscription();
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
var seekVideo = function seekVideo(_ref6) {
|
|
1069
|
+
var currentTime = _ref6.currentTime;
|
|
979
1070
|
var meeting = meetingRef.current;
|
|
980
1071
|
if (meeting) {
|
|
981
1072
|
meeting.seekVideo({
|
|
@@ -995,9 +1086,9 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
995
1086
|
meeting.stopLivestream();
|
|
996
1087
|
}
|
|
997
1088
|
};
|
|
998
|
-
var connectTo = function connectTo(
|
|
999
|
-
var meetingId =
|
|
1000
|
-
payload =
|
|
1089
|
+
var connectTo = function connectTo(_ref7) {
|
|
1090
|
+
var meetingId = _ref7.meetingId,
|
|
1091
|
+
payload = _ref7.payload;
|
|
1001
1092
|
try {
|
|
1002
1093
|
var _meeting3 = meetingRef.current;
|
|
1003
1094
|
var _temp = function () {
|
|
@@ -1093,6 +1184,7 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
1093
1184
|
disableScreenShare: disableScreenShare,
|
|
1094
1185
|
enableScreenShare: enableScreenShare,
|
|
1095
1186
|
toggleScreenShare: toggleScreenShare,
|
|
1187
|
+
switchTo: switchTo,
|
|
1096
1188
|
getMics: getMics,
|
|
1097
1189
|
getWebcams: getWebcams,
|
|
1098
1190
|
changeWebcam: changeWebcam,
|
|
@@ -1108,7 +1200,9 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
1108
1200
|
stopLivestream: stopLivestream,
|
|
1109
1201
|
connectTo: connectTo,
|
|
1110
1202
|
startHls: startHls,
|
|
1111
|
-
stopHls: stopHls
|
|
1203
|
+
stopHls: stopHls,
|
|
1204
|
+
enableAdaptiveSubscription: enableAdaptiveSubscription,
|
|
1205
|
+
disableAdaptiveSubscription: disableAdaptiveSubscription
|
|
1112
1206
|
}
|
|
1113
1207
|
}, children);
|
|
1114
1208
|
};
|
|
@@ -1122,7 +1216,11 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1122
1216
|
_ref$onMediaStatusCha = _ref.onMediaStatusChanged,
|
|
1123
1217
|
onMediaStatusChanged = _ref$onMediaStatusCha === void 0 ? function () {} : _ref$onMediaStatusCha,
|
|
1124
1218
|
_ref$onVideoQualityCh = _ref.onVideoQualityChanged,
|
|
1125
|
-
onVideoQualityChanged = _ref$onVideoQualityCh === void 0 ? function () {} : _ref$onVideoQualityCh
|
|
1219
|
+
onVideoQualityChanged = _ref$onVideoQualityCh === void 0 ? function () {} : _ref$onVideoQualityCh,
|
|
1220
|
+
_ref$onStreamPaused = _ref.onStreamPaused,
|
|
1221
|
+
onStreamPaused = _ref$onStreamPaused === void 0 ? function () {} : _ref$onStreamPaused,
|
|
1222
|
+
_ref$onStreamResumed = _ref.onStreamResumed,
|
|
1223
|
+
onStreamResumed = _ref$onStreamResumed === void 0 ? function () {} : _ref$onStreamResumed;
|
|
1126
1224
|
var _useState = useState(null),
|
|
1127
1225
|
webcamStream = _useState[0],
|
|
1128
1226
|
setwebcamStream = _useState[1];
|
|
@@ -1331,6 +1429,12 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
1331
1429
|
}
|
|
1332
1430
|
participant === null || participant === void 0 ? void 0 : participant.on('stream-enabled', _handleStreamEnabled);
|
|
1333
1431
|
participant === null || participant === void 0 ? void 0 : participant.on('stream-disabled', _handleStreamDisabled);
|
|
1432
|
+
participant === null || participant === void 0 ? void 0 : participant.on('stream-paused', function (data) {
|
|
1433
|
+
onStreamPaused(data);
|
|
1434
|
+
});
|
|
1435
|
+
participant === null || participant === void 0 ? void 0 : participant.on('stream-resumed', function (data) {
|
|
1436
|
+
onStreamResumed(data);
|
|
1437
|
+
});
|
|
1334
1438
|
participant === null || participant === void 0 ? void 0 : participant.on('media-status-changed', _handleMediaStatusChanged);
|
|
1335
1439
|
participant === null || participant === void 0 ? void 0 : participant.on('video-quality-changed', _handleVideoQualityChanged);
|
|
1336
1440
|
eventEmitter.on(events['participant-mode-changed'], _handleParticipantModeChanged);
|
|
@@ -1955,6 +2059,7 @@ var useWhiteboard = function useWhiteboard() {
|
|
|
1955
2059
|
};
|
|
1956
2060
|
};
|
|
1957
2061
|
|
|
2062
|
+
var _excluded = ["participantId", "type"];
|
|
1958
2063
|
var Constants = VideoSDK.Constants;
|
|
1959
2064
|
var createCameraVideoTrack = function createCameraVideoTrack(_ref) {
|
|
1960
2065
|
var _ref$cameraId = _ref.cameraId,
|
|
@@ -2026,6 +2131,171 @@ var getNetworkStats = function getNetworkStats(_temp) {
|
|
|
2026
2131
|
return Promise.reject(e);
|
|
2027
2132
|
}
|
|
2028
2133
|
};
|
|
2134
|
+
var withAdaptiveObservers = function withAdaptiveObservers(VideoPlayerComponent) {
|
|
2135
|
+
var intersectionObserverOptions = {
|
|
2136
|
+
root: null,
|
|
2137
|
+
rootMargin: '0px',
|
|
2138
|
+
threshold: 0
|
|
2139
|
+
};
|
|
2140
|
+
var debounceDelay = 400;
|
|
2141
|
+
return function (props) {
|
|
2142
|
+
var participantId = props.participantId,
|
|
2143
|
+
type = props.type;
|
|
2144
|
+
var ref = useRef(null);
|
|
2145
|
+
var observerRef = useRef(null);
|
|
2146
|
+
var resizeObserverRef = useRef(null);
|
|
2147
|
+
var _useParticipant = useParticipant(participantId),
|
|
2148
|
+
participant = _useParticipant.participant;
|
|
2149
|
+
useEffect(function () {
|
|
2150
|
+
if (type === 'share' || !ref.current || !participant) return;
|
|
2151
|
+
var element = ref.current;
|
|
2152
|
+
if (!element || !participant) return;
|
|
2153
|
+
if (observerRef.current) observerRef.current.disconnect();
|
|
2154
|
+
var handleIntersectionChange = debounce(function (entries) {
|
|
2155
|
+
for (var _iterator = _createForOfIteratorHelperLoose(entries), _step; !(_step = _iterator()).done;) {
|
|
2156
|
+
var entry = _step.value;
|
|
2157
|
+
if (entry.intersectionRatio > 0) {
|
|
2158
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(participant.streams.values()), _step2; !(_step2 = _iterator2()).done;) {
|
|
2159
|
+
var stream = _step2.value;
|
|
2160
|
+
if (stream.kind === 'video' && stream.pausedBy !== 'SUB_MANAGER') {
|
|
2161
|
+
stream.resume();
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
} else {
|
|
2165
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(participant.streams.values()), _step3; !(_step3 = _iterator3()).done;) {
|
|
2166
|
+
var _stream = _step3.value;
|
|
2167
|
+
if (_stream.kind === 'video') {
|
|
2168
|
+
_stream.pause();
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
}, debounceDelay);
|
|
2174
|
+
observerRef.current = new IntersectionObserver(handleIntersectionChange, intersectionObserverOptions);
|
|
2175
|
+
var processResize = function processResize(width, height) {
|
|
2176
|
+
if (width > 0 && height > 0) {
|
|
2177
|
+
participant.setViewPort(width, height);
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
var handleResize = debounce(function (entries) {
|
|
2181
|
+
var _entries$0$contentRec = entries[0].contentRect,
|
|
2182
|
+
width = _entries$0$contentRec.width,
|
|
2183
|
+
height = _entries$0$contentRec.height;
|
|
2184
|
+
processResize(width, height);
|
|
2185
|
+
}, debounceDelay);
|
|
2186
|
+
resizeObserverRef.current = new ResizeObserver(handleResize);
|
|
2187
|
+
resizeObserverRef.current.observe(element);
|
|
2188
|
+
observerRef.current.observe(element);
|
|
2189
|
+
return function () {
|
|
2190
|
+
if (observerRef.current) {
|
|
2191
|
+
observerRef.current.disconnect();
|
|
2192
|
+
}
|
|
2193
|
+
if (resizeObserverRef.current) {
|
|
2194
|
+
resizeObserverRef.current.disconnect();
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
2197
|
+
}, []);
|
|
2198
|
+
return /*#__PURE__*/React.createElement(VideoPlayerComponent, _extends({
|
|
2199
|
+
ref: ref
|
|
2200
|
+
}, props));
|
|
2201
|
+
};
|
|
2202
|
+
};
|
|
2203
|
+
var VideoSDKPlayer = forwardRef(function (_ref5, ref) {
|
|
2204
|
+
var participantId = _ref5.participantId,
|
|
2205
|
+
_ref5$type = _ref5.type,
|
|
2206
|
+
type = _ref5$type === void 0 ? 'video' : _ref5$type,
|
|
2207
|
+
_ref5$containerStyle = _ref5.containerStyle,
|
|
2208
|
+
containerStyle = _ref5$containerStyle === void 0 ? {} : _ref5$containerStyle,
|
|
2209
|
+
_ref5$className = _ref5.className,
|
|
2210
|
+
className = _ref5$className === void 0 ? '' : _ref5$className,
|
|
2211
|
+
_ref5$classNameVideo = _ref5.classNameVideo,
|
|
2212
|
+
classNameVideo = _ref5$classNameVideo === void 0 ? '' : _ref5$classNameVideo,
|
|
2213
|
+
_ref5$videoStyle = _ref5.videoStyle,
|
|
2214
|
+
videoStyle = _ref5$videoStyle === void 0 ? {} : _ref5$videoStyle;
|
|
2215
|
+
var _useParticipant2 = useParticipant(participantId),
|
|
2216
|
+
webcamOn = _useParticipant2.webcamOn,
|
|
2217
|
+
webcamStream = _useParticipant2.webcamStream,
|
|
2218
|
+
isLocal = _useParticipant2.isLocal,
|
|
2219
|
+
screenShareStream = _useParticipant2.screenShareStream,
|
|
2220
|
+
screenShareOn = _useParticipant2.screenShareOn;
|
|
2221
|
+
var videoRef = useRef(null);
|
|
2222
|
+
useEffect(function () {
|
|
2223
|
+
var stream = type === 'share' ? screenShareStream : webcamStream;
|
|
2224
|
+
var isOn = type === 'share' ? screenShareOn : webcamOn;
|
|
2225
|
+
if (videoRef.current) {
|
|
2226
|
+
if (isOn && stream) {
|
|
2227
|
+
var mediaStream = new MediaStream();
|
|
2228
|
+
mediaStream.addTrack(stream.track);
|
|
2229
|
+
videoRef.current.srcObject = mediaStream;
|
|
2230
|
+
videoRef.current.play()["catch"](function (error) {
|
|
2231
|
+
return console.error('videoRef.current.play() failed', error);
|
|
2232
|
+
});
|
|
2233
|
+
} else {
|
|
2234
|
+
videoRef.current.srcObject = null;
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
}, [type].concat(type === 'share' ? [screenShareOn, screenShareStream] : type === 'video' ? [webcamOn, webcamStream] : []));
|
|
2238
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2239
|
+
ref: ref,
|
|
2240
|
+
className: "video-container participant-video-" + participantId + " " + (className || ''),
|
|
2241
|
+
style: _extends({
|
|
2242
|
+
objectFit: type === 'share' ? 'contain' : 'none',
|
|
2243
|
+
height: '100%'
|
|
2244
|
+
}, containerStyle)
|
|
2245
|
+
}, /*#__PURE__*/React.createElement("video", {
|
|
2246
|
+
width: "100%",
|
|
2247
|
+
height: "100%",
|
|
2248
|
+
ref: videoRef,
|
|
2249
|
+
autoPlay: true,
|
|
2250
|
+
className: classNameVideo,
|
|
2251
|
+
style: isLocal && type !== 'share' ? _extends({
|
|
2252
|
+
transform: 'scaleX(-1)',
|
|
2253
|
+
WebkitTransform: 'scaleX(-1)'
|
|
2254
|
+
}, videoStyle) : videoStyle
|
|
2255
|
+
}));
|
|
2256
|
+
});
|
|
2257
|
+
var VideoPlayer = function VideoPlayer(_ref6) {
|
|
2258
|
+
var participantId = _ref6.participantId,
|
|
2259
|
+
type = _ref6.type,
|
|
2260
|
+
props = _objectWithoutPropertiesLoose(_ref6, _excluded);
|
|
2261
|
+
var VideoPlayerComponent = useMemo(function () {
|
|
2262
|
+
return type === 'share' ? VideoSDKPlayer : withAdaptiveObservers(VideoSDKPlayer);
|
|
2263
|
+
}, [type, participantId]);
|
|
2264
|
+
return /*#__PURE__*/React.createElement(VideoPlayerComponent, _extends({
|
|
2265
|
+
participantId: participantId,
|
|
2266
|
+
type: type
|
|
2267
|
+
}, props));
|
|
2268
|
+
};
|
|
2269
|
+
var AudioPlayer = function AudioPlayer(_ref7) {
|
|
2270
|
+
var participantId = _ref7.participantId,
|
|
2271
|
+
type = _ref7.type;
|
|
2272
|
+
var _useParticipant3 = useParticipant(participantId),
|
|
2273
|
+
micStream = _useParticipant3.micStream,
|
|
2274
|
+
isLocal = _useParticipant3.isLocal,
|
|
2275
|
+
screenShareAudioStream = _useParticipant3.screenShareAudioStream;
|
|
2276
|
+
var micRef = useRef(null);
|
|
2277
|
+
useEffect(function () {
|
|
2278
|
+
if (micRef.current) {
|
|
2279
|
+
var audioStream = type === 'shareAudio' ? screenShareAudioStream : micStream;
|
|
2280
|
+
if (audioStream) {
|
|
2281
|
+
var mediaStream = new MediaStream();
|
|
2282
|
+
mediaStream.addTrack(audioStream.track);
|
|
2283
|
+
micRef.current.srcObject = mediaStream;
|
|
2284
|
+
micRef.current.play()["catch"](function (error) {
|
|
2285
|
+
return console.error('micRef.current.play() failed', error);
|
|
2286
|
+
});
|
|
2287
|
+
} else {
|
|
2288
|
+
micRef.current.srcObject = null;
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
}, [micStream, screenShareAudioStream, type]);
|
|
2292
|
+
return /*#__PURE__*/React.createElement("audio", {
|
|
2293
|
+
ref: micRef,
|
|
2294
|
+
autoPlay: true,
|
|
2295
|
+
playsInline: true,
|
|
2296
|
+
muted: isLocal
|
|
2297
|
+
});
|
|
2298
|
+
};
|
|
2029
2299
|
|
|
2030
|
-
export { Constants, MeetingConsumer, MeetingProvider, createCameraVideoTrack, createMicrophoneAudioTrack, createScreenShareVideoTrack, getNetworkStats, useCharacter, useConnection, useFile, useMediaDevice, useMeeting, useParticipant, usePubSub, useTranscription, useWhiteboard };
|
|
2300
|
+
export { AudioPlayer, Constants, MeetingConsumer, MeetingProvider, VideoPlayer, createCameraVideoTrack, createMicrophoneAudioTrack, createScreenShareVideoTrack, getNetworkStats, useCharacter, useConnection, useFile, useMediaDevice, useMeeting, useParticipant, usePubSub, useTranscription, useWhiteboard, withAdaptiveObservers };
|
|
2031
2301
|
//# sourceMappingURL=index.modern.js.map
|