@livedigital/client 2.37.2 → 2.37.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.
@@ -230,7 +230,8 @@ export declare enum DeviceErrors {
230
230
  NotFoundError = "NotFoundError",
231
231
  NoDevices = "NoDevices",
232
232
  DeviceIsBusy = "DeviceIsBusy",
233
- NotAllowedError = "NotAllowedError"
233
+ NotAllowedError = "NotAllowedError",
234
+ RequestDevicesUnknownError = "RequestDevicesUnknownError"
234
235
  }
235
236
  export declare type TrackInboundStats = {
236
237
  consumerId: string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@livedigital/client",
3
3
  "author": "vlprojects",
4
4
  "license": "MIT",
5
- "version": "2.37.2",
5
+ "version": "2.37.3",
6
6
  "private": false,
7
7
  "bugs": {
8
8
  "url": "https://github.com/vlprojects/livedigital-sdk/issues"
@@ -49,10 +49,12 @@ class System {
49
49
  this.availableAudioDevices = availableAudioDevices;
50
50
  }
51
51
 
52
- async requestMediaDevicesAccess(constraints: MediaStreamConstraints = { video: true, audio: true }): Promise<void> {
52
+ async requestMediaDevicesAccess(
53
+ constraints: MediaStreamConstraints = { video: true, audio: true },
54
+ ): Promise<MediaStreamTrack[]> {
53
55
  try {
54
56
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
55
- stream.getTracks().forEach((track) => track.stop());
57
+ return stream.getTracks();
56
58
  } catch (error) {
57
59
  this.logger.error('getUserMedia()', { error, constraints });
58
60
 
@@ -67,6 +69,8 @@ class System {
67
69
  if (error.name === 'NotFoundError') {
68
70
  throw new Error(DeviceErrors.NotFoundError);
69
71
  }
72
+
73
+ throw new Error(DeviceErrors.RequestDevicesUnknownError);
70
74
  }
71
75
  }
72
76
 
@@ -101,25 +105,26 @@ class System {
101
105
  }
102
106
 
103
107
  async detectDevices(): Promise<void> {
108
+ let tracks: MediaStreamTrack[] = [];
104
109
  if (this.isDevicesDetected) {
105
110
  return;
106
111
  }
107
112
 
108
113
  try {
109
- await this.requestMediaDevicesAccess();
114
+ tracks = await this.requestMediaDevicesAccess();
110
115
  } catch (errorVideoAndAudio) {
111
116
  if (![DeviceErrors.NotFoundError, DeviceErrors.NotAllowedError].includes(errorVideoAndAudio.message)) {
112
117
  throw errorVideoAndAudio;
113
118
  }
114
119
 
115
120
  try {
116
- await this.requestMediaDevicesAccess({ audio: true });
121
+ tracks = await this.requestMediaDevicesAccess({ audio: true });
117
122
  } catch (errorAudioOnly) {
118
123
  if (![DeviceErrors.NotFoundError, DeviceErrors.NotAllowedError].includes(errorAudioOnly.message)) {
119
124
  throw errorAudioOnly;
120
125
  }
121
126
 
122
- await this.requestMediaDevicesAccess({ video: true });
127
+ tracks = await this.requestMediaDevicesAccess({ video: true });
123
128
  }
124
129
  }
125
130
 
@@ -128,6 +133,7 @@ class System {
128
133
  // at this moment or access to device granted or no devices exists
129
134
 
130
135
  const rawDevices = await this.refreshAvailableMediaDevicesList();
136
+ tracks.forEach((track) => track.stop());
131
137
  const hasAudioInputDevices = rawDevices.some((x) => x.kind === 'audioinput');
132
138
  const hasVideoInputDevices = rawDevices.some((x) => x.kind === 'videoinput');
133
139
 
@@ -286,6 +286,7 @@ export enum DeviceErrors {
286
286
  NoDevices = 'NoDevices',
287
287
  DeviceIsBusy = 'DeviceIsBusy',
288
288
  NotAllowedError = 'NotAllowedError',
289
+ RequestDevicesUnknownError = 'RequestDevicesUnknownError',
289
290
  }
290
291
 
291
292
  export type TrackInboundStats = {