@agilemotion/oui-react-js 1.5.5 → 1.5.7

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.
@@ -71,6 +71,8 @@ var _CallEnd = _interopRequireDefault(require("@material-ui/icons/CallEnd"));
71
71
 
72
72
  var _Dock = _interopRequireDefault(require("@material-ui/icons/Dock"));
73
73
 
74
+ var _Settings = _interopRequireDefault(require("@material-ui/icons/Settings"));
75
+
74
76
  var _icons = require("@material-ui/icons");
75
77
 
76
78
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -99,6 +101,12 @@ class Icon extends _react.Component {
99
101
  color: this.props.color
100
102
  }
101
103
  });
104
+ } else if (this.props.id === 'SETTINGS') {
105
+ return /*#__PURE__*/_react.default.createElement(_Settings.default, {
106
+ style: {
107
+ color: this.props.color
108
+ }
109
+ });
102
110
  } else if (this.props.id === 'PAN_TOOL') {
103
111
  return /*#__PURE__*/_react.default.createElement(_icons.PanTool, null);
104
112
  } else if (this.props.id === 'PEOPLE') {
@@ -127,6 +127,20 @@ class SocketManager {
127
127
  }
128
128
  });
129
129
 
130
+ _defineProperty(this, "endSession", meetingId => {
131
+ if (this.socket) {
132
+ this.emitEvent(_VCEventType.VCEventType.LEAVE_MEETING, {
133
+ userId: sessionStorage.getItem("username"),
134
+ meetingId: meetingId
135
+ }).then(() => {
136
+ this.emitEvent(_VCEventType.VCEventType.END_SESSION, {
137
+ userId: sessionStorage.getItem("username"),
138
+ meetingId: meetingId
139
+ }).catch(error => {});
140
+ }).catch(error => {});
141
+ }
142
+ });
143
+
130
144
  this.usersOnline = [];
131
145
  this.profile = null;
132
146
  }
@@ -39,6 +39,16 @@ var _ToolbarButton = _interopRequireDefault(require("./ToolbarButton"));
39
39
 
40
40
  var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
41
41
 
42
+ var _Grow = _interopRequireDefault(require("@material-ui/core/Grow"));
43
+
44
+ var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
45
+
46
+ var _ClickAwayListener = _interopRequireDefault(require("@material-ui/core/ClickAwayListener"));
47
+
48
+ var _MenuList = _interopRequireDefault(require("@material-ui/core/MenuList"));
49
+
50
+ var _Popper = _interopRequireDefault(require("@material-ui/core/Popper"));
51
+
42
52
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
53
 
44
54
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -52,7 +62,9 @@ const Toolbar = props => {
52
62
  const [isRecording, setIsRecording] = (0, _react.useState)(false);
53
63
  const [autoPermit, setAutoPermit] = (0, _react.useState)(false);
54
64
  const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
65
+ const [leaveButtonAnchorEl, setLeaveButtonAnchorEl] = (0, _react.useState)(null);
55
66
  const openMoreActions = Boolean(anchorEl);
67
+ const leaveButtonOpen = Boolean(leaveButtonAnchorEl);
56
68
  const [screenShared, setScreenShared] = (0, _react.useState)(false);
57
69
  const [roomStatus, setRoomStatus] = (0, _react.useState)();
58
70
  const [raisedHandsNames, setRaisedHandsNames] = (0, _react.useState)([]);
@@ -117,6 +129,14 @@ const Toolbar = props => {
117
129
  setAnchorEl(null);
118
130
  };
119
131
 
132
+ const handleLeaveButtonClick = event => {
133
+ setLeaveButtonAnchorEl(event.currentTarget);
134
+ };
135
+
136
+ const handleLeaveButtonClose = () => {
137
+ setLeaveButtonAnchorEl(null);
138
+ };
139
+
120
140
  const muteVideo = () => {
121
141
  setVideoMuted(prevStatus => !prevStatus);
122
142
  };
@@ -167,6 +187,10 @@ const Toolbar = props => {
167
187
  eventHandler.endCall();
168
188
  };
169
189
 
190
+ const endSession = () => {
191
+ eventHandler.endSession();
192
+ };
193
+
170
194
  const showPeople = () => {
171
195
  eventHandler.showPeople();
172
196
  };
@@ -438,12 +462,44 @@ const Toolbar = props => {
438
462
  }
439
463
  }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
440
464
  id: 'MORE'
