@stream-io/video-react-sdk 1.14.2 → 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/dist/index.cjs.js CHANGED
@@ -80,12 +80,13 @@ const defaultDevice = 'default';
80
80
  * @param key the key to use for local storage.
81
81
  */
82
82
  const usePersistedDevicePreferences = (key = '@stream-io/device-preferences') => {
83
- const { useCameraState, useMicrophoneState, useSpeakerState } = videoReactBindings.useCallStateHooks();
84
- usePersistedDevicePreference(key, 'camera', useCameraState());
85
- usePersistedDevicePreference(key, 'microphone', useMicrophoneState());
86
- usePersistedDevicePreference(key, 'speaker', useSpeakerState());
83
+ const { useCallSettings, useCameraState, useMicrophoneState, useSpeakerState, } = videoReactBindings.useCallStateHooks();
84
+ const settings = useCallSettings();
85
+ usePersistedDevicePreference(key, 'camera', useCameraState(), settings ? !settings.video.camera_default_on : undefined);
86
+ usePersistedDevicePreference(key, 'microphone', useMicrophoneState(), settings ? !settings.audio.mic_default_on : undefined);
87
+ usePersistedDevicePreference(key, 'speaker', useSpeakerState(), false);
87
88
  };
88
- const usePersistedDevicePreference = (key, deviceKey, state) => {
89
+ const usePersistedDevicePreference = (key, deviceKey, state, defaultMuted) => {
89
90
  const { useCallCallingState } = videoReactBindings.useCallStateHooks();
90
91
  const callingState = useCallCallingState();
91
92
  const [applyingState, setApplyingState] = react.useState('idle');
@@ -93,14 +94,18 @@ const usePersistedDevicePreference = (key, deviceKey, state) => {
93
94
  react.useEffect(function apply() {
94
95
  if (callingState === videoClient.CallingState.LEFT ||
95
96
  !state.devices?.length ||
97
+ typeof defaultMuted !== 'boolean' ||
96
98
  applyingState !== 'idle') {
97
99
  return;
98
100
  }
99
101
  const preferences = parseLocalDevicePreferences(key);
100
102
  const preference = preferences[deviceKey];
101
103
  setApplyingState('applying');
102
- if (preference && !manager.state.selectedDevice) {
103
- applyLocalDevicePreference(manager, [preference].flat(), state.devices)
104
+ if (!manager.state.selectedDevice) {
105
+ const applyPromise = preference
106
+ ? applyLocalDevicePreference(manager, [preference].flat(), state.devices)
107
+ : applyMutedState(manager, defaultMuted);
108
+ applyPromise
104
109
  .catch((err) => {
105
110
  console.warn(`Failed to apply ${deviceKey} device preferences`, err);
106
111
  })
@@ -109,7 +114,15 @@ const usePersistedDevicePreference = (key, deviceKey, state) => {
109
114
  else {
110
115
  setApplyingState('applied');
111
116
  }
112
- }, [applyingState, callingState, deviceKey, key, manager, state.devices]);
117
+ }, [
118
+ applyingState,
119
+ callingState,
120
+ defaultMuted,
121
+ deviceKey,
122
+ key,
123
+ manager,
124
+ state.devices,
125
+ ]);
113
126
  react.useEffect(function persist() {
114
127
  if (callingState === videoClient.CallingState.LEFT ||
115
128
  !state.devices?.length ||
@@ -189,9 +202,12 @@ const applyLocalDevicePreference = async (manager, preference, devices) => {
189
202
  }
190
203
  }
191
204
  if (typeof muted === 'boolean') {
192
- await manager[muted ? 'disable' : 'enable']?.();
205
+ await applyMutedState(manager, muted);
193
206
  }
194
207
  };
208
+ const applyMutedState = async (manager, muted) => {
209
+ await manager[muted ? 'disable' : 'enable']?.();
210
+ };
195
211
  const getSelectedDevicePreference = (devices, selectedDevice) => ({
196
212
  selectedDeviceId: selectedDevice || defaultDevice,
197
213
  selectedDeviceLabel: devices?.find((d) => d.deviceId === selectedDevice)?.label ?? '',
@@ -2656,13 +2672,15 @@ const VerticalScrollButtons = ({ scrollWrapper, }) => {
2656
2672
  };
2657
2673
 
2658
2674
  const Pip = (props) => {
2659
- const { excludeLocalParticipant = false, filterParticipants, mirrorLocalParticipantVideo = true, VideoPlaceholder, ParticipantViewUI = DefaultParticipantViewUI, PictureInPicturePlaceholder, } = props;
2675
+ const { t } = videoReactBindings.useI18n();
2676
+ const { excludeLocalParticipant = false, filterParticipants, mirrorLocalParticipantVideo = true, VideoPlaceholder, ParticipantViewUI = DefaultParticipantViewUI, } = props;
2660
2677
  const [layoutWrapperElement, setLayoutWrapperElement] = react.useState(null);
2661
2678
  const call = videoReactBindings.useCall();
2662
2679
  const participants = useFilteredParticipants({
2663
2680
  excludeLocalParticipant,
2664
2681
  filterParticipants,
2665
2682
  });
2683
+ const screenSharingParticipant = participants.find((p) => videoClient.hasScreenShare(p));
2666
2684
  usePaginatedLayoutSortPreset(call);
2667
2685
  react.useEffect(() => {
2668
2686
  if (!layoutWrapperElement || !call)
@@ -2672,7 +2690,8 @@ const Pip = (props) => {
2672
2690
  const mirror = mirrorLocalParticipantVideo ? undefined : false;
2673
2691
  if (!call)
2674
2692
  return null;
2675
- return (jsxRuntime.jsx("div", { className: "str-video__pip-layout", ref: setLayoutWrapperElement, children: participants.map((participant) => (jsxRuntime.jsx(ParticipantView, { participant: participant, muteAudio: true, mirror: mirror, VideoPlaceholder: VideoPlaceholder, PictureInPicturePlaceholder: PictureInPicturePlaceholder, ParticipantViewUI: ParticipantViewUI }, participant.sessionId))) }));
2693
+ return (jsxRuntime.jsxs("div", { className: "str-video__pip-layout", ref: setLayoutWrapperElement, children: [screenSharingParticipant &&
2694
+ (screenSharingParticipant.isLocalParticipant ? (jsxRuntime.jsxs("div", { className: "str-video__pip-screen-share-local", children: [jsxRuntime.jsx(Icon, { icon: "screen-share-off" }), jsxRuntime.jsx("span", { className: "str-video__pip-screen-share-local__title", children: t('You are presenting your screen') })] })) : (jsxRuntime.jsx(ParticipantView, { participant: screenSharingParticipant, trackType: "screenShareTrack", muteAudio: true, mirror: false, VideoPlaceholder: VideoPlaceholder, ParticipantViewUI: ParticipantViewUI }))), participants.map((participant) => (jsxRuntime.jsx(ParticipantView, { participant: participant, muteAudio: true, mirror: mirror, VideoPlaceholder: VideoPlaceholder, ParticipantViewUI: ParticipantViewUI }, participant.sessionId)))] }));
2676
2695
  };
2677
2696
  Pip.displayName = 'PipLayout.Pip';
2678
2697
  const Host = () => {
@@ -2707,7 +2726,7 @@ const LivestreamPlayer = (props) => {
2707
2726
  return (jsxRuntime.jsx(StreamCall, { call: call, children: jsxRuntime.jsx(LivestreamLayout, { ...layoutProps }) }));
2708
2727
  };
2709
2728
 
2710
- const [major, minor, patch] = ("1.14.2").split('.');
2729
+ const [major, minor, patch] = ("1.14.4").split('.');
2711
2730
  videoClient.setSdkInfo({
2712
2731
  type: videoClient.SfuModels.SdkType.REACT,
2713
2732
  major,