@stream-io/video-react-sdk 1.14.3 → 1.14.4
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/CHANGELOG.md +11 -0
- package/dist/index.cjs.js +26 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +26 -10
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/usePersistedDevicePreferences.ts +49 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-sdk",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.4",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@floating-ui/react": "^0.27.6",
|
|
33
|
-
"@stream-io/video-client": "1.
|
|
33
|
+
"@stream-io/video-client": "1.20.0",
|
|
34
34
|
"@stream-io/video-filters-web": "0.1.7",
|
|
35
|
-
"@stream-io/video-react-bindings": "1.5.
|
|
35
|
+
"@stream-io/video-react-bindings": "1.5.16",
|
|
36
36
|
"chart.js": "^4.4.4",
|
|
37
37
|
"clsx": "^2.0.0",
|
|
38
38
|
"react-chartjs-2": "^5.3.0"
|
|
@@ -41,17 +41,36 @@ const defaultDevice = 'default';
|
|
|
41
41
|
export const usePersistedDevicePreferences = (
|
|
42
42
|
key: string = '@stream-io/device-preferences',
|
|
43
43
|
): void => {
|
|
44
|
-
const {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const {
|
|
45
|
+
useCallSettings,
|
|
46
|
+
useCameraState,
|
|
47
|
+
useMicrophoneState,
|
|
48
|
+
useSpeakerState,
|
|
49
|
+
} = useCallStateHooks();
|
|
50
|
+
const settings = useCallSettings();
|
|
51
|
+
|
|
52
|
+
usePersistedDevicePreference(
|
|
53
|
+
key,
|
|
54
|
+
'camera',
|
|
55
|
+
useCameraState(),
|
|
56
|
+
settings ? !settings.video.camera_default_on : undefined,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
usePersistedDevicePreference(
|
|
60
|
+
key,
|
|
61
|
+
'microphone',
|
|
62
|
+
useMicrophoneState(),
|
|
63
|
+
settings ? !settings.audio.mic_default_on : undefined,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
usePersistedDevicePreference(key, 'speaker', useSpeakerState(), false);
|
|
49
67
|
};
|
|
50
68
|
|
|
51
69
|
const usePersistedDevicePreference = <K extends DeviceKey>(
|
|
52
70
|
key: string,
|
|
53
71
|
deviceKey: K,
|
|
54
72
|
state: DeviceState<K>,
|
|
73
|
+
defaultMuted?: boolean,
|
|
55
74
|
): void => {
|
|
56
75
|
const { useCallCallingState } = useCallStateHooks();
|
|
57
76
|
const callingState = useCallCallingState();
|
|
@@ -65,6 +84,7 @@ const usePersistedDevicePreference = <K extends DeviceKey>(
|
|
|
65
84
|
if (
|
|
66
85
|
callingState === CallingState.LEFT ||
|
|
67
86
|
!state.devices?.length ||
|
|
87
|
+
typeof defaultMuted !== 'boolean' ||
|
|
68
88
|
applyingState !== 'idle'
|
|
69
89
|
) {
|
|
70
90
|
return;
|
|
@@ -75,8 +95,16 @@ const usePersistedDevicePreference = <K extends DeviceKey>(
|
|
|
75
95
|
|
|
76
96
|
setApplyingState('applying');
|
|
77
97
|
|
|
78
|
-
if (
|
|
79
|
-
|
|
98
|
+
if (!manager.state.selectedDevice) {
|
|
99
|
+
const applyPromise = preference
|
|
100
|
+
? applyLocalDevicePreference(
|
|
101
|
+
manager,
|
|
102
|
+
[preference].flat(),
|
|
103
|
+
state.devices,
|
|
104
|
+
)
|
|
105
|
+
: applyMutedState(manager, defaultMuted);
|
|
106
|
+
|
|
107
|
+
applyPromise
|
|
80
108
|
.catch((err) => {
|
|
81
109
|
console.warn(
|
|
82
110
|
`Failed to apply ${deviceKey} device preferences`,
|
|
@@ -88,7 +116,15 @@ const usePersistedDevicePreference = <K extends DeviceKey>(
|
|
|
88
116
|
setApplyingState('applied');
|
|
89
117
|
}
|
|
90
118
|
},
|
|
91
|
-
[
|
|
119
|
+
[
|
|
120
|
+
applyingState,
|
|
121
|
+
callingState,
|
|
122
|
+
defaultMuted,
|
|
123
|
+
deviceKey,
|
|
124
|
+
key,
|
|
125
|
+
manager,
|
|
126
|
+
state.devices,
|
|
127
|
+
],
|
|
92
128
|
);
|
|
93
129
|
|
|
94
130
|
useEffect(
|
|
@@ -206,10 +242,14 @@ const applyLocalDevicePreference = async (
|
|
|
206
242
|
}
|
|
207
243
|
|
|
208
244
|
if (typeof muted === 'boolean') {
|
|
209
|
-
await manager
|
|
245
|
+
await applyMutedState(manager, muted);
|
|
210
246
|
}
|
|
211
247
|
};
|
|
212
248
|
|
|
249
|
+
const applyMutedState = async (manager: DeviceManagerLike, muted: boolean) => {
|
|
250
|
+
await manager[muted ? 'disable' : 'enable']?.();
|
|
251
|
+
};
|
|
252
|
+
|
|
213
253
|
const getSelectedDevicePreference = (
|
|
214
254
|
devices: MediaDeviceInfo[],
|
|
215
255
|
selectedDevice: string | undefined,
|