@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.
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { memo, useState, useEffect, Fragment as Fragment$1, createContext, useContext, useCallback, useMemo, useRef, isValidElement, forwardRef, useLayoutEffect, lazy, Suspense } from 'react';
3
- import { useCall, useCallStateHooks, useI18n, Restricted, useToggleCallRecording, useConnectedUser, useEffectEvent, useIsAudioConnecting, useIsVideoConnecting, StreamCallProvider, StreamVideoProvider } from '@stream-io/video-react-bindings';
4
- import { hasAudio, hasScreenShareAudio, hasVideo, hasScreenShare, OwnCapability, Browsers, VisibilityState, hasPausedTrack, createSoundDetector, SfuModels, isPinned, name, NoiseCancellationSettingsModeEnum, CallingState, combineComparators, screenSharing, speakerLayoutSortPreset, paginatedLayoutSortPreset, CallTypes, defaultSortPreset, humanize, StreamVideoClient } from '@stream-io/video-client';
3
+ import { useCall, useCallStateHooks, useI18n, Restricted, useToggleCallRecording, useConnectedUser, useEffectEvent, useIsAudioConnecting, useIsVideoConnecting, StreamCallProvider, StreamVideoProvider, useSpeakerLayoutSortPreset } from '@stream-io/video-react-bindings';
4
+ import { hasAudio, hasScreenShareAudio, hasVideo, hasScreenShare, OwnCapability, Browsers, VisibilityState, hasPausedTrack, createSoundDetector, SfuModels, isPinned, name, NoiseCancellationSettingsModeEnum, CallingState, paginatedLayoutSortPreset, CallTypes, defaultSortPreset, humanize, StreamVideoClient } from '@stream-io/video-client';
5
5
  import { useFloating, offset, shift, flip, size, autoUpdate, FloatingOverlay, FloatingPortal, arrow, FloatingArrow, useListItem, useListNavigation, useTypeahead, useClick, useDismiss, useRole, useInteractions, FloatingFocusManager, FloatingList } from '@floating-ui/react';
6
6
  import clsx from 'clsx';
7
7
 