441
- })))), /*#__PURE__*/_react.default.createElement("div", {
465
+ })))), (isHost && participants.length === 0 || !isHost) && /*#__PURE__*/_react.default.createElement("div", {
442
466
  className: 'button-wrapper col no-margin no-padding hang-up'
443
467
  }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
444
- title: "Hang up"
468
+ title: "Leave"
445
469
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
446
470
  onClick: endCall,
471
+ style: {
472
+ backgroundColor: '#eb3f21',
473
+ color: 'white',
474
+ marginRight: '4px',
475
+ minWidth: '120px',
476
+ width: '120px',
477
+ height: '60px'
478
+ },
479
+ startIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
480
+ id: 'CALL_END'
481
+ })
482
+ }, /*#__PURE__*/_react.default.createElement("span", {
483
+ style: {
484
+ marginRight: '8px',
485
+ fontSize: '12px'
486
+ }
487
+ }, "Leave")))), isHost && participants.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
488
+ className: 'button-wrapper col no-margin no-padding hang-up'
489
+ }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
490
+ title: "Leave"
491
+ }, /*#__PURE__*/_react.default.createElement(_Button.default, {
492
+ variant: "contained",
493
+ color: "primary",
494
+ size: "large",
495
+ onClick: handleLeaveButtonClick,
496
+ startIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
497
+ id: 'CALL_END'
498
+ }),
499
+ ref: leaveButtonAnchorEl,
500
+ "aria-controls": leaveButtonOpen ? 'toolbar-menu' : undefined,
501
+ "aria-haspopup": "true",
502
+ "aria-expanded": leaveButtonOpen ? 'true' : undefined,
447
503
  style: {
448
504
  backgroundColor: '#eb3f21',
449
505
  color: 'white',
@@ -457,9 +513,59 @@ const Toolbar = props => {
457
513
  marginRight: '8px',
458
514
  fontSize: '12px'
459
515
  }
460
- }, "Hang up"), /*#__PURE__*/_react.default.createElement(_Icon.default, {
461
- id: 'CALL_END'
462
- }))))))), /*#__PURE__*/_react.default.createElement(_core.Menu, {
516
+ }, "Leave"))))))), /*#__PURE__*/_react.default.createElement(_core.Menu, {
517
+ anchorEl: leaveButtonAnchorEl,
518
+ id: "toobar-menu",
519
+ open: leaveButtonOpen,
520
+ onClose: handleLeaveButtonClose,
521
+ onClick: handleLeaveButtonClose,
522
+ PaperProps: {
523
+ elevation: 0,
524
+ style: {
525
+ boxShadow: '0 8px 16px 0 rgba(0, 0, 0, 0.2)'
526
+ },
527
+ sx: {
528
+ overflow: 'visible',
529
+ filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
530
+ mt: 1.5,
531
+ '& .MuiList-root': {},
532
+ '& .MuiAvatar-root': {
533
+ width: 32,
534
+ height: 32,
535
+ ml: -0.5,
536
+ mr: 1
537
+ },
538
+ '&:before': {
539
+ content: '""',
540
+ display: 'block',
541
+ position: 'absolute',
542
+ top: 0,
543
+ right: 14,
544
+ width: 10,
545
+ height: 10,
546
+ bgcolor: 'primary',
547
+ transform: 'translateY(-50%) rotate(45deg)',
548
+ zIndex: 0
549
+ }
550
+ }
551
+ },
552
+ transformOrigin: {
553
+ horizontal: 120,
554
+ vertical: -60
555
+ },
556
+ anchorOrigin: {
557
+ horizontal: 'right',
558
+ vertical: 'top'
559
+ }
560
+ }, /*#__PURE__*/_react.default.createElement(_core.MenuItem, {
561
+ onClick: () => {
562
+ endCall();
563
+ }
564
+ }, "Leave"), /*#__PURE__*/_react.default.createElement(_core.MenuItem, {
565
+ onClick: () => {
566
+ endSession();
567
+ }
568
+ }, "End session")), /*#__PURE__*/_react.default.createElement(_core.Menu, {
463
569
  anchorEl: anchorEl,
464
570
  id: "toobar-menu",
465
571
  open: openMoreActions,
@@ -130,6 +130,10 @@ const TrainingRoom = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.defau
130
130
  onLowerHand(be.payload);
131
131
  break;
132
132
 
133
+ case _VCEventType.VCEventType.END_SESSION:
134
+ hangUp();
135
+ break;
136
+
133
137
  case _VCEventType.VCEventType.SHARING_STOPPED:
134
138
  setScreenShared(false);
135
139
  setStartScreenSharing(false);
@@ -301,7 +305,7 @@ const TrainingRoom = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.defau
301
305
  setDisplayState(initialContext ? initialContext.windowDisplayState : 'MAXIMIZED');
302
306
  });
