@stream-io/video-react-sdk 1.39.2 → 1.40.0

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.
@@ -1210,7 +1210,7 @@ const SpeakerTest = (props) => {
1210
1210
  const audioElementRef = react.useRef(null);
1211
1211
  const [isPlaying, setIsPlaying] = react.useState(false);
1212
1212
  const { t } = videoReactBindings.useI18n();
1213
- const { audioUrl = `https://unpkg.com/${"@stream-io/video-react-sdk"}@${"1.39.2"}/assets/piano.mp3`, } = props;
1213
+ const { audioUrl = `https://unpkg.com/${"@stream-io/video-react-sdk"}@${"1.40.0"}/assets/piano.mp3`, } = props;
1214
1214
  // Update audio output device when selection changes
1215
1215
  react.useEffect(() => {
1216
1216
  const audio = audioElementRef.current;
@@ -1896,15 +1896,30 @@ const DefaultScreenShareOverlay = () => {
1896
1896
  };
1897
1897
  return (jsxRuntime.jsxs("div", { className: "str-video__screen-share-overlay", children: [jsxRuntime.jsx(Icon, { icon: "screen-share-off" }), jsxRuntime.jsx("span", { className: "str-video__screen-share-overlay__title", children: t('You are presenting your screen') }), jsxRuntime.jsxs("button", { onClick: stopScreenShare, type: "button", className: "str-video__screen-share-overlay__button", children: [jsxRuntime.jsx(Icon, { icon: "close" }), " ", t('Stop Screen Sharing')] })] }));
1898
1898
  };
1899
- const DefaultParticipantViewUI = ({ indicatorsVisible = true, menuPlacement = 'bottom-start', showMenuButton = true, ParticipantActionsContextMenu: ParticipantActionsContextMenu$1 = ParticipantActionsContextMenu, }) => {
1899
+ /**
1900
+ * Rendered over a remote participant's tile when the browser's autoplay policy
1901
+ * has blocked their audio. Selecting it calls `call.resumeAudio()`, unblocking
1902
+ * every blocked element at once.
1903
+ */
1904
+ const DefaultAudioBlockedNotification = () => {
1905
+ const call = videoReactBindings.useCall();
1906
+ const { t } = videoReactBindings.useI18n();
1907
+ return (jsxRuntime.jsx("button", { type: "button", className: "str-video__audio-blocked-notification", onClick: call?.resumeAudio, "aria-live": "polite", children: jsxRuntime.jsxs("span", { className: "str-video__audio-blocked-notification__message", children: [jsxRuntime.jsx(Icon, { icon: "speaker" }), jsxRuntime.jsxs("span", { className: "str-video__audio-blocked-notification__text", children: [jsxRuntime.jsx("span", { className: "str-video__audio-blocked-notification__title", children: t('Audio is blocked by your system') }), jsxRuntime.jsx("span", { className: "str-video__audio-blocked-notification__subtitle", children: t('Click or tap to play audio') })] })] }) }));
1908
+ };
1909
+ const DefaultParticipantViewUI = ({ indicatorsVisible = true, menuPlacement = 'bottom-start', showMenuButton = true, ParticipantActionsContextMenu: ParticipantActionsContextMenu$1 = ParticipantActionsContextMenu, AudioBlockedNotification = DefaultAudioBlockedNotification, }) => {
1900
1910
  const { participant, trackType } = useParticipantViewContext();
1911
+ const { useAutoplayBlockedSessionIds } = videoReactBindings.useCallStateHooks();
1912
+ const blockedSessionIds = useAutoplayBlockedSessionIds();
1901
1913
  const isScreenSharing = videoClient.hasScreenShare(participant);
1914
+ const shouldShowAudioBlockedNotification = !participant.isLocalParticipant &&
1915
+ trackType !== 'screenShareTrack' &&
1916
+ blockedSessionIds.includes(participant.sessionId);
1902
1917
  if (participant.isLocalParticipant &&
1903
1918
  isScreenSharing &&
1904
1919
  trackType === 'screenShareTrack') {
1905
1920
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DefaultScreenShareOverlay, {}), jsxRuntime.jsx(ParticipantDetails, { indicatorsVisible: indicatorsVisible })] }));
1906
1921
  }