@@ -1208,7 +1208,7 @@ const SpeakerTest = (props) => {
1208
1208
  const audioElementRef = useRef(null);
1209
1209
  const [isPlaying, setIsPlaying] = useState(false);
1210
1210
  const { t } = useI18n();
1211
- const { audioUrl = `https://unpkg.com/${"@stream-io/video-react-sdk"}@${"1.39.2"}/assets/piano.mp3`, } = props;
1211
+ const { audioUrl = `https://unpkg.com/${"@stream-io/video-react-sdk"}@${"1.40.0"}/assets/piano.mp3`, } = props;
1212
1212
  // Update audio output device when selection changes
1213
1213
  useEffect(() => {
1214
1214
  const audio = audioElementRef.current;
@@ -1894,15 +1894,30 @@ const DefaultScreenShareOverlay = () => {
1894
1894
  };
1895
1895
  return (jsxs("div", { className: "str-video__screen-share-overlay", children: [jsx(Icon, { icon: "screen-share-off" }), jsx("span", { className: "str-video__screen-share-overlay__title", children: t('You are presenting your screen') }), jsxs("button", { onClick: stopScreenShare, type: "button", className: "str-video__screen-share-overlay__button", children: [jsx(Icon, { icon: "close" }), " ", t('Stop Screen Sharing')] })] }));
1896
1896
  };
1897
- const DefaultParticipantViewUI = ({ indicatorsVisible = true, menuPlacement = 'bottom-start', showMenuButton = true, ParticipantActionsContextMenu: ParticipantActionsContextMenu$1 = ParticipantActionsContextMenu, }) => {
1897
+ /**
1898
+ * Rendered over a remote participant's tile when the browser's autoplay policy
1899
+ * has blocked their audio. Selecting it calls `call.resumeAudio()`, unblocking
1900
+ * every blocked element at once.
1901
+ */
1902
+ const DefaultAudioBlockedNotification = () => {
1903
+ const call = useCall();
1904
+ const { t } = useI18n();
1905
+ return (jsx("button", { type: "button", className: "str-video__audio-blocked-notification", onClick: call?.resumeAudio, "aria-live": "polite", children: jsxs("span", { className: "str-video__audio-blocked-notification__message", children: [jsx(Icon, { icon: "speaker" }), jsxs("span", { className: "str-video__audio-blocked-notification__text", children: [jsx("span", { className: "str-video__audio-blocked-notification__title", children: t('Audio is blocked by your system') }), jsx("span", { className: "str-video__audio-blocked-notification__subtitle", children: t('Click or tap to play audio') })] })] }) }));
1906
+ };
1907
+ const DefaultParticipantViewUI = ({ indicatorsVisible = true, menuPlacement = 'bottom-start', showMenuButton = true, ParticipantActionsContextMenu: ParticipantActionsContextMenu$1 = ParticipantActionsContextMenu, AudioBlockedNotification = DefaultAudioBlockedNotification, }) => {
1898
1908
  const { participant, trackType } = useParticipantViewContext();
1909
+ const { useAutoplayBlockedSessionIds } = useCallStateHooks();
1910
+ const blockedSessionIds = useAutoplayBlockedSessionIds();
1899
1911
  const isScreenSharing = hasScreenShare(participant);
1912
+ const shouldShowAudioBlockedNotification = !participant.isLocalParticipant &&
1913
+ trackType !== 'screenShareTrack' &&
1914
+ blockedSessionIds.includes(participant.sessionId);
1900
1915
  if (participant.isLocalParticipant &&
1901
1916
  isScreenSharing &&
1902
1917
  trackType === 'screenShareTrack') {
1903
1918
  return (jsxs(Fragment, { children: [jsx(DefaultScreenShareOverlay, {}), jsx(ParticipantDetails, { indicatorsVisible: indicatorsVisible })] }));
1904
1919
  }
1905
- return (jsxs(Fragment, { children: [showMenuButton && (jsx(MenuToggle, { strategy: "fixed", placement: menuPlacement, ToggleButton: ToggleButton, children: jsx(ParticipantActionsContextMenu$1, {}) })), jsx(Reaction, { participant: participant }), jsx(ParticipantDetails, { indicatorsVisible: indicatorsVisible })] }));
1920
+ return (jsxs(Fragment, { children: [showMenuButton && (jsx(MenuToggle, { strategy: "fixed", placement: menuPlacement, ToggleButton: ToggleButton, children: jsx(ParticipantActionsContextMenu$1, {}) })), jsx(Reaction, { participant: participant }), jsx(ParticipantDetails, { indicatorsVisible: indicatorsVisible }), AudioBlockedNotification && shouldShowAudioBlockedNotification && (jsx(AudioBlockedNotification, {}))] }));
1906
1921
  };
1907
1922
  const ParticipantDetails = ({ indicatorsVisible = true, }) => {
1908
1923
  const { participant, trackType } = useParticipantViewContext();
@@ -2059,6 +2074,8 @@ var en = {
2059
2074
  "You have no permission to share your audio": "You have no permission to share your audio",
2060
2075
  "You are presenting your screen": "You are presenting your screen",
2061
2076
  "Stop Screen Sharing": "Stop Screen Sharing",
2077
+ "Audio is blocked by your system": "Audio is blocked by your system",
2078
+ "Click or tap to play audio": "Click or tap to play audio",
2062
2079
  Allow: Allow,
2063
2080
  Revoke: Revoke,
2064
2081
  Dismiss: Dismiss,
@@ -2293,22 +2310,6 @@ const usePaginatedLayoutSortPreset = (call) => {
2293
2310
  };
2294
2311
  }, [call]);
2295
2312
  };
2296
- const useSpeakerLayoutSortPreset = (call, isOneOnOneCall) => {
2297
- useEffect(() => {
2298
- if (!call)
2299
- return;
2300
- // always show the remote participant in the spotlight
2301
- if (isOneOnOneCall) {
2302
- call.setSortParticipantsBy(combineComparators(screenSharing, loggedIn));
2303
- }
2304
- else {
2305
- call.setSortParticipantsBy(speakerLayoutSortPreset);
2306
- }
2307
- return () => {
2308
- resetSortPreset(call);
2309
- };
2310
- }, [call, isOneOnOneCall]);
2311
- };
2312
2313
  const useRawRemoteParticipants = () => {
2313
2314
  const { useRawParticipants } = useCallStateHooks();
2314
2315
  const rawParticipants = useRawParticipants();
@@ -2319,13 +2320,6 @@ const resetSortPreset = (call) => {
2319
2320
  const callConfig = CallTypes.get(call.type);
2320
2321
  call.setSortParticipantsBy(callConfig.options.sortParticipantsBy || defaultSortPreset);
2321
2322
  };
2322
- const loggedIn = (a, b) => {
2323
- if (a.isLocalParticipant)
2324
- return 1;
2325
- if (b.isLocalParticipant)
2326
- return -1;
2327
- return 0;
2328
- };
2329
2323
 
2330
2324
  const LivestreamLayout = (props) => {
2331
2325
  const { useParticipants, useHasOngoingScreenShare } = useCallStateHooks();