@livedigital/client 2.41.0 → 2.41.1
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/engine/system/index.d.ts +1 -0
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/engine/system/index.ts +28 -9
package/package.json
CHANGED
|
@@ -4,6 +4,16 @@ import EnhancedEventEmitter from '../../EnhancedEventEmitter';
|
|
|
4
4
|
import { AvailableMediaDevices, DeviceErrors } from '../../types/common';
|
|
5
5
|
import Logger from '../Logger';
|
|
6
6
|
|
|
7
|
+
const isUnexpectedError = (errorMessage: string) => {
|
|
8
|
+
const errors: string[] = [
|
|
9
|
+
DeviceErrors.NotFoundError,
|
|
10
|
+
DeviceErrors.NotAllowedError,
|
|
11
|
+
DeviceErrors.DeviceIsBusy,
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
return !errors.includes(errorMessage);
|
|
15
|
+
};
|
|
16
|
+
|
|
7
17
|
class System {
|
|
8
18
|
public isEnableVideoDevicesLock = false;
|
|
9
19
|
|
|
@@ -113,18 +123,14 @@ class System {
|
|
|
113
123
|
try {
|
|
114
124
|
tracks = await this.requestMediaDevicesAccess();
|
|
115
125
|
} catch (errorVideoAndAudio) {
|
|
116
|
-
if (
|
|
126
|
+
if (isUnexpectedError(errorVideoAndAudio.message)) {
|
|
117
127
|
throw errorVideoAndAudio;
|
|
118
128
|
}
|
|
119
129
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
throw errorAudioOnly;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
tracks = await this.requestMediaDevicesAccess({ video: true });
|
|
130
|
+
/* if device is busy that means we have permissions */
|
|
131
|
+
if (errorVideoAndAudio.message !== DeviceErrors.DeviceIsBusy) {
|
|
132
|
+
await this.assertHasAccessToMediaDevices({ audio: true });
|
|
133
|
+
await this.assertHasAccessToMediaDevices({ video: true });
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
136
|
|
|
@@ -158,6 +164,19 @@ class System {
|
|
|
158
164
|
listenDevices(): void {
|
|
159
165
|
navigator.mediaDevices.addEventListener('devicechange', this.deviceChangeHandler);
|
|
160
166
|
}
|
|
167
|
+
|
|
168
|
+
private async assertHasAccessToMediaDevices(
|
|
169
|
+
constraints: MediaStreamConstraints = { video: true, audio: true },
|
|
170
|
+
): Promise<void> {
|
|
171
|
+
try {
|
|
172
|
+
const tracks = await this.requestMediaDevicesAccess(constraints);
|
|
173
|
+
tracks.forEach((track) => track.stop());
|
|
174
|
+
} catch (accessError) {
|
|
175
|
+
if (isUnexpectedError(accessError.message)) {
|
|
176
|
+
throw accessError;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
161
180
|
}
|
|
162
181
|
|
|
163
182
|
export default System;
|