@stream-io/video-react-native-sdk 0.0.1-alpha.352 → 0.0.1-alpha.353
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 +4 -0
- package/dist/src/components/utility/internal/ToggleAudioButton.js +2 -2
- package/dist/src/components/utility/internal/ToggleAudioButton.js.map +1 -1
- package/dist/src/components/utility/internal/ToggleVideoButton.js +2 -2
- package/dist/src/components/utility/internal/ToggleVideoButton.js.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -2
- package/dist/src/hooks/index.js +0 -2
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/providers/MediaStreamManagement/index.d.ts +16 -0
- package/dist/src/providers/MediaStreamManagement/index.js +27 -0
- package/dist/src/providers/MediaStreamManagement/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/components/utility/internal/ToggleAudioButton.tsx +3 -4
- package/src/components/utility/internal/ToggleVideoButton.tsx +3 -4
- package/src/hooks/index.ts +0 -2
- package/src/providers/MediaStreamManagement/index.tsx +47 -0
- package/dist/src/hooks/useCallControls.d.ts +0 -12
- package/dist/src/hooks/useCallControls.js +0 -43
- package/dist/src/hooks/useCallControls.js.map +0 -1
- package/src/hooks/useCallControls.tsx +0 -51
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.1-alpha.353](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-0.0.1-alpha.352...@stream-io/video-react-native-sdk-0.0.1-alpha.353) (2023-08-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [0.0.1-alpha.352](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-0.0.1-alpha.351...@stream-io/video-react-native-sdk-0.0.1-alpha.352) (2023-08-04)
|
|
6
10
|
|
|
7
11
|
|
|
@@ -33,12 +33,12 @@ const theme_1 = require("../../../theme");
|
|
|
33
33
|
const icons_1 = require("../../../icons");
|
|
34
34
|
const react_native_1 = require("react-native");
|
|
35
35
|
const utils_1 = require("../../../utils");
|
|
36
|
+
const providers_1 = require("../../../providers");
|
|
36
37
|
const ToggleAudioButton = () => {
|
|
37
38
|
const [isAwaitingApproval, setIsAwaitingApproval] = (0, react_1.useState)(false);
|
|
38
|
-
const {
|
|
39
|
+
const { isAudioMuted, toggleAudioMuted } = (0, providers_1.useMediaStreamManagement)();
|
|
39
40
|
const userHasSendAudioCapability = (0, video_react_bindings_1.useHasPermissions)(video_client_1.OwnCapability.SEND_AUDIO);
|
|
40
41
|
const { t } = (0, video_react_bindings_1.useI18n)();
|
|
41
|
-
const isAudioMuted = !isAudioPublished;
|
|
42
42
|
(0, hooks_1.usePermissionNotification)({
|
|
43
43
|
permission: video_client_1.OwnCapability.SEND_AUDIO,
|
|
44
44
|
messageApproved: t('You can now speak.'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleAudioButton.js","sourceRoot":"","sources":["../../../../../src/components/utility/internal/ToggleAudioButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,0DAAoE;AACpE,0EAKyC;AACzC,6DAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"ToggleAudioButton.js","sourceRoot":"","sources":["../../../../../src/components/utility/internal/ToggleAudioButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,0DAAoE;AACpE,0EAKyC;AACzC,6DAA0D;AAC1D,0CAA2D;AAC3D,0CAAuC;AACvC,0CAA6C;AAC7C,+CAAiD;AACjD,0CAAiD;AACjD,kDAA8D;AAEvD,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,MAAM,CAAC,kBAAkB,EAAE,qBA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AC7B;CACF,CAAC,CAAC"}
|
|
@@ -33,11 +33,11 @@ const react_native_1 = require("react-native");
|
|
|
33
33
|
const theme_1 = require("../../../theme");
|
|
34
34
|
const icons_1 = require("../../../icons");
|
|
35
35
|
const hooks_1 = require("../../../hooks");
|
|
36
|
+
const providers_1 = require("../../../providers");
|
|
36
37
|
const ToggleVideoButton = () => {
|
|
37
38
|
const [isAwaitingApproval, setIsAwaitingApproval] = (0, react_1.useState)(false);
|
|
38
|
-
const {
|
|
39
|
+
const { isVideoMuted, toggleVideoMuted } = (0, providers_1.useMediaStreamManagement)();
|
|
39
40
|
const { t } = (0, video_react_bindings_1.useI18n)();
|
|
40
|
-
const isVideoMuted = !isVideoPublished;
|
|
41
41
|
const userHasSendVideoCapability = (0, video_react_bindings_1.useHasPermissions)(video_client_1.OwnCapability.SEND_VIDEO);
|
|
42
42
|
const call = (0, video_react_bindings_1.useCall)();
|
|
43
43
|
(0, react_1.useEffect)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleVideoButton.js","sourceRoot":"","sources":["../../../../../src/components/utility/internal/ToggleVideoButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,0DAAoE;AACpE,0EAKyC;AACzC,6DAA0D;AAC1D,0CAAiD;AACjD,+CAAiD;AACjD,0CAAuC;AACvC,0CAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"ToggleVideoButton.js","sourceRoot":"","sources":["../../../../../src/components/utility/internal/ToggleVideoButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,0DAAoE;AACpE,0EAKyC;AACzC,6DAA0D;AAC1D,0CAAiD;AACjD,+CAAiD;AACjD,0CAAuC;AACvC,0CAAmD;AACnD,0CAA2D;AAC3D,kDAA8D;AAEvD,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,MAAM,CAAC,kBAAkB,EAAE,qBAA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AC7B;CACF,CAAC,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from './useCallControls';
|
|
2
1
|
export * from './useLocalVideoStream';
|
|
3
2
|
export * from './useIncallManager';
|
|
4
3
|
export * from './usePermissionRequest';
|
|
5
4
|
export * from './usePermissionNotification';
|
|
6
5
|
export * from './push';
|
|
7
6
|
export * from './useAndroidKeepCallAliveEffect';
|
|
8
|
-
export * from './useCallControls';
|
package/dist/src/hooks/index.js
CHANGED
|
@@ -14,12 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./useCallControls"), exports);
|
|
18
17
|
__exportStar(require("./useLocalVideoStream"), exports);
|
|
19
18
|
__exportStar(require("./useIncallManager"), exports);
|
|
20
19
|
__exportStar(require("./usePermissionRequest"), exports);
|
|
21
20
|
__exportStar(require("./usePermissionNotification"), exports);
|
|
22
21
|
__exportStar(require("./push"), exports);
|
|
23
22
|
__exportStar(require("./useAndroidKeepCallAliveEffect"), exports);
|
|
24
|
-
__exportStar(require("./useCallControls"), exports);
|
|
25
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,qDAAmC;AACnC,yDAAuC;AACvC,8DAA4C;AAC5C,yCAAuB;AACvB,kEAAgD"}
|
|
@@ -12,6 +12,14 @@ export type MediaStreamManagementContextAPI = {
|
|
|
12
12
|
* Publishes video stream for currently selected video input (camera) device to other call participants.
|
|
13
13
|
*/
|
|
14
14
|
publishVideoStream: () => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Signals whether local audio stream is muted/unmuted when in the call.
|
|
17
|
+
*/
|
|
18
|
+
isAudioMuted: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Signals whether local video stream is muted/unmuted when in the call.
|
|
21
|
+
*/
|
|
22
|
+
isVideoMuted: boolean;
|
|
15
23
|
/**
|
|
16
24
|
* Signals whether audio stream will be published when the call is joined.
|
|
17
25
|
*/
|
|
@@ -34,6 +42,14 @@ export type MediaStreamManagementContextAPI = {
|
|
|
34
42
|
* The latest value set will be used to decide, whether audio stream will be published when joining a call.
|
|
35
43
|
*/
|
|
36
44
|
toggleInitialVideoMuteState: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Toggles the video mute status, when in the call.
|
|
47
|
+
*/
|
|
48
|
+
toggleVideoMuted: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Toggles the audio mute status, when in the call.
|
|
51
|
+
*/
|
|
52
|
+
toggleAudioMuted: () => void;
|
|
37
53
|
/**
|
|
38
54
|
* Toggles the camera facing mode between front and back camera.
|
|
39
55
|
*/
|
|
@@ -45,9 +45,12 @@ const MediaStreamContext = (0, react_1.createContext)(null);
|
|
|
45
45
|
*/
|
|
46
46
|
const MediaStreamManagement = ({ children }) => {
|
|
47
47
|
const call = (0, video_react_bindings_1.useCall)();
|
|
48
|
+
const localParticipant = (0, video_react_bindings_1.useLocalParticipant)();
|
|
48
49
|
const callingState = (0, video_react_bindings_1.useCallCallingState)();
|
|
49
50
|
const videoDevices = (0, contexts_1.useStreamVideoStoreValue)((store) => store.videoDevices);
|
|
50
51
|
const localVideoStream = (0, video_react_bindings_1.useLocalParticipant)()?.videoStream;
|
|
52
|
+
const isAudioMuted = !localParticipant?.publishedTracks.includes(video_client_1.SfuModels.TrackType.AUDIO);
|
|
53
|
+
const isVideoMuted = !localParticipant?.publishedTracks.includes(video_client_1.SfuModels.TrackType.VIDEO);
|
|
51
54
|
const [isCameraOnFrontFacingMode, setIsCameraOnFrontFacingMode] = (0, react_1.useState)(true);
|
|
52
55
|
const [initAudioEnabled, setInitialAudioEnabled] = (0, react_1.useState)(() => {
|
|
53
56
|
const hasNativePermission = permissions_1.isMicPermissionGranted$.getValue();
|
|
@@ -94,6 +97,22 @@ const MediaStreamManagement = ({ children }) => {
|
|
|
94
97
|
call?.stopPublish(video_client_1.SfuModels.TrackType.VIDEO);
|
|
95
98
|
}
|
|
96
99
|
}, [call, callingState]);
|
|
100
|
+
const toggleVideoMuted = (0, react_1.useCallback)(async () => {
|
|
101
|
+
if (isVideoMuted) {
|
|
102
|
+
publishVideoStream();
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
stopPublishingVideo();
|
|
106
|
+
}
|
|
107
|
+
}, [isVideoMuted, publishVideoStream, stopPublishingVideo]);
|
|
108
|
+
const toggleAudioMuted = (0, react_1.useCallback)(async () => {
|
|
109
|
+
if (isAudioMuted) {
|
|
110
|
+
publishAudioStream();
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
stopPublishingAudio();
|
|
114
|
+
}
|
|
115
|
+
}, [isAudioMuted, publishAudioStream, stopPublishingAudio]);
|
|
97
116
|
const toggleInitialAudioMuteState = (0, react_1.useCallback)(() => setInitialAudioEnabled((prev) => {
|
|
98
117
|
if (!permissions_1.isMicPermissionGranted$.getValue() && !prev) {
|
|
99
118
|
react_native_1.Alert.alert('Microphone permission not granted, can not enable audio');
|
|
@@ -121,9 +140,13 @@ const MediaStreamManagement = ({ children }) => {
|
|
|
121
140
|
}, [localVideoStream, videoDevices.length]);
|
|
122
141
|
const contextValue = (0, react_1.useMemo)(() => {
|
|
123
142
|
return {
|
|
143
|
+
isAudioMuted,
|
|
144
|
+
isVideoMuted,
|
|
124
145
|
initialAudioEnabled: initAudioEnabled,
|
|
125
146
|
initialVideoEnabled: initVideoEnabled,
|
|
126
147
|
isCameraOnFrontFacingMode,
|
|
148
|
+
toggleAudioMuted,
|
|
149
|
+
toggleVideoMuted,
|
|
127
150
|
toggleInitialAudioMuteState,
|
|
128
151
|
toggleInitialVideoMuteState,
|
|
129
152
|
toggleCameraFacingMode,
|
|
@@ -133,9 +156,13 @@ const MediaStreamManagement = ({ children }) => {
|
|
|
133
156
|
stopPublishingVideo,
|
|
134
157
|
};
|
|
135
158
|
}, [
|
|
159
|
+
isAudioMuted,
|
|
160
|
+
isVideoMuted,
|
|
136
161
|
initAudioEnabled,
|
|
137
162
|
initVideoEnabled,
|
|
138
163
|
isCameraOnFrontFacingMode,
|
|
164
|
+
toggleAudioMuted,
|
|
165
|
+
toggleVideoMuted,
|
|
139
166
|
toggleInitialAudioMuteState,
|
|
140
167
|
toggleInitialVideoMuteState,
|
|
141
168
|
toggleCameraFacingMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/MediaStreamManagement/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AACf,0DAIiC;AACjC,0EAIyC;AACzC,uEAG+C;AAC/C,2DAAwD;AACxD,2DAAwD;AACxD,+CAAqC;AACrC,6CAA0D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/MediaStreamManagement/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AACf,0DAIiC;AACjC,0EAIyC;AACzC,uEAG+C;AAC/C,2DAAwD;AACxD,2DAAwD;AACxD,+CAAqC;AACrC,6CAA0D;AAmE1D,MAAM,kBAAkB,GACtB,IAAA,qBAAa,EAAyC,IAAI,CAAC,CAAC;AAE9D;;;;;;;;;GASG;AACI,MAAM,qBAAqB,GAAG,CAAC,EAAE,QAAQ,EAAyB,EAAE,EAAE;IAC3E,MAAM,IAAI,GAAG,IAAA,8BAAO,GAAE,CAAC;IACvB,MAAM,gBAAgB,GAAG,IAAA,0CAAmB,G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AAE;IAC3C,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,kBAAkB,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;KAC1C;IACD,OAAO,KAAwC,CAAC;AAClD,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.1-alpha.
|
|
1
|
+
export declare const version = "0.0.1-alpha.353";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -7,22 +7,21 @@ import {
|
|
|
7
7
|
useI18n,
|
|
8
8
|
} from '@stream-io/video-react-bindings';
|
|
9
9
|
import { CallControlsButton } from './CallControlsButton';
|
|
10
|
-
import {
|
|
10
|
+
import { usePermissionNotification } from '../../../hooks';
|
|
11
11
|
import { theme } from '../../../theme';
|
|
12
12
|
import { Mic, MicOff } from '../../../icons';
|
|
13
13
|
import { Alert, StyleSheet } from 'react-native';
|
|
14
14
|
import { muteStatusColor } from '../../../utils';
|
|
15
|
+
import { useMediaStreamManagement } from '../../../providers';
|
|
15
16
|
|
|
16
17
|
export const ToggleAudioButton = () => {
|
|
17
18
|
const [isAwaitingApproval, setIsAwaitingApproval] = useState(false);
|
|
18
|
-
const {
|
|
19
|
+
const { isAudioMuted, toggleAudioMuted } = useMediaStreamManagement();
|
|
19
20
|
const userHasSendAudioCapability = useHasPermissions(
|
|
20
21
|
OwnCapability.SEND_AUDIO,
|
|
21
22
|
);
|
|
22
23
|
const { t } = useI18n();
|
|
23
24
|
|
|
24
|
-
const isAudioMuted = !isAudioPublished;
|
|
25
|
-
|
|
26
25
|
usePermissionNotification({
|
|
27
26
|
permission: OwnCapability.SEND_AUDIO,
|
|
28
27
|
messageApproved: t('You can now speak.'),
|
|
@@ -11,15 +11,14 @@ import { muteStatusColor } from '../../../utils';
|
|
|
11
11
|
import { Alert, StyleSheet } from 'react-native';
|
|
12
12
|
import { theme } from '../../../theme';
|
|
13
13
|
import { Video, VideoSlash } from '../../../icons';
|
|
14
|
-
import {
|
|
14
|
+
import { usePermissionNotification } from '../../../hooks';
|
|
15
|
+
import { useMediaStreamManagement } from '../../../providers';
|
|
15
16
|
|
|
16
17
|
export const ToggleVideoButton = () => {
|
|
17
18
|
const [isAwaitingApproval, setIsAwaitingApproval] = useState(false);
|
|
18
|
-
const {
|
|
19
|
+
const { isVideoMuted, toggleVideoMuted } = useMediaStreamManagement();
|
|
19
20
|
const { t } = useI18n();
|
|
20
21
|
|
|
21
|
-
const isVideoMuted = !isVideoPublished;
|
|
22
|
-
|
|
23
22
|
const userHasSendVideoCapability = useHasPermissions(
|
|
24
23
|
OwnCapability.SEND_VIDEO,
|
|
25
24
|
);
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from './useCallControls';
|
|
2
1
|
export * from './useLocalVideoStream';
|
|
3
2
|
export * from './useIncallManager';
|
|
4
3
|
export * from './usePermissionRequest';
|
|
5
4
|
export * from './usePermissionNotification';
|
|
6
5
|
export * from './push';
|
|
7
6
|
export * from './useAndroidKeepCallAliveEffect';
|
|
8
|
-
export * from './useCallControls';
|
|
@@ -38,6 +38,14 @@ export type MediaStreamManagementContextAPI = {
|
|
|
38
38
|
* Publishes video stream for currently selected video input (camera) device to other call participants.
|
|
39
39
|
*/
|
|
40
40
|
publishVideoStream: () => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Signals whether local audio stream is muted/unmuted when in the call.
|
|
43
|
+
*/
|
|
44
|
+
isAudioMuted: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Signals whether local video stream is muted/unmuted when in the call.
|
|
47
|
+
*/
|
|
48
|
+
isVideoMuted: boolean;
|
|
41
49
|
/**
|
|
42
50
|
* Signals whether audio stream will be published when the call is joined.
|
|
43
51
|
*/
|
|
@@ -60,6 +68,14 @@ export type MediaStreamManagementContextAPI = {
|
|
|
60
68
|
* The latest value set will be used to decide, whether audio stream will be published when joining a call.
|
|
61
69
|
*/
|
|
62
70
|
toggleInitialVideoMuteState: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Toggles the video mute status, when in the call.
|
|
73
|
+
*/
|
|
74
|
+
toggleVideoMuted: () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Toggles the audio mute status, when in the call.
|
|
77
|
+
*/
|
|
78
|
+
toggleAudioMuted: () => void;
|
|
63
79
|
/**
|
|
64
80
|
* Toggles the camera facing mode between front and back camera.
|
|
65
81
|
*/
|
|
@@ -89,9 +105,16 @@ const MediaStreamContext =
|
|
|
89
105
|
*/
|
|
90
106
|
export const MediaStreamManagement = ({ children }: PropsWithChildren<{}>) => {
|
|
91
107
|
const call = useCall();
|
|
108
|
+
const localParticipant = useLocalParticipant();
|
|
92
109
|
const callingState = useCallCallingState();
|
|
93
110
|
const videoDevices = useStreamVideoStoreValue((store) => store.videoDevices);
|
|
94
111
|
const localVideoStream = useLocalParticipant()?.videoStream;
|
|
112
|
+
const isAudioMuted = !localParticipant?.publishedTracks.includes(
|
|
113
|
+
SfuModels.TrackType.AUDIO,
|
|
114
|
+
);
|
|
115
|
+
const isVideoMuted = !localParticipant?.publishedTracks.includes(
|
|
116
|
+
SfuModels.TrackType.VIDEO,
|
|
117
|
+
);
|
|
95
118
|
|
|
96
119
|
const [isCameraOnFrontFacingMode, setIsCameraOnFrontFacingMode] =
|
|
97
120
|
useState(true);
|
|
@@ -152,6 +175,22 @@ export const MediaStreamManagement = ({ children }: PropsWithChildren<{}>) => {
|
|
|
152
175
|
}
|
|
153
176
|
}, [call, callingState]);
|
|
154
177
|
|
|
178
|
+
const toggleVideoMuted = useCallback(async () => {
|
|
179
|
+
if (isVideoMuted) {
|
|
180
|
+
publishVideoStream();
|
|
181
|
+
} else {
|
|
182
|
+
stopPublishingVideo();
|
|
183
|
+
}
|
|
184
|
+
}, [isVideoMuted, publishVideoStream, stopPublishingVideo]);
|
|
185
|
+
|
|
186
|
+
const toggleAudioMuted = useCallback(async () => {
|
|
187
|
+
if (isAudioMuted) {
|
|
188
|
+
publishAudioStream();
|
|
189
|
+
} else {
|
|
190
|
+
stopPublishingAudio();
|
|
191
|
+
}
|
|
192
|
+
}, [isAudioMuted, publishAudioStream, stopPublishingAudio]);
|
|
193
|
+
|
|
155
194
|
const toggleInitialAudioMuteState = useCallback(
|
|
156
195
|
() =>
|
|
157
196
|
setInitialAudioEnabled((prev) => {
|
|
@@ -191,9 +230,13 @@ export const MediaStreamManagement = ({ children }: PropsWithChildren<{}>) => {
|
|
|
191
230
|
|
|
192
231
|
const contextValue = useMemo(() => {
|
|
193
232
|
return {
|
|
233
|
+
isAudioMuted,
|
|
234
|
+
isVideoMuted,
|
|
194
235
|
initialAudioEnabled: initAudioEnabled,
|
|
195
236
|
initialVideoEnabled: initVideoEnabled,
|
|
196
237
|
isCameraOnFrontFacingMode,
|
|
238
|
+
toggleAudioMuted,
|
|
239
|
+
toggleVideoMuted,
|
|
197
240
|
toggleInitialAudioMuteState,
|
|
198
241
|
toggleInitialVideoMuteState,
|
|
199
242
|
toggleCameraFacingMode,
|
|
@@ -203,9 +246,13 @@ export const MediaStreamManagement = ({ children }: PropsWithChildren<{}>) => {
|
|
|
203
246
|
stopPublishingVideo,
|
|
204
247
|
};
|
|
205
248
|
}, [
|
|
249
|
+
isAudioMuted,
|
|
250
|
+
isVideoMuted,
|
|
206
251
|
initAudioEnabled,
|
|
207
252
|
initVideoEnabled,
|
|
208
253
|
isCameraOnFrontFacingMode,
|
|
254
|
+
toggleAudioMuted,
|
|
255
|
+
toggleVideoMuted,
|
|
209
256
|
toggleInitialAudioMuteState,
|
|
210
257
|
toggleInitialVideoMuteState,
|
|
211
258
|
toggleCameraFacingMode,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A helper hook which exposes audio, video publishing state and
|
|
3
|
-
* their respective functions to toggle state
|
|
4
|
-
*
|
|
5
|
-
* @category Device Management
|
|
6
|
-
*/
|
|
7
|
-
export declare const useCallControls: () => {
|
|
8
|
-
isAudioPublished: boolean | undefined;
|
|
9
|
-
isVideoPublished: boolean | undefined;
|
|
10
|
-
toggleAudioMuted: () => Promise<void>;
|
|
11
|
-
toggleVideoMuted: () => Promise<void>;
|
|
12
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useCallControls = void 0;
|
|
4
|
-
const video_client_1 = require("@stream-io/video-client");
|
|
5
|
-
const video_react_bindings_1 = require("@stream-io/video-react-bindings");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const MediaStreamManagement_1 = require("../providers/MediaStreamManagement");
|
|
8
|
-
/**
|
|
9
|
-
* A helper hook which exposes audio, video publishing state and
|
|
10
|
-
* their respective functions to toggle state
|
|
11
|
-
*
|
|
12
|
-
* @category Device Management
|
|
13
|
-
*/
|
|
14
|
-
const useCallControls = () => {
|
|
15
|
-
const localParticipant = (0, video_react_bindings_1.useLocalParticipant)();
|
|
16
|
-
const { publishAudioStream, publishVideoStream, stopPublishingAudio, stopPublishingVideo, } = (0, MediaStreamManagement_1.useMediaStreamManagement)();
|
|
17
|
-
const isAudioPublished = localParticipant?.publishedTracks.includes(video_client_1.SfuModels.TrackType.AUDIO);
|
|
18
|
-
const isVideoPublished = localParticipant?.publishedTracks.includes(video_client_1.SfuModels.TrackType.VIDEO);
|
|
19
|
-
const toggleVideoMuted = (0, react_1.useCallback)(async () => {
|
|
20
|
-
if (isVideoPublished) {
|
|
21
|
-
stopPublishingVideo();
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
publishVideoStream();
|
|
25
|
-
}
|
|
26
|
-
}, [isVideoPublished, publishVideoStream, stopPublishingVideo]);
|
|
27
|
-
const toggleAudioMuted = (0, react_1.useCallback)(async () => {
|
|
28
|
-
if (isAudioPublished) {
|
|
29
|
-
stopPublishingAudio();
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
publishAudioStream();
|
|
33
|
-
}
|
|
34
|
-
}, [isAudioPublished, publishAudioStream, stopPublishingAudio]);
|
|
35
|
-
return {
|
|
36
|
-
isAudioPublished,
|
|
37
|
-
isVideoPublished,
|
|
38
|
-
toggleAudioMuted,
|
|
39
|
-
toggleVideoMuted,
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
exports.useCallControls = useCallControls;
|
|
43
|
-
//# sourceMappingURL=useCallControls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCallControls.js","sourceRoot":"","sources":["../../../src/hooks/useCallControls.tsx"],"names":[],"mappings":";;;AAAA,0DAAoD;AACpD,0EAAsE;AACtE,iCAAoC;AACpC,8EAA8E;AAE9E;;;;;GAKG;AACI,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,gBAAgB,GAAG,IAAA,0CAAmB,GAAE,CAAC;IAE/C,MAAM,EACJ,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GACpB,GAAG,IAAA,gDAAwB,GAAE,CAAC;IAE/B,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,eAAe,CAAC,QAAQ,CACjE,wBAAS,CAAC,SAAS,CAAC,KAAK,CAC1B,CAAC;IACF,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,eAAe,CAAC,QAAQ,CACjE,wBAAS,CAAC,SAAS,CAAC,KAAK,CAC1B,CAAC;IAEF,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QAC9C,IAAI,gBAAgB,EAAE;YACpB,mBAAmB,EAAE,CAAC;SACvB;aAAM;YACL,kBAAkB,EAAE,CAAC;SACtB;IACH,CAAC,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEhE,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QAC9C,IAAI,gBAAgB,EAAE;YACpB,mBAAmB,EAAE,CAAC;SACvB;aAAM;YACL,kBAAkB,EAAE,CAAC;SACtB;IACH,CAAC,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEhE,OAAO;QACL,gBAAgB;QAChB,gBAAgB;QAChB,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;AACJ,CAAC,CAAC;AAvCW,QAAA,eAAe,mBAuC1B"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SfuModels } from '@stream-io/video-client';
|
|
2
|
-
import { useLocalParticipant } from '@stream-io/video-react-bindings';
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
import { useMediaStreamManagement } from '../providers/MediaStreamManagement';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A helper hook which exposes audio, video publishing state and
|
|
8
|
-
* their respective functions to toggle state
|
|
9
|
-
*
|
|
10
|
-
* @category Device Management
|
|
11
|
-
*/
|
|
12
|
-
export const useCallControls = () => {
|
|
13
|
-
const localParticipant = useLocalParticipant();
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
publishAudioStream,
|
|
17
|
-
publishVideoStream,
|
|
18
|
-
stopPublishingAudio,
|
|
19
|
-
stopPublishingVideo,
|
|
20
|
-
} = useMediaStreamManagement();
|
|
21
|
-
|
|
22
|
-
const isAudioPublished = localParticipant?.publishedTracks.includes(
|
|
23
|
-
SfuModels.TrackType.AUDIO,
|
|
24
|
-
);
|
|
25
|
-
const isVideoPublished = localParticipant?.publishedTracks.includes(
|
|
26
|
-
SfuModels.TrackType.VIDEO,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const toggleVideoMuted = useCallback(async () => {
|
|
30
|
-
if (isVideoPublished) {
|
|
31
|
-
stopPublishingVideo();
|
|
32
|
-
} else {
|
|
33
|
-
publishVideoStream();
|
|
34
|
-
}
|
|
35
|
-
}, [isVideoPublished, publishVideoStream, stopPublishingVideo]);
|
|
36
|
-
|
|
37
|
-
const toggleAudioMuted = useCallback(async () => {
|
|
38
|
-
if (isAudioPublished) {
|
|
39
|
-
stopPublishingAudio();
|
|
40
|
-
} else {
|
|
41
|
-
publishAudioStream();
|
|
42
|
-
}
|
|
43
|
-
}, [isAudioPublished, publishAudioStream, stopPublishingAudio]);
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
isAudioPublished,
|
|
47
|
-
isVideoPublished,
|
|
48
|
-
toggleAudioMuted,
|
|
49
|
-
toggleVideoMuted,
|
|
50
|
-
};
|
|
51
|
-
};
|