303
307
 
304
- _VCEventManager.default.addSubscriptions(eventHandler, _VCEventType.VCEventType.REQUEST_TO_JOIN_MEETING, _VCEventType.VCEventType.USER_JOINED, _VCEventType.VCEventType.USER_LEFT_MEETING, _VCEventType.VCEventType.SYSTEM_EVENT, _VCEventType.VCEventType.SOCKET_CONNECT, _VCEventType.VCEventType.SOCKET_DISCONNECT, _VCEventType.VCEventType.RAISE_HAND, _VCEventType.VCEventType.LOWER_HAND, _VCEventType.VCEventType.PEER_DISCONNECT, _VCEventType.VCEventType.CONSUMER_TRANSPORT_FAILED, _VCEventType.VCEventType.CREATE_TRANSPORT_FAILED, _VCEventType.VCEventType.SHARING_STOPPED);
308
+ _VCEventManager.default.addSubscriptions(eventHandler, _VCEventType.VCEventType.REQUEST_TO_JOIN_MEETING, _VCEventType.VCEventType.USER_JOINED, _VCEventType.VCEventType.USER_LEFT_MEETING, _VCEventType.VCEventType.SYSTEM_EVENT, _VCEventType.VCEventType.SOCKET_CONNECT, _VCEventType.VCEventType.SOCKET_DISCONNECT, _VCEventType.VCEventType.RAISE_HAND, _VCEventType.VCEventType.LOWER_HAND, _VCEventType.VCEventType.PEER_DISCONNECT, _VCEventType.VCEventType.CONSUMER_TRANSPORT_FAILED, _VCEventType.VCEventType.CREATE_TRANSPORT_FAILED, _VCEventType.VCEventType.SHARING_STOPPED, _VCEventType.VCEventType.END_SESSION);
305
309
 
306
310
  document.addEventListener('sideBarToggleEvent', handleSidebarToggle);
307
311
 
@@ -412,6 +416,21 @@ const TrainingRoom = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.defau
412
416
  setSideBarTab('');
413
417
  };
414
418
 
