@stream-io/video-react-sdk 0.3.43 → 0.3.45
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 +14 -0
- package/dist/index.cjs.js +18 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +18 -5
- package/dist/index.es.js.map +1 -1
- package/dist/src/core/components/Video/Video.d.ts +12 -0
- package/dist/src/translations/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Button/CompositeButton.tsx +13 -8
- package/src/components/DeviceSettings/DeviceSettings.tsx +16 -11
- package/src/core/components/Video/Video.tsx +20 -0
- package/src/translations/en.json +1 -0
|
@@ -14,8 +14,20 @@ export type VideoProps = ComponentPropsWithoutRef<'video'> & {
|
|
|
14
14
|
* Override the default UI that's visible when a participant turned off their video.
|
|
15
15
|
*/
|
|
16
16
|
VideoPlaceholder?: ComponentType<VideoPlaceholderProps>;
|
|
17
|
+
/**
|
|
18
|
+
* An object with setRef functions
|
|
19
|
+
* meant for exposing some of the internal elements of this component.
|
|
20
|
+
*/
|
|
17
21
|
refs?: {
|
|
22
|
+
/**
|
|
23
|
+
* The video element that's used to play the video stream.
|
|
24
|
+
* @param element the video element.
|
|
25
|
+
*/
|
|
18
26
|
setVideoElement?: (element: HTMLVideoElement | null) => void;
|
|
27
|
+
/**
|
|
28
|
+
* The video placeholder element that's used when the video stream is not playing.
|
|
29
|
+
* @param element the video placeholder element.
|
|
30
|
+
*/
|
|
19
31
|
setVideoPlaceholderElement?: (element: HTMLDivElement | null) => void;
|
|
20
32
|
};
|
|
21
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { MenuToggle, ToggleMenuButtonProps } from '../Menu';
|
|
3
3
|
import { ComponentType, forwardRef, PropsWithChildren } from 'react';
|
|
4
|
+
import { useI18n } from '@stream-io/video-react-bindings';
|
|
4
5
|
import { Placement } from '@floating-ui/react';
|
|
5
6
|
|
|
6
7
|
import { IconButton } from './IconButton';
|
|
@@ -39,12 +40,16 @@ export const CompositeButton = forwardRef<
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
const ToggleMenuButton = forwardRef<HTMLButtonElement, ToggleMenuButtonProps>(
|
|
42
|
-
({ menuShown }, ref) =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
({ menuShown }, ref) => {
|
|
44
|
+
const { t } = useI18n();
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<IconButton
|
|
48
|
+
className={'str-video__menu-toggle-button'}
|
|
49
|
+
icon={menuShown ? 'caret-down' : 'caret-up'}
|
|
50
|
+
title={t('Toggle device menu')}
|
|
51
|
+
ref={ref}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
},
|
|
50
55
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
+
import { useI18n } from '@stream-io/video-react-bindings';
|
|
2
3
|
import { MenuToggle, ToggleMenuButtonProps } from '../Menu';
|
|
3
4
|
import {
|
|
4
5
|
DeviceSelectorAudioInput,
|
|
@@ -25,15 +26,19 @@ const Menu = () => (
|
|
|
25
26
|
);
|
|
26
27
|
|
|
27
28
|
const ToggleMenuButton = forwardRef<HTMLButtonElement, ToggleMenuButtonProps>(
|
|
28
|
-
({ menuShown }, ref) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
({ menuShown }, ref) => {
|
|
30
|
+
const { t } = useI18n();
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<IconButton
|
|
34
|
+
className={clsx('str-video__device-settings__button', {
|
|
35
|
+
'str-video__device-settings__button--active': menuShown,
|
|
36
|
+
})}
|
|
37
|
+
title={t('Toggle device menu')}
|
|
38
|
+
icon="device-settings"
|
|
39
|
+
ref={ref}
|
|
40
|
+
// tabindex={0}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
},
|
|
39
44
|
);
|
|
@@ -31,8 +31,20 @@ export type VideoProps = ComponentPropsWithoutRef<'video'> & {
|
|
|
31
31
|
* Override the default UI that's visible when a participant turned off their video.
|
|
32
32
|
*/
|
|
33
33
|
VideoPlaceholder?: ComponentType<VideoPlaceholderProps>;
|
|
34
|
+
/**
|
|
35
|
+
* An object with setRef functions
|
|
36
|
+
* meant for exposing some of the internal elements of this component.
|
|
37
|
+
*/
|
|
34
38
|
refs?: {
|
|
39
|
+
/**
|
|
40
|
+
* The video element that's used to play the video stream.
|
|
41
|
+
* @param element the video element.
|
|
42
|
+
*/
|
|
35
43
|
setVideoElement?: (element: HTMLVideoElement | null) => void;
|
|
44
|
+
/**
|
|
45
|
+
* The video placeholder element that's used when the video stream is not playing.
|
|
46
|
+
* @param element the video placeholder element.
|
|
47
|
+
*/
|
|
36
48
|
setVideoPlaceholderElement?: (element: HTMLDivElement | null) => void;
|
|
37
49
|
};
|
|
38
50
|
};
|
|
@@ -93,6 +105,11 @@ export const Video = ({
|
|
|
93
105
|
setIsWideMode(width >= height);
|
|
94
106
|
};
|
|
95
107
|
|
|
108
|
+
// playback may have started before we had a chance to
|
|
109
|
+
// attach the 'play/pause' event listener, so we set the state
|
|
110
|
+
// here to make sure it's in sync
|
|
111
|
+
setIsVideoPaused(videoElement.paused);
|
|
112
|
+
|
|
96
113
|
videoElement.addEventListener('play', handlePlayPause);
|
|
97
114
|
videoElement.addEventListener('pause', handlePlayPause);
|
|
98
115
|
track.addEventListener('unmute', handlePlayPause);
|
|
@@ -100,6 +117,9 @@ export const Video = ({
|
|
|
100
117
|
videoElement.removeEventListener('play', handlePlayPause);
|
|
101
118
|
videoElement.removeEventListener('pause', handlePlayPause);
|
|
102
119
|
track.removeEventListener('unmute', handlePlayPause);
|
|
120
|
+
|
|
121
|
+
// reset the 'pause' state once we unmount the video element
|
|
122
|
+
setIsVideoPaused(true);
|
|
103
123
|
};
|
|
104
124
|
}, [stream, videoElement]);
|
|
105
125
|
|