@stream-io/video-react-sdk 1.18.2 → 1.18.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 +19 -0
- package/dist/index.cjs.js +18 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +18 -15
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/usePersistedDevicePreferences.ts +23 -20
- package/src/wrappers/LivestreamPlayer/LivestreamPlayer.tsx +6 -4
package/dist/index.es.js
CHANGED
|
@@ -106,14 +106,12 @@ const usePersistedDevicePreferences = (key = '@stream-io/device-preferences') =>
|
|
|
106
106
|
const preferences = parseLocalDevicePreferences(key);
|
|
107
107
|
const preference = preferences[deviceKey];
|
|
108
108
|
const manager = state[deviceKey];
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
}
|
|
109
|
+
const applyPromise = preference
|
|
110
|
+
? applyLocalDevicePreference(manager, [preference].flat(), state.devices)
|
|
111
|
+
: applyMutedState(manager, defaultMuted);
|
|
112
|
+
await applyPromise.catch((err) => {
|
|
113
|
+
console.warn(`Failed to apply ${deviceKey} device preferences`, err);
|
|
114
|
+
});
|
|
117
115
|
}
|
|
118
116
|
})().finally(() => setApplyingState((state) => (state === 'applying' ? 'applied' : state)));
|
|
119
117
|
}, [
|
|
@@ -310,7 +308,9 @@ const applyLocalDevicePreference = async (manager, preference, devices) => {
|
|
|
310
308
|
const device = devices.find((d) => d.deviceId === p.selectedDeviceId) ??
|
|
311
309
|
devices.find((d) => d.label === p.selectedDeviceLabel);
|
|
312
310
|
if (device) {
|
|
313
|
-
|
|
311
|
+
if (!manager.state.selectedDevice) {
|
|
312
|
+
await manager.select(device.deviceId);
|
|
313
|
+
}
|
|
314
314
|
muted = p.muted;
|
|
315
315
|
break;
|
|
316
316
|
}
|
|
@@ -320,7 +320,9 @@ const applyLocalDevicePreference = async (manager, preference, devices) => {
|
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
const applyMutedState = async (manager, muted) => {
|
|
323
|
-
|
|
323
|
+
if (!manager.state.status) {
|
|
324
|
+
await manager[muted ? 'disable' : 'enable']?.();
|
|
325
|
+
}
|
|
324
326
|
};
|
|
325
327
|
const getSelectedDevicePreference = (devices, selectedDevice) => ({
|
|
326
328
|
selectedDeviceId: selectedDevice || defaultDevice,
|
|
@@ -2895,7 +2897,7 @@ const useLivestreamCall = (props) => {
|
|
|
2895
2897
|
const call = useCall();
|
|
2896
2898
|
const { useIsCallLive, useOwnCapabilities } = useCallStateHooks();
|
|
2897
2899
|
const canJoinLive = useIsCallLive();
|
|
2898
|
-
const canJoinEarly =
|
|
2900
|
+
const canJoinEarly = useCanJoinEarly();
|
|
2899
2901
|
const canJoinBackstage = useOwnCapabilities()?.includes('join-backstage') ?? false;
|
|
2900
2902
|
const canJoinAsap = canJoinLive || canJoinEarly || canJoinBackstage;
|
|
2901
2903
|
const joinBehavior = props.joinBehavior ?? 'asap';
|
|
@@ -2912,20 +2914,21 @@ const useLivestreamCall = (props) => {
|
|
|
2912
2914
|
}, [call, canJoin, onError]);
|
|
2913
2915
|
return call;
|
|
2914
2916
|
};
|
|
2915
|
-
const
|
|
2917
|
+
const useCanJoinEarly = () => {
|
|
2916
2918
|
const { useCallStartsAt, useCallSettings } = useCallStateHooks();
|
|
2917
2919
|
const startsAt = useCallStartsAt();
|
|
2918
2920
|
const settings = useCallSettings();
|
|
2919
2921
|
const joinAheadTimeSeconds = settings?.backstage.join_ahead_time_seconds;
|
|
2920
|
-
const [canJoinEarly,
|
|
2922
|
+
const [canJoinEarly, setCanJoinEarly] = useState(() => checkCanJoinEarly(startsAt, joinAheadTimeSeconds));
|
|
2921
2923
|
useEffect(() => {
|
|
2922
2924
|
if (!canJoinEarly) {
|
|
2923
2925
|
const handle = setInterval(() => {
|
|
2924
|
-
|
|
2926
|
+
setCanJoinEarly(checkCanJoinEarly(startsAt, joinAheadTimeSeconds));
|
|
2925
2927
|
}, 1000);
|
|
2926
2928
|
return () => clearInterval(handle);
|
|
2927
2929
|
}
|
|
2928
2930
|
}, [canJoinEarly, startsAt, joinAheadTimeSeconds]);
|
|
2931
|
+
return canJoinEarly;
|
|
2929
2932
|
};
|
|
2930
2933
|
const checkCanJoinEarly = (startsAt, joinAheadTimeSeconds) => {
|
|
2931
2934
|
if (!startsAt) {
|
|
@@ -2934,7 +2937,7 @@ const checkCanJoinEarly = (startsAt, joinAheadTimeSeconds) => {
|
|
|
2934
2937
|
return Date.now() >= +startsAt - (joinAheadTimeSeconds ?? 0) * 1000;
|
|
2935
2938
|
};
|
|
2936
2939
|
|
|
2937
|
-
const [major, minor, patch] = ("1.18.
|
|
2940
|
+
const [major, minor, patch] = ("1.18.4").split('.');
|
|
2938
2941
|
setSdkInfo({
|
|
2939
2942
|
type: SfuModels.SdkType.REACT,
|
|
2940
2943
|
major,
|