419
+ const endSession = () => {
420
+ _ApplicationManager.default.openConfirmDialog("Are you sure you want to end the current session?", result => {
421
+ if (result === true) {
422
+ _SocketManager.default.endSession(props.calendarEvent.id);
423
+
424
+ _ApplicationManager.default.setHasActiveMeeting(false);
425
+
426
+ _ApplicationManager.default.removeLoadedGraph(false);
427
+
428
+ setSideBarOpen(false);
429
+ setSideBarTab('');
430
+ }
431
+ });
432
+ };
433
+
415
434
  const emitSystemEvent = (eventType, data, toParticipantIds = null) => {
416
435
  let participantIds = [];
417
436
 
@@ -490,6 +509,9 @@ const TrainingRoom = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.defau
490
509
  endCall: () => {
491
510
  hangUp();
492
511
  },
512
+ endSession: () => {
513
+ endSession();
514
+ },
493
515
  showChat: () => {
494
516
  fetchChats();
495
517
  },
@@ -69,6 +69,8 @@ _defineProperty(VCEventType, "END_CALL", "END_CALL");
69
69
 
70
70
  _defineProperty(VCEventType, "LEAVE_MEETING", "LEAVE_MEETING");
71
71
 
72
+ _defineProperty(VCEventType, "END_SESSION", "END_SESSION");
73
+
72
74
  _defineProperty(VCEventType, "CALL_ENDED", "CALL_ENDED");
73
75
 
74
76
  _defineProperty(VCEventType, "ALL_USERS", "ALL_USERS");
@@ -15,7 +15,7 @@ var _VCEventType = require("./VCEventType");
15
15
 
16
16
  var _VCEventManager = _interopRequireDefault(require("./VCEventManager"));
17
17
 
18
- var _Recorder = _interopRequireDefault(require("./Recorder"));
18
+ var _VCRoomRecorder = _interopRequireDefault(require("./VCRoomRecorder"));
19
19
 
20
20
  var _MediaSoupHelper = _interopRequireDefault(require("./MediaSoupHelper"));
21
21
 
@@ -409,7 +409,7 @@ const VCRoomParticipant = props => {
409
409
  audioRef.current = stream;
410
410
 
411
411
  if (props.isHost && type === 'audio') {
412
- _Recorder.default.addTrack(props.data.userId, track);
412
+ _VCRoomRecorder.default.addTrack(props.data.userId, track);
413
413
 
414
414
  tracks.current.setAudioTrack(track);
415
415
  }
@@ -420,29 +420,38 @@ const VCRoomParticipant = props => {
420
420
  tracks.current.setVideoTrack(track);
421
421
  }
422
422
 
423
- let producer = await producerTransport.produce(params);
424
- producerTransport.getStats().then(data => console.log(data));
425
- producers.set(type, producer);
423
+ let producer;
426
424
 
427
- if (type === 'video') {
428
- videoRef.current.srcObject = stream;
429
- videoStream.current = stream;
430
- setVideoRefresher(!videoRefresher);
431
- console.log(stream);
425
+ try {
426
+ producer = await producerTransport.produce(params);
427
+ } catch (e) {
428
+ console.log(e);
432
429
  }
433
430
 
434
- producer.on('transportclose', () => {
435
- stream.srcObject.getTracks().forEach(function (track) {
436
- track.stop();
431
+ if (producer) {
432
+ producerTransport.getStats().then(data => console.log(data));
433
+ producers.set(type, producer);
434
+
435
+ if (type === 'video') {
436
+ videoRef.current.srcObject = stream;
437
+ videoStream.current = stream;
438
+ setVideoRefresher(!videoRefresher);
439
+ console.log(stream);
440
+ }
441
+
442
+ producer.on('transportclose', () => {
443
+ stream.srcObject.getTracks().forEach(function (track) {
444
+ track.stop();
445
+ });
446
+ producers.delete(type);
437
447
  });
438
- producers.delete(type);
439
- });
440
- producer.on('close', () => {
441
- stream.srcObject.getTracks().forEach(function (track) {
442
- track.stop();
448
+ producer.on('close', () => {
449
+ stream.srcObject.getTracks().forEach(function (track) {
450
+ track.stop();
451
+ });
452
+ producers.delete(type);
443
453
  });
444
- producers.delete(type);
445
- });
454
+ }
446
455
  };
447
456
 
448
457
  const stopProducing = (type, callback) => {
@@ -517,8 +526,8 @@ const VCRoomParticipant = props => {
517
526
  track.stop();
518
527
  });
519
528
 
520
- if (userId && _Recorder.default) {
521
- _Recorder.default.removeTrack(userId);
529
+ if (userId && _VCRoomRecorder.default) {
530
+ _VCRoomRecorder.default.removeTrack(userId);
522
531
  }
523
532
 
524
533
  let elementById = document.getElementById(props.data.userId + '-audio-el-container');
@@ -561,7 +570,7 @@ const VCRoomParticipant = props => {
561
570
  document.getElementById('meeting-audio-el-container').appendChild(audioElement);
562
571
 
563
572
  if (props.isHost) {
564
- _Recorder.default.addTrack(userId, stream.getAudioTracks()[0]);
573
+ _VCRoomRecorder.default.addTrack(userId, stream.getAudioTracks()[0]);
565
574
  }
566
575
  }
567
576
  }
@@ -674,22 +683,7 @@ const VCRoomParticipant = props => {
674
683
  id: 'MIC_OFF'
675
684
  }) : /*#__PURE__*/_react.default.createElement(_Icon.default, {
676
685
  id: 'MIC'
677
- })), props.data.inView && numberOfInViewParticipants > 1 && /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
678
- title: "Remove from view"
679
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
680
- onClick: e => {
681
- stopProducing('video');
682
- props.onRemoveFromView(props.data);
683
- },
684
- style: {
685
- marginRight: '4px',
686
- width: '16px',
687
- height: '16px',
688
- color: 'white'
689
- }
690
- }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
691
- id: 'CLOSE'
692
- }))), props.isHost && !videoMuted && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
686
+ })), props.isHost && !videoMuted && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
693
687
  onClick: e => {
694
688
  props.onHostVideoMute(props.data);
695
689
  },
@@ -732,11 +726,10 @@ const VCRoomParticipant = props => {
732
726
  "aria-haspopup": "true",
733
727
  "aria-expanded": openMoreActions ? 'true' : undefined,
734
728
  style: {
735
- color: '#198754',
736
729
  height: '8px'
737
730
  }
738
731
  }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
