@100mslive/react-native-room-kit 1.0.3 → 1.0.4-beta.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.
- package/lib/commonjs/Icons/CrossCircle/assets/cross-circle.png +0 -0
- package/lib/commonjs/Icons/CrossCircle/assets/cross-circle@2x.png +0 -0
- package/lib/commonjs/Icons/CrossCircle/assets/cross-circle@3x.png +0 -0
- package/lib/commonjs/Icons/CrossCircle/index.js +33 -0
- package/lib/commonjs/Icons/CrossCircle/index.js.map +1 -0
- package/lib/commonjs/Icons/Hand/assets/hand-off.png +0 -0
- package/lib/commonjs/Icons/Hand/assets/hand-off@2x.png +0 -0
- package/lib/commonjs/Icons/Hand/assets/hand-off@3x.png +0 -0
- package/lib/commonjs/Icons/Radio/assets/radio-xlarge.png +0 -0
- package/lib/commonjs/Icons/Radio/assets/radio-xlarge@2x.png +0 -0
- package/lib/commonjs/Icons/Radio/assets/radio-xlarge@3x.png +0 -0
- package/lib/commonjs/Icons/Recording/assets/recording-off.png +0 -0
- package/lib/commonjs/Icons/Recording/assets/recording-off@2x.png +0 -0
- package/lib/commonjs/Icons/Recording/assets/recording-off@3x.png +0 -0
- package/lib/commonjs/Icons/WelcomeHand/assets/welcome-hand.png +0 -0
- package/lib/commonjs/Icons/WelcomeHand/assets/welcome-hand@2x.png +0 -0
- package/lib/commonjs/Icons/WelcomeHand/assets/welcome-hand@3x.png +0 -0
- package/lib/commonjs/Icons/index.js +11 -0
- package/lib/commonjs/Icons/index.js.map +1 -1
- package/lib/commonjs/components/HLSFooter.js +2 -1
- package/lib/commonjs/components/HLSFooter.js.map +1 -1
- package/lib/commonjs/components/HLSView.js +54 -4
- package/lib/commonjs/components/HLSView.js.map +1 -1
- package/lib/commonjs/components/HMSManageAudioOutput.js +116 -34
- package/lib/commonjs/components/HMSManageAudioOutput.js.map +1 -1
- package/lib/commonjs/components/RoomSettingsModalDebugModeContent.js +2 -3
- package/lib/commonjs/components/RoomSettingsModalDebugModeContent.js.map +1 -1
- package/lib/commonjs/hooks-sdk.js +17 -1
- package/lib/commonjs/hooks-sdk.js.map +1 -1
- package/lib/commonjs/hooks-util.js +7 -2
- package/lib/commonjs/hooks-util.js.map +1 -1
- package/lib/commonjs/utils/constants.js +4 -1
- package/lib/commonjs/utils/constants.js.map +1 -1
- package/lib/commonjs/utils/functions.js +2 -71
- package/lib/commonjs/utils/functions.js.map +1 -1
- package/lib/module/Icons/CrossCircle/assets/cross-circle.png +0 -0
- package/lib/module/Icons/CrossCircle/assets/cross-circle@2x.png +0 -0
- package/lib/module/Icons/CrossCircle/assets/cross-circle@3x.png +0 -0
- package/lib/module/Icons/CrossCircle/index.js +25 -0
- package/lib/module/Icons/CrossCircle/index.js.map +1 -0
- package/lib/module/Icons/Hand/assets/hand-off.png +0 -0
- package/lib/module/Icons/Hand/assets/hand-off@2x.png +0 -0
- package/lib/module/Icons/Hand/assets/hand-off@3x.png +0 -0
- package/lib/module/Icons/Radio/assets/radio-xlarge.png +0 -0
- package/lib/module/Icons/Radio/assets/radio-xlarge@2x.png +0 -0
- package/lib/module/Icons/Radio/assets/radio-xlarge@3x.png +0 -0
- package/lib/module/Icons/Recording/assets/recording-off.png +0 -0
- package/lib/module/Icons/Recording/assets/recording-off@2x.png +0 -0
- package/lib/module/Icons/Recording/assets/recording-off@3x.png +0 -0
- package/lib/module/Icons/WelcomeHand/assets/welcome-hand.png +0 -0
- package/lib/module/Icons/WelcomeHand/assets/welcome-hand@2x.png +0 -0
- package/lib/module/Icons/WelcomeHand/assets/welcome-hand@3x.png +0 -0
- package/lib/module/Icons/index.js +1 -0
- package/lib/module/Icons/index.js.map +1 -1
- package/lib/module/components/HLSFooter.js +2 -1
- package/lib/module/components/HLSFooter.js.map +1 -1
- package/lib/module/components/HLSView.js +55 -5
- package/lib/module/components/HLSView.js.map +1 -1
- package/lib/module/components/HMSManageAudioOutput.js +116 -34
- package/lib/module/components/HMSManageAudioOutput.js.map +1 -1
- package/lib/module/components/RoomSettingsModalDebugModeContent.js +4 -5
- package/lib/module/components/RoomSettingsModalDebugModeContent.js.map +1 -1
- package/lib/module/hooks-sdk.js +18 -2
- package/lib/module/hooks-sdk.js.map +1 -1
- package/lib/module/hooks-util.js +7 -2
- package/lib/module/hooks-util.js.map +1 -1
- package/lib/module/utils/constants.js +4 -1
- package/lib/module/utils/constants.js.map +1 -1
- package/lib/module/utils/functions.js +0 -67
- package/lib/module/utils/functions.js.map +1 -1
- package/lib/typescript/Icons/CrossCircle/index.d.ts +7 -0
- package/lib/typescript/Icons/CrossCircle/index.d.ts.map +1 -0
- package/lib/typescript/Icons/index.d.ts +1 -0
- package/lib/typescript/Icons/index.d.ts.map +1 -1
- package/lib/typescript/components/HLSFooter.d.ts.map +1 -1
- package/lib/typescript/components/HLSView.d.ts +2 -1
- package/lib/typescript/components/HLSView.d.ts.map +1 -1
- package/lib/typescript/components/HMSManageAudioOutput.d.ts.map +1 -1
- package/lib/typescript/components/RoomSettingsModalDebugModeContent.d.ts.map +1 -1
- package/lib/typescript/hooks-sdk.d.ts +1 -0
- package/lib/typescript/hooks-sdk.d.ts.map +1 -1
- package/lib/typescript/hooks-util.d.ts.map +1 -1
- package/lib/typescript/utils/constants.d.ts +3 -0
- package/lib/typescript/utils/constants.d.ts.map +1 -1
- package/lib/typescript/utils/functions.d.ts +0 -3
- package/lib/typescript/utils/functions.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/Icons/CrossCircle/assets/cross-circle.png +0 -0
- package/src/Icons/CrossCircle/assets/cross-circle@2x.png +0 -0
- package/src/Icons/CrossCircle/assets/cross-circle@3x.png +0 -0
- package/src/Icons/CrossCircle/index.tsx +33 -0
- package/src/Icons/Hand/assets/hand-off.png +0 -0
- package/src/Icons/Hand/assets/hand-off@2x.png +0 -0
- package/src/Icons/Hand/assets/hand-off@3x.png +0 -0
- package/src/Icons/Radio/assets/radio-xlarge.png +0 -0
- package/src/Icons/Radio/assets/radio-xlarge@2x.png +0 -0
- package/src/Icons/Radio/assets/radio-xlarge@3x.png +0 -0
- package/src/Icons/Recording/assets/recording-off.png +0 -0
- package/src/Icons/Recording/assets/recording-off@2x.png +0 -0
- package/src/Icons/Recording/assets/recording-off@3x.png +0 -0
- package/src/Icons/WelcomeHand/assets/welcome-hand.png +0 -0
- package/src/Icons/WelcomeHand/assets/welcome-hand@2x.png +0 -0
- package/src/Icons/WelcomeHand/assets/welcome-hand@3x.png +0 -0
- package/src/Icons/index.ts +1 -0
- package/src/components/HLSFooter.tsx +3 -0
- package/src/components/HLSView.tsx +85 -4
- package/src/components/HMSManageAudioOutput.tsx +164 -48
- package/src/components/RoomSettingsModalDebugModeContent.tsx +4 -3
- package/src/hooks-sdk.ts +24 -0
- package/src/hooks-util.ts +95 -71
- package/src/utils/constants.ts +4 -0
- package/src/utils/functions.ts +8 -113
- package/lib/commonjs/utils/getRoomLinkDetails.js +0 -23
- package/lib/commonjs/utils/getRoomLinkDetails.js.map +0 -1
- package/lib/module/utils/getRoomLinkDetails.js +0 -16
- package/lib/module/utils/getRoomLinkDetails.js.map +0 -1
- package/lib/typescript/utils/getRoomLinkDetails.d.ts +0 -5
- package/lib/typescript/utils/getRoomLinkDetails.d.ts.map +0 -1
- package/src/utils/getRoomLinkDetails.ts +0 -23
|
@@ -31,11 +31,13 @@ import {
|
|
|
31
31
|
import type { RootState } from '../redux';
|
|
32
32
|
import { BottomSheet } from './BottomSheet';
|
|
33
33
|
import { TestIds } from '../utils/constants';
|
|
34
|
+
import { useHMSActions } from '../hooks-sdk';
|
|
34
35
|
|
|
35
36
|
export const HMSManageAudioOutput: React.FC = () => {
|
|
36
37
|
const hmsInstance = useHMSInstance();
|
|
37
38
|
const isHLSViewer = useIsHLSViewer();
|
|
38
39
|
const [settingsModalVisible, setSettingsModalVisible] = React.useState(false);
|
|
40
|
+
const { setRoomMuteLocally } = useHMSActions();
|
|
39
41
|
|
|
40
42
|
const [currentAudioOutputDevice, setCurrentAudioOutputDevice] =
|
|
41
43
|
React.useState<HMSAudioDevice | null>(null);
|
|
@@ -43,6 +45,9 @@ export const HMSManageAudioOutput: React.FC = () => {
|
|
|
43
45
|
React.useState<HMSAudioDevice[]>([]);
|
|
44
46
|
|
|
45
47
|
const debugMode = useSelector((state: RootState) => state.user.debugMode);
|
|
48
|
+
const roomLocallyMuted = useSelector(
|
|
49
|
+
(state: RootState) => state.hmsStates.roomLocallyMuted
|
|
50
|
+
);
|
|
46
51
|
|
|
47
52
|
// Fetch current selected audio device and audio devices list on Android
|
|
48
53
|
React.useEffect(() => {
|
|
@@ -79,16 +84,12 @@ export const HMSManageAudioOutput: React.FC = () => {
|
|
|
79
84
|
|
|
80
85
|
// Handles showing Modal for changing Audio device
|
|
81
86
|
const handleSpeakerChange = () => {
|
|
82
|
-
if (Platform.OS === '
|
|
83
|
-
hmsInstance
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
hmsInstance
|
|
87
|
-
.getAudioDevicesList()
|
|
88
|
-
.then((devices) => setAvailableAudioOutputDevices(devices)); // TODO(set-state-after-unmount): setting state irrespective of component unmount check
|
|
89
|
-
}
|
|
90
|
-
setSettingsModalVisible(true);
|
|
87
|
+
if (Platform.OS === 'android' && availableAudioOutputDevices.length === 0) {
|
|
88
|
+
hmsInstance
|
|
89
|
+
.getAudioDevicesList()
|
|
90
|
+
.then((devices) => setAvailableAudioOutputDevices(devices)); // TODO(set-state-after-unmount): setting state irrespective of component unmount check
|
|
91
91
|
}
|
|
92
|
+
setSettingsModalVisible(true);
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
// Add audio device change listeners
|
|
@@ -120,23 +121,29 @@ export const HMSManageAudioOutput: React.FC = () => {
|
|
|
120
121
|
}, [hmsInstance, debugMode]);
|
|
121
122
|
|
|
122
123
|
// Handle changing selected audio device
|
|
123
|
-
const handleSelectAudioDevice = (
|
|
124
|
-
|
|
124
|
+
const handleSelectAudioDevice = (
|
|
125
|
+
device: HMSAudioDevice | 'mute-audio' | 'ios-audio-device'
|
|
126
|
+
) => {
|
|
127
|
+
if (device === 'mute-audio') {
|
|
128
|
+
setRoomMuteLocally(true);
|
|
129
|
+
} else {
|
|
130
|
+
if (roomLocallyMuted) {
|
|
131
|
+
setRoomMuteLocally(false);
|
|
132
|
+
}
|
|
133
|
+
if (device === 'ios-audio-device') {
|
|
134
|
+
hmsInstance.switchAudioOutputUsingIOSUI();
|
|
135
|
+
} else {
|
|
136
|
+
hmsInstance.switchAudioOutput(device);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
125
139
|
setSettingsModalVisible(false);
|
|
126
140
|
};
|
|
127
141
|
|
|
128
142
|
const hmsRoomStyles = useHMSRoomStyleSheet((theme, typography) => ({
|
|
129
|
-
headerText: {
|
|
130
|
-
color: theme.palette.on_surface_high,
|
|
131
|
-
fontFamily: `${typography.font_family}-Medium`,
|
|
132
|
-
},
|
|
133
143
|
text: {
|
|
134
144
|
color: theme.palette.on_surface_high,
|
|
135
145
|
fontFamily: `${typography.font_family}-SemiBold`,
|
|
136
146
|
},
|
|
137
|
-
divider: {
|
|
138
|
-
backgroundColor: theme.palette.border_default,
|
|
139
|
-
},
|
|
140
147
|
}));
|
|
141
148
|
|
|
142
149
|
return (
|
|
@@ -146,7 +153,9 @@ export const HMSManageAudioOutput: React.FC = () => {
|
|
|
146
153
|
onPress={handleSpeakerChange}
|
|
147
154
|
style={isHLSViewer ? styles.button : null}
|
|
148
155
|
>
|
|
149
|
-
{
|
|
156
|
+
{roomLocallyMuted ? (
|
|
157
|
+
<SpeakerIcon muted={true} />
|
|
158
|
+
) : Platform.OS === 'ios' ? (
|
|
150
159
|
<SpeakerIcon muted={false} />
|
|
151
160
|
) : (
|
|
152
161
|
getIcon(currentAudioOutputDevice || HMSAudioDevice.AUTOMATIC)
|
|
@@ -164,7 +173,33 @@ export const HMSManageAudioOutput: React.FC = () => {
|
|
|
164
173
|
<BottomSheet.Divider />
|
|
165
174
|
|
|
166
175
|
<View style={styles.contentContainer}>
|
|
167
|
-
{
|
|
176
|
+
{Platform.OS === 'ios' ? (
|
|
177
|
+
<>
|
|
178
|
+
<AudioOutputDevice
|
|
179
|
+
id={'ios-audio-device'}
|
|
180
|
+
hideDivider={true}
|
|
181
|
+
selected={!roomLocallyMuted}
|
|
182
|
+
text={'Auto'}
|
|
183
|
+
icon={<SpeakerIcon muted={false} />}
|
|
184
|
+
onPress={handleSelectAudioDevice}
|
|
185
|
+
checkTestID={TestIds.automatic_audio_device_active}
|
|
186
|
+
textTestID={TestIds.automatic_audio_device_text}
|
|
187
|
+
buttonTestID={TestIds.automatic_audio_device_btn}
|
|
188
|
+
/>
|
|
189
|
+
|
|
190
|
+
<AudioOutputDevice
|
|
191
|
+
id={'mute-audio'}
|
|
192
|
+
hideDivider={false}
|
|
193
|
+
selected={roomLocallyMuted}
|
|
194
|
+
text={'Mute Audio'}
|
|
195
|
+
icon={<SpeakerIcon muted={true} />}
|
|
196
|
+
onPress={handleSelectAudioDevice}
|
|
197
|
+
checkTestID={TestIds.mute_audio_active}
|
|
198
|
+
textTestID={TestIds.mute_audio_text}
|
|
199
|
+
buttonTestID={TestIds.mute_audio_btn}
|
|
200
|
+
/>
|
|
201
|
+
</>
|
|
202
|
+
) : availableAudioOutputDevices.length === 0 ? (
|
|
168
203
|
<View style={styles.emptyView}>
|
|
169
204
|
<Text
|
|
170
205
|
testID={TestIds.audio_modal_empty_text}
|
|
@@ -183,36 +218,39 @@ export const HMSManageAudioOutput: React.FC = () => {
|
|
|
183
218
|
const isFirst = index === 0;
|
|
184
219
|
|
|
185
220
|
return (
|
|
186
|
-
<
|
|
187
|
-
{
|
|
188
|
-
|
|
221
|
+
<AudioOutputDevice
|
|
222
|
+
key={device}
|
|
223
|
+
id={device}
|
|
224
|
+
hideDivider={isFirst}
|
|
225
|
+
selected={
|
|
226
|
+
device === currentAudioOutputDevice && !roomLocallyMuted
|
|
227
|
+
}
|
|
228
|
+
checkTestID={activeAudioDeviceTestIds[device]}
|
|
229
|
+
text={getDescription(device, currentAudioOutputDevice)}
|
|
230
|
+
textTestID={audioDeviceTextTestIds[device]}
|
|
231
|
+
icon={getIcon(
|
|
232
|
+
device === HMSAudioDevice.AUTOMATIC &&
|
|
233
|
+
currentAudioOutputDevice
|
|
234
|
+
? currentAudioOutputDevice
|
|
235
|
+
: device
|
|
189
236
|
)}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
style={styles.audioDeviceItem}
|
|
194
|
-
onPress={() => handleSelectAudioDevice(device)}
|
|
195
|
-
>
|
|
196
|
-
<View style={styles.itemTextWrapper}>
|
|
197
|
-
{getIcon(
|
|
198
|
-
device === HMSAudioDevice.AUTOMATIC &&
|
|
199
|
-
currentAudioOutputDevice
|
|
200
|
-
? currentAudioOutputDevice
|
|
201
|
-
: device
|
|
202
|
-
)}
|
|
203
|
-
|
|
204
|
-
<Text testID={audioDeviceTextTestIds[device]} style={[styles.itemText, hmsRoomStyles.text]}>
|
|
205
|
-
{getDescription(device, currentAudioOutputDevice)}
|
|
206
|
-
</Text>
|
|
207
|
-
</View>
|
|
208
|
-
|
|
209
|
-
{device === currentAudioOutputDevice ? (
|
|
210
|
-
<CheckIcon testID={activeAudioDeviceTestIds[device]} />
|
|
211
|
-
) : null}
|
|
212
|
-
</TouchableOpacity>
|
|
213
|
-
</React.Fragment>
|
|
237
|
+
buttonTestID={audioDeviceTestIds[device]}
|
|
238
|
+
onPress={handleSelectAudioDevice}
|
|
239
|
+
/>
|
|
214
240
|
);
|
|
215
241
|
})}
|
|
242
|
+
|
|
243
|
+
<AudioOutputDevice
|
|
244
|
+
id={'mute-audio'}
|
|
245
|
+
hideDivider={false}
|
|
246
|
+
selected={roomLocallyMuted}
|
|
247
|
+
text={'Mute Audio'}
|
|
248
|
+
icon={<SpeakerIcon muted={true} />}
|
|
249
|
+
onPress={handleSelectAudioDevice}
|
|
250
|
+
checkTestID={TestIds.mute_audio_active}
|
|
251
|
+
textTestID={TestIds.mute_audio_text}
|
|
252
|
+
buttonTestID={TestIds.mute_audio_btn}
|
|
253
|
+
/>
|
|
216
254
|
</ScrollView>
|
|
217
255
|
)}
|
|
218
256
|
</View>
|
|
@@ -221,6 +259,84 @@ export const HMSManageAudioOutput: React.FC = () => {
|
|
|
221
259
|
);
|
|
222
260
|
};
|
|
223
261
|
|
|
262
|
+
interface AudioOutputDeviceProps {
|
|
263
|
+
id: HMSAudioDevice | 'mute-audio' | 'ios-audio-device';
|
|
264
|
+
hideDivider: boolean;
|
|
265
|
+
selected: boolean;
|
|
266
|
+
checkTestID: string;
|
|
267
|
+
text: string;
|
|
268
|
+
textTestID: string;
|
|
269
|
+
icon: React.ReactElement;
|
|
270
|
+
buttonTestID: string;
|
|
271
|
+
onPress(selected: HMSAudioDevice | 'mute-audio' | 'ios-audio-device'): void;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const AudioOutputDevice: React.FC<AudioOutputDeviceProps> = (props) => {
|
|
275
|
+
const {
|
|
276
|
+
id,
|
|
277
|
+
hideDivider,
|
|
278
|
+
selected,
|
|
279
|
+
checkTestID,
|
|
280
|
+
text,
|
|
281
|
+
textTestID,
|
|
282
|
+
icon,
|
|
283
|
+
buttonTestID,
|
|
284
|
+
onPress,
|
|
285
|
+
} = props;
|
|
286
|
+
|
|
287
|
+
const hmsRoomStyles = useHMSRoomStyleSheet(
|
|
288
|
+
(theme, typography) => ({
|
|
289
|
+
text: {
|
|
290
|
+
color: selected
|
|
291
|
+
? theme.palette.primary_bright
|
|
292
|
+
: theme.palette.on_surface_high,
|
|
293
|
+
fontFamily: `${typography.font_family}-SemiBold`,
|
|
294
|
+
},
|
|
295
|
+
divider: {
|
|
296
|
+
backgroundColor: theme.palette.border_default,
|
|
297
|
+
},
|
|
298
|
+
checkIcon: {
|
|
299
|
+
tintColor: theme.palette.primary_bright,
|
|
300
|
+
},
|
|
301
|
+
}),
|
|
302
|
+
[selected]
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<React.Fragment>
|
|
307
|
+
{hideDivider ? null : (
|
|
308
|
+
<View style={[styles.divider, hmsRoomStyles.divider]} />
|
|
309
|
+
)}
|
|
310
|
+
|
|
311
|
+
<TouchableOpacity
|
|
312
|
+
testID={buttonTestID}
|
|
313
|
+
disabled={selected}
|
|
314
|
+
style={styles.audioDeviceItem}
|
|
315
|
+
onPress={() => onPress(id)}
|
|
316
|
+
>
|
|
317
|
+
<View style={styles.itemTextWrapper}>
|
|
318
|
+
{icon
|
|
319
|
+
? React.cloneElement(icon, {
|
|
320
|
+
style: selected ? hmsRoomStyles.checkIcon : null,
|
|
321
|
+
})
|
|
322
|
+
: null}
|
|
323
|
+
|
|
324
|
+
<Text
|
|
325
|
+
testID={textTestID}
|
|
326
|
+
style={[styles.itemText, hmsRoomStyles.text]}
|
|
327
|
+
>
|
|
328
|
+
{text}
|
|
329
|
+
</Text>
|
|
330
|
+
</View>
|
|
331
|
+
|
|
332
|
+
{selected ? (
|
|
333
|
+
<CheckIcon testID={checkTestID} style={hmsRoomStyles.checkIcon} />
|
|
334
|
+
) : null}
|
|
335
|
+
</TouchableOpacity>
|
|
336
|
+
</React.Fragment>
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
224
340
|
const styles = StyleSheet.create({
|
|
225
341
|
button: {
|
|
226
342
|
backgroundColor: 'transparent',
|
|
@@ -321,4 +437,4 @@ const activeAudioDeviceTestIds = {
|
|
|
321
437
|
[HMSAudioDevice.WIRED_HEADSET]: TestIds.wired_headset_audio_device_active,
|
|
322
438
|
[HMSAudioDevice.EARPIECE]: TestIds.earpiece_audio_device_active,
|
|
323
439
|
[HMSAudioDevice.BLUETOOTH]: TestIds.bluetooth_audio_device_active,
|
|
324
|
-
} as const;
|
|
440
|
+
} as const;
|
|
@@ -6,14 +6,15 @@ import {
|
|
|
6
6
|
ScrollView,
|
|
7
7
|
TouchableOpacity,
|
|
8
8
|
Alert,
|
|
9
|
+
Linking,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import {
|
|
11
12
|
HMSAudioMixingMode,
|
|
12
13
|
HMSUpdateListenerActions,
|
|
14
|
+
checkNotifications,
|
|
13
15
|
} from '@100mslive/react-native-hms';
|
|
14
16
|
import { useDispatch, useSelector } from 'react-redux';
|
|
15
17
|
import Toast from 'react-native-simple-toast';
|
|
16
|
-
import { openSettings, requestNotifications } from 'react-native-permissions';
|
|
17
18
|
|
|
18
19
|
import { COLORS } from '../utils/theme';
|
|
19
20
|
import type { RootState } from '../redux';
|
|
@@ -210,7 +211,7 @@ export const RoomSettingsModalDebugModeContent: React.FC<
|
|
|
210
211
|
// check notification permission on android platform
|
|
211
212
|
// Audio share feature needs foreground service running. for Foreground service to keep running, we need active notification.
|
|
212
213
|
if (Platform.OS === 'android') {
|
|
213
|
-
const result = await
|
|
214
|
+
const result = await checkNotifications();
|
|
214
215
|
|
|
215
216
|
console.log('Notification Permission Result: ', result);
|
|
216
217
|
|
|
@@ -220,7 +221,7 @@ export const RoomSettingsModalDebugModeContent: React.FC<
|
|
|
220
221
|
'100ms SDK needs notification permission to start audio share. Please allow notification from settings and try again!',
|
|
221
222
|
[
|
|
222
223
|
{ text: 'cancel' },
|
|
223
|
-
{ text: 'Go to Settings', onPress: () => openSettings() },
|
|
224
|
+
{ text: 'Go to Settings', onPress: () => Linking.openSettings() },
|
|
224
225
|
],
|
|
225
226
|
{ cancelable: true }
|
|
226
227
|
);
|
package/src/hooks-sdk.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
setIsLocalAudioMutedState,
|
|
6
6
|
setIsLocalScreenSharedState,
|
|
7
7
|
setIsLocalVideoMutedState,
|
|
8
|
+
setRoomLocallyMuted,
|
|
8
9
|
} from './redux/actions';
|
|
9
10
|
import {
|
|
10
11
|
selectAllowedTracksToPublish,
|
|
@@ -218,6 +219,28 @@ export const useHMSActions = () => {
|
|
|
218
219
|
[]
|
|
219
220
|
);
|
|
220
221
|
|
|
222
|
+
const setRoomMuteLocally = useCallback(
|
|
223
|
+
async (mute: boolean): Promise<void> => {
|
|
224
|
+
const state: RootState = store.getState();
|
|
225
|
+
const hmsInstance = state.user.hmsInstance;
|
|
226
|
+
|
|
227
|
+
if (!hmsInstance) {
|
|
228
|
+
return Promise.reject('HMSSDK Instance is not available!');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
const result = await hmsInstance.setPlaybackForAllAudio(mute);
|
|
233
|
+
console.log('Set Room Mute Locally Success: ', result);
|
|
234
|
+
|
|
235
|
+
dispatch(setRoomLocallyMuted(mute));
|
|
236
|
+
} catch (error) {
|
|
237
|
+
console.log('Set Room Mute Locally Error: ', error);
|
|
238
|
+
return Promise.reject(error);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
[]
|
|
242
|
+
);
|
|
243
|
+
|
|
221
244
|
return {
|
|
222
245
|
setLocalAudioEnabled,
|
|
223
246
|
setLocalVideoEnabled,
|
|
@@ -228,5 +251,6 @@ export const useHMSActions = () => {
|
|
|
228
251
|
raiseLocalPeerHand,
|
|
229
252
|
lowerLocalPeerHand,
|
|
230
253
|
lowerRemotePeerHand,
|
|
254
|
+
setRoomMuteLocally,
|
|
231
255
|
};
|
|
232
256
|
};
|
package/src/hooks-util.ts
CHANGED
|
@@ -56,7 +56,11 @@ import {
|
|
|
56
56
|
PeerListRefreshInterval,
|
|
57
57
|
PipModes,
|
|
58
58
|
} from './utils/types';
|
|
59
|
-
import type {
|
|
59
|
+
import type {
|
|
60
|
+
ChatBroadcastFilter,
|
|
61
|
+
OnLeaveHandler,
|
|
62
|
+
PeerTrackNode,
|
|
63
|
+
} from './utils/types';
|
|
60
64
|
import { createPeerTrackNode } from './utils/functions';
|
|
61
65
|
import {
|
|
62
66
|
batch,
|
|
@@ -1256,10 +1260,12 @@ export const useHMSReconnection = () => {
|
|
|
1256
1260
|
if (mounted) {
|
|
1257
1261
|
batch(() => {
|
|
1258
1262
|
dispatch(setReconnecting(true));
|
|
1259
|
-
dispatch(
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
+
dispatch(
|
|
1264
|
+
addNotification({
|
|
1265
|
+
id: NotificationTypes.RECONNECTING,
|
|
1266
|
+
type: NotificationTypes.RECONNECTING,
|
|
1267
|
+
})
|
|
1268
|
+
);
|
|
1263
1269
|
});
|
|
1264
1270
|
}
|
|
1265
1271
|
});
|
|
@@ -1268,7 +1274,7 @@ export const useHMSReconnection = () => {
|
|
|
1268
1274
|
batch(() => {
|
|
1269
1275
|
dispatch(setReconnecting(false));
|
|
1270
1276
|
dispatch(removeNotification(NotificationTypes.RECONNECTING));
|
|
1271
|
-
})
|
|
1277
|
+
});
|
|
1272
1278
|
}
|
|
1273
1279
|
});
|
|
1274
1280
|
|
|
@@ -1426,13 +1432,19 @@ export const useAutoPip = (oneToOneCall: boolean) => {
|
|
|
1426
1432
|
);
|
|
1427
1433
|
const [numerator, denominator] = usePipAspectRatio(oneToOneCall);
|
|
1428
1434
|
|
|
1435
|
+
const remotePeersPresent = useSelector((state: RootState) => {
|
|
1436
|
+
const room = state.hmsStates.room;
|
|
1437
|
+
return room && room.peerCount !== null ? room.peerCount > 1 : false; // `peerCount` includes local peer
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1429
1440
|
useEffect(() => {
|
|
1430
|
-
if (autoEnterPipMode) {
|
|
1441
|
+
if (autoEnterPipMode && remotePeersPresent) {
|
|
1431
1442
|
enableAutoPip({ aspectRatio: [numerator, denominator] });
|
|
1432
1443
|
|
|
1433
1444
|
return disableAutoPip;
|
|
1434
1445
|
}
|
|
1435
1446
|
}, [
|
|
1447
|
+
remotePeersPresent,
|
|
1436
1448
|
numerator,
|
|
1437
1449
|
denominator,
|
|
1438
1450
|
autoEnterPipMode,
|
|
@@ -1471,10 +1483,16 @@ export const usePipAspectRatio = (oneToOneCall: boolean): [number, number] => {
|
|
|
1471
1483
|
}
|
|
1472
1484
|
// default aspect ratio
|
|
1473
1485
|
return [16, 9];
|
|
1474
|
-
}, [
|
|
1486
|
+
}, [
|
|
1487
|
+
isHLSViewer,
|
|
1488
|
+
firstSSNodeId,
|
|
1489
|
+
oneToOneCall,
|
|
1490
|
+
ssResolution,
|
|
1491
|
+
hlsPlayerResolution,
|
|
1492
|
+
]);
|
|
1475
1493
|
|
|
1476
1494
|
return aspectRatio;
|
|
1477
|
-
}
|
|
1495
|
+
};
|
|
1478
1496
|
|
|
1479
1497
|
export const useHMSActiveSpeakerUpdates = (
|
|
1480
1498
|
setPeerTrackNodes: React.Dispatch<React.SetStateAction<PeerTrackNode[]>>,
|
|
@@ -2008,57 +2026,60 @@ export const useLeaveMethods = () => {
|
|
|
2008
2026
|
const dispatch = useDispatch();
|
|
2009
2027
|
const reduxStore = useStore<RootState>();
|
|
2010
2028
|
|
|
2011
|
-
const destroy = useCallback(
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
onLeave
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2029
|
+
const destroy = useCallback(
|
|
2030
|
+
(reason: Parameters<OnLeaveHandler>[0]) => {
|
|
2031
|
+
try {
|
|
2032
|
+
const s = hmsInstance.destroy();
|
|
2033
|
+
console.log('Destroy Success: ', s);
|
|
2034
|
+
// TODOS:
|
|
2035
|
+
// - If show `Meeting_Ended` is true, show Meeting screen by setting state to MEETING_ENDED
|
|
2036
|
+
// - Reset Redux States
|
|
2037
|
+
// - HMSInstance will not be available now
|
|
2038
|
+
// - When your presses "Re Join" Action button, restart process from root component
|
|
2039
|
+
// - When your presses "Done" Action button
|
|
2040
|
+
// - If we have callback fn, call it
|
|
2041
|
+
// - Otherwise try our best to navigate away from current screen
|
|
2042
|
+
//
|
|
2043
|
+
// - No screen to show
|
|
2044
|
+
// - No need to reset redux state?
|
|
2045
|
+
// - HMSInstance will be available till this point
|
|
2046
|
+
// - If we have callback fn, call it
|
|
2047
|
+
// - Otherwise try our best to navigate away from current screen
|
|
2048
|
+
// - When we are navigated away from screen, HMSInstance will be not available
|
|
2049
|
+
|
|
2050
|
+
// dispatch(clearMessageData());
|
|
2051
|
+
// dispatch(clearPeerData());
|
|
2052
|
+
// dispatch(clearHmsReference());
|
|
2053
|
+
|
|
2054
|
+
const onLeave = reduxStore.getState().user.onLeave;
|
|
2055
|
+
|
|
2056
|
+
if (typeof onLeave === 'function') {
|
|
2057
|
+
onLeave(reason);
|
|
2058
|
+
dispatch(clearStore());
|
|
2059
|
+
} else if (
|
|
2060
|
+
navigation &&
|
|
2061
|
+
typeof navigation.canGoBack === 'function' &&
|
|
2062
|
+
navigation.canGoBack()
|
|
2063
|
+
) {
|
|
2064
|
+
navigation.goBack();
|
|
2065
|
+
dispatch(clearStore());
|
|
2066
|
+
} else {
|
|
2067
|
+
// Otherwise default action is to show "Meeting Ended" screen
|
|
2068
|
+
dispatch(clearStore()); // TODO: We need different clearStore for MeetingEnded
|
|
2069
|
+
dispatch(changeMeetingState(MeetingState.MEETING_ENDED));
|
|
2070
|
+
}
|
|
2071
|
+
} catch (e) {
|
|
2072
|
+
console.log(`Destroy HMS instance Error: ${e}`);
|
|
2073
|
+
Toast.showWithGravity(
|
|
2074
|
+
`Destroy HMS instance Error: ${e}`,
|
|
2075
|
+
Toast.LONG,
|
|
2076
|
+
Toast.TOP
|
|
2077
|
+
);
|
|
2078
|
+
return Promise.reject(e);
|
|
2051
2079
|
}
|
|
2052
|
-
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
`Destroy HMS instance Error: ${e}`,
|
|
2056
|
-
Toast.LONG,
|
|
2057
|
-
Toast.TOP
|
|
2058
|
-
);
|
|
2059
|
-
return Promise.reject(e);
|
|
2060
|
-
}
|
|
2061
|
-
}, [hmsInstance]);
|
|
2080
|
+
},
|
|
2081
|
+
[hmsInstance]
|
|
2082
|
+
);
|
|
2062
2083
|
|
|
2063
2084
|
const leave = useCallback(
|
|
2064
2085
|
async (reason: OnLeaveReason, shouldEndStream: boolean = false) => {
|
|
@@ -2093,15 +2114,18 @@ export const useLeaveMethods = () => {
|
|
|
2093
2114
|
}
|
|
2094
2115
|
}, [hmsInstance]);
|
|
2095
2116
|
|
|
2096
|
-
const endRoom = useCallback(
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2117
|
+
const endRoom = useCallback(
|
|
2118
|
+
async (reason: OnLeaveReason) => {
|
|
2119
|
+
try {
|
|
2120
|
+
const d = await hmsInstance.endRoom('Host ended the room');
|
|
2121
|
+
console.log('EndRoom Success: ', d);
|
|
2122
|
+
await destroy(reason);
|
|
2123
|
+
} catch (e) {
|
|
2124
|
+
console.log('EndRoom Error: ', e);
|
|
2125
|
+
}
|
|
2126
|
+
},
|
|
2127
|
+
[destroy, hmsInstance]
|
|
2128
|
+
);
|
|
2105
2129
|
|
|
2106
2130
|
return { destroy, leave, endRoom, prebuiltCleanUp };
|
|
2107
2131
|
};
|
|
@@ -2227,8 +2251,8 @@ export const useSendMessage = () => {
|
|
|
2227
2251
|
'publishSettings' in sendingTo
|
|
2228
2252
|
? HMSMessageRecipientType.ROLES
|
|
2229
2253
|
: 'peerID' in sendingTo
|
|
2230
|
-
|
|
2231
|
-
|
|
2254
|
+
? HMSMessageRecipientType.PEER
|
|
2255
|
+
: HMSMessageRecipientType.BROADCAST,
|
|
2232
2256
|
recipientPeer: 'peerID' in sendingTo ? sendingTo : undefined,
|
|
2233
2257
|
recipientRoles: 'publishSettings' in sendingTo ? [sendingTo] : undefined,
|
|
2234
2258
|
});
|
|
@@ -2396,7 +2420,7 @@ export const useStartRecording = () => {
|
|
|
2396
2420
|
addNotification({
|
|
2397
2421
|
id: Math.random().toString(16).slice(2),
|
|
2398
2422
|
type: NotificationTypes.ERROR,
|
|
2399
|
-
message: error.message
|
|
2423
|
+
message: error.message,
|
|
2400
2424
|
})
|
|
2401
2425
|
);
|
|
2402
2426
|
});
|
package/src/utils/constants.ts
CHANGED
|
@@ -143,4 +143,8 @@ export const TestIds = {
|
|
|
143
143
|
bluetooth_audio_device_btn: 'bluetooth-audio-device-button',
|
|
144
144
|
bluetooth_audio_device_text: 'bluetooth-audio-device-text',
|
|
145
145
|
bluetooth_audio_device_active: 'bluetooth-audio-device--active',
|
|
146
|
+
|
|
147
|
+
mute_audio_btn: 'mute-audio-button',
|
|
148
|
+
mute_audio_text: 'mute-audio-text',
|
|
149
|
+
mute_audio_active: 'mute-audio--active',
|
|
146
150
|
} as const;
|