1907
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showMenuButton && (jsxRuntime.jsx(MenuToggle, { strategy: "fixed", placement: menuPlacement, ToggleButton: ToggleButton, children: jsxRuntime.jsx(ParticipantActionsContextMenu$1, {}) })), jsxRuntime.jsx(Reaction, { participant: participant }), jsxRuntime.jsx(ParticipantDetails, { indicatorsVisible: indicatorsVisible })] }));
1922
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showMenuButton && (jsxRuntime.jsx(MenuToggle, { strategy: "fixed", placement: menuPlacement, ToggleButton: ToggleButton, children: jsxRuntime.jsx(ParticipantActionsContextMenu$1, {}) })), jsxRuntime.jsx(Reaction, { participant: participant }), jsxRuntime.jsx(ParticipantDetails, { indicatorsVisible: indicatorsVisible }), AudioBlockedNotification && shouldShowAudioBlockedNotification && (jsxRuntime.jsx(AudioBlockedNotification, {}))] }));
1908
1923
  };
1909
1924
  const ParticipantDetails = ({ indicatorsVisible = true, }) => {
1910
1925
  const { participant, trackType } = useParticipantViewContext();
@@ -2061,6 +2076,8 @@ var en = {
2061
2076
  "You have no permission to share your audio": "You have no permission to share your audio",
2062
2077
  "You are presenting your screen": "You are presenting your screen",
2063
2078
  "Stop Screen Sharing": "Stop Screen Sharing",
2079
+ "Audio is blocked by your system": "Audio is blocked by your system",
2080
+ "Click or tap to play audio": "Click or tap to play audio",
2064
2081
  Allow: Allow,
2065
2082
  Revoke: Revoke,
2066
2083
  Dismiss: Dismiss,
@@ -2295,22 +2312,6 @@ const usePaginatedLayoutSortPreset = (call) => {
2295
2312
  };
2296
2313
  }, [call]);
2297
2314
  };
2298
- const useSpeakerLayoutSortPreset = (call, isOneOnOneCall) => {
2299
- react.useEffect(() => {
2300
- if (!call)
2301
- return;
2302
- // always show the remote participant in the spotlight
2303
- if (isOneOnOneCall) {
2304
- call.setSortParticipantsBy(videoClient.combineComparators(videoClient.screenSharing, loggedIn));
2305
- }
2306
- else {
2307
- call.setSortParticipantsBy(videoClient.speakerLayoutSortPreset);
2308
- }
2309
- return () => {
2310
- resetSortPreset(call);
2311
- };
2312
- }, [call, isOneOnOneCall]);
2313
- };
2314
2315
  const useRawRemoteParticipants = () => {
2315
2316
  const { useRawParticipants } = videoReactBindings.useCallStateHooks();
2316
2317
  const rawParticipants = useRawParticipants();
@@ -2321,13 +2322,6 @@ const resetSortPreset = (call) => {
2321
2322
  const callConfig = videoClient.CallTypes.get(call.type);
2322
2323
  call.setSortParticipantsBy(callConfig.options.sortParticipantsBy || videoClient.defaultSortPreset);
2323
2324
  };
2324
- const loggedIn = (a, b) => {
2325
- if (a.isLocalParticipant)
2326
- return 1;
2327
- if (b.isLocalParticipant)
2328
- return -1;
2329
- return 0;
2330
- };
2331
2325
 
2332
2326
  const LivestreamLayout = (props) => {
2333
2327
  const { useParticipants, useHasOngoingScreenShare } = videoReactBindings.useCallStateHooks();
@@ -2552,7 +2546,7 @@ const SpeakerLayout = ({ ParticipantViewUIBar = DefaultParticipantViewUIBar, Par
2552
2546
  return () => cleanup?.();
2553
2547
  }, [participantsBarWrapperElement, call]);
2554
2548
  const isOneOnOneCall = allParticipants.length === 2;
2555
- useSpeakerLayoutSortPreset(call, isOneOnOneCall);
2549
+ videoReactBindings.useSpeakerLayoutSortPreset(call, isOneOnOneCall);
2556
2550
  useDragToScroll(participantsBarWrapperElement, {
2557
2551
  enabled: enableDragToScroll,
2558
2552
  });