739
- id: 'MIC'
732
+ id: 'SETTINGS'
740
733
  }))))))), !props.isCurrentUser && /*#__PURE__*/_react.default.createElement("span", {
741
734
  style: {
742
735
  marginLeft: '4px'
@@ -89,6 +89,7 @@
89
89
 
90
90
  @media (max-device-width: 820px) {
91
91
  .meetingParticipantContainer {
92
+ text-align: center;
92
93
  min-width: 100% !important;
93
94
  }
94
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilemotion/oui-react-js",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "babel": {
5
5
  "presets": [
6
6
  "@babel/preset-env",
@@ -1,235 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _SocketManager = _interopRequireDefault(require("../SocketManager"));
9
-
10
- var _VCEventManager = _interopRequireDefault(require("./VCEventManager"));
11
-
12
- var _VCEventType = require("./VCEventType");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
-
18
- const {
19
- electron
20
- } = window;
21
-
22
- class Recorder {
23
- constructor() {
24
- _defineProperty(this, "init", async (meetingId, meetingTitle) => {
25
- this.meetingId = meetingId;
26
- this.meetingTitle = meetingTitle;
27
- });
28
-
29
- _defineProperty(this, "addTrack", (id, track) => {
30
- console.log("ADDING TRACK FOR : " + id);
31
- this.audioTracks.set(id, track);
32
-
33
- if (this.recorder && this.recorder.state === 'recording') {
34
- let mediaStream = new MediaStream([track]);
35
- const mediaStreamAudioSourceNode = new MediaStreamAudioSourceNode(this.audioContext, {
36
- mediaStream: mediaStream
37
- });
38
- mediaStreamAudioSourceNode.connect(this.mediaStreamAudioDestinationNode);
39
- }
40
- });
41
-
42
- _defineProperty(this, "removeTrack", id => {
43
- if (this.audioTracks.has(id)) {
44
- this.audioTracks.delete(id);
45
- }
46
- });
47
-
48
- _defineProperty(this, "handleRecordingDataAvailable", e => {
49
- if (e.data.size > 0) {
50
- console.log("ADDED CHUNK : " + this.recordingSequence);
51
- const blob = new Blob([e.data], {
52
- type: "video/webm"
53
- });
54
- const data = {
55
- userId: _VCEventManager.default.getUserDetails().userId,
56
- meetingId: this.meetingId,
57
- name: this.meetingTitle,
58
- type: blob.type,
59
- size: blob.size,
60
- sequenceNumber: this.recordingSequence,
61
- sessionId: this.currentRecordingId
62
- };
63
- const reader = new FileReader();
64
- reader.readAsDataURL(blob);
65
-
66
- let _this = this;
67
-
68
- reader.onload = function (evt) {
69
- const result = evt.target.result;
70
- _this.recordingType = blob.type;
71
- _this.recordingSize += blob.size;
72
- data.recordedData = result.replace('data:video/webm;base64,', '');
73
- console.log("======== SAVING RECORDING CHUNK =========");
74
- console.log(data);
75
-
76
- _SocketManager.default.emitEvent(_VCEventType.VCEventType.SAVE_RECORDING, data).then(data => {
77
- console.log("===== SAVE RECORDING SUCCESS ======");
78
-
79
- if (!_this.isRecording) {
80
- console.log("======= STOPPING RECORDING =======", _this.meetingTitle);
81
- const data = {
82
- meetingId: _this.meetingId,
83
- name: _this.meetingTitle,
84
- type: _this.recordingType,
85
- size: _this.recordingSize,
86
- sequenceNumber: _this.recordingSequence,
87
- sessionId: _this.currentRecordingId
88
- };
89
-
90
- _SocketManager.default.emitEvent(_VCEventType.VCEventType.STOP_RECORDING, data).catch(error => {});
91
- }
92
- }).catch(error => {
93
- console.log("===== SAVE RECORDING ERROR ======");
94
- });
95
- };
96
-
97
- _this.recordingSequence++;
98
- } else {
99
- console.log("no data to push");
100
- }
101
- });
102
-
103
- _defineProperty(this, "recordMeeting", async () => {
104
- this.recorder = await this.createMediaRecorder();
105
-
106
- let _this = this;
107
-
108
- if (this.recorder != null) {
109
- _SocketManager.default.emitEvent(_VCEventType.VCEventType.TOGGLE_RECORD_MEETING, {
110
- roomID: _this.meetingId,
111
- isRecording: true
112
- }).then(data => {
113
- console.log("RECORDING STARTED : " + data.id);
114
- _this.currentRecordingId = data.id;
115
- _this.recordingSequence = 0;
116
- _this.recordingSize = 0;
117
- _this.recordingType = '';
118
-
119
- _this.recorder.start(60000);
120
-
121
- _this.isRecording = true;
122
- }).catch(error => {
123
- console.log("RECORD START ERROR");
124
- console.log(error);
125
- });
126
- }
127
- });
128
-
129
- _defineProperty(this, "stopRecordingMeeting", () => {
130
- try {
131
- this.isRecording = false;
132
-
133
- _SocketManager.default.emitEvent(_VCEventType.VCEventType.TOGGLE_RECORD_MEETING, {
134
- roomID: this.meetingId,
135
- isRecording: false
136
- }).catch(error => {});
137
-
138
- if (this.recorder && this.recorder.state === 'recording') {
139
- if (this.recorder.stream) {
140
- var _this$recorder$stream;
141
-
142
- if (((_this$recorder$stream = this.recorder.stream.getVideoTracks()) === null || _this$recorder$stream === void 0 ? void 0 : _this$recorder$stream.length) > 0) {
143
- this.recorder.stream.getVideoTracks()[0].stop();
144
- }
145
- }
146
-
147
- this.recorder.stop();
148
- }
149
- } catch (e) {
150
- console.error(e);
151
- }
152
- });
153
-
154
- _defineProperty(this, "handleStopRecording", e => {
155
- this.isRecording = false;
156
- });
157
-
158
- _defineProperty(this, "createMediaRecorder", () => {
159
- return new Promise((resolve, reject) => {
160
- electron.ipcRenderer.getMainWindowId().then(id => {
161
- if (id) {
162
- const videoConstraints = {
163
- audio: false,
164
- video: {
165
- mandatory: {
166
- chromeMediaSource: 'desktop',
167
- chromeMediaSourceId: id,
168
- minWidth: 1280,
169
- maxWidth: 1280,
170
- minHeight: 720,
171
- maxHeight: 720
172
- }
173
- }
174
- };
175
-
176
- let _this = this;
177
-
178
- navigator.mediaDevices.getUserMedia(videoConstraints).then(stream => {
179
- const options = {
180
- mimeType: "video/webm; codecs=vp9"
181
- };
182
- let audioContext = new AudioContext();
183
- let mediaStreamAudioDestinationNode = new MediaStreamAudioDestinationNode(audioContext);
184
- let tracks = [mediaStreamAudioDestinationNode.stream.getAudioTracks()[0], stream.getVideoTracks()[0]];
185
-
186
- if (this.audioTracks.size > 0) {
187
- for (const value of this.audioTracks.values()) {
188
- tracks.push(value);
189
- let mediaStreamAudioSourceNode = new MediaStreamAudioSourceNode(audioContext, {
190
- mediaStream: new MediaStream([value])
191
- });
192
- mediaStreamAudioSourceNode.connect(mediaStreamAudioDestinationNode);
193
- }
194
- } else {
195
- let mediaStreamAudioSourceNode = new MediaStreamAudioSourceNode(audioContext, {
196
- mediaStream: new MediaStream(tracks)
197
- });
198
- mediaStreamAudioSourceNode.connect(mediaStreamAudioDestinationNode);
199
- }
200
-
201
- console.log("INIT WITH TRACKS : ", tracks);
202
- let initialMediaStream = new MediaStream(tracks);
203
- const recorder = new MediaRecorder(initialMediaStream, options);
204
- recorder.ondataavailable = _this.handleRecordingDataAvailable;
205
- recorder.onstop = _this.handleStopRecording;
206
- this.audioContext = audioContext;
207
- this.mediaStreamAudioDestinationNode = mediaStreamAudioDestinationNode;
208
- resolve(recorder);
209
- }).catch(e => {
210
- console.error(e);
211
- reject(new Error(e.message));
212
- });
213
- } else {
214
- reject(new Error("Cannot initialize recorder. Application screen source not found"));
215
- }
216
- });
217
- });
218
- });
219
-
220
- this.meetingId = null;
221
- this.meetingTitle = '';
222
- this.recordingSequence = 0;
223
- this.currentRecordingId = null;
224
- this.recordingType = null;
225
- this.recordingSize = null;
226
- this.isRecording = false;
227
- this.recorder = null;
228
- this.audioTracks = new Map();
229
- }
230
-
231
- }
232
-
233
- const instance = new Recorder();
234
- var _default = instance;
235
- exports.default = _default;