@100mslive/react-native-room-kit
Version:
100ms Room Kit provides simple & easy to use UI components to build Live Streaming & Video Conferencing experiences in your apps.
38 lines • 1.38 kB
JavaScript
import * as React from 'react';
import { useSelector } from 'react-redux';
import { useCanPublishVideo, useHMSActions } from '../hooks-sdk';
import { PressableIcon } from './PressableIcon';
import { CameraIcon } from '../Icons';
import { TestIds } from '../utils/constants';
export const HMSManageLocalVideo = ({
style
}) => {
const canPublishVideo = useCanPublishVideo();
if (!canPublishVideo) {
return null;
}
return /*#__PURE__*/React.createElement(ToggleVideoMuteButton, {
style: style
});
};
const ToggleVideoMuteButton = ({
style
}) => {
const hmsActions = useHMSActions();
// TODO: set initial `isLocalVideoMuted` state value as per initial track setting
const isLocalVideoMuted = useSelector(state => state.hmsStates.isLocalVideoMuted);
const handleVideoMuteTogglePress = async () => {
// TODO: add getter API for state
// const enabled = hmsStore.getState(selectIsLocalVideoEnabled);
await hmsActions.setLocalVideoEnabled(!isLocalVideoMuted);
};
return /*#__PURE__*/React.createElement(PressableIcon, {
testID: !!isLocalVideoMuted ? TestIds.camera_muted_btn : TestIds.camera_unmuted_btn,
onPress: handleVideoMuteTogglePress,
active: isLocalVideoMuted,
style: style
}, /*#__PURE__*/React.createElement(CameraIcon, {
muted: !!isLocalVideoMuted
}));
};
//# sourceMappingURL=HMSManageLocalVideo.js.map