diff --git a/react/features/video-menu/components/native/RemoteVideoMenu.tsx b/react/features/video-menu/components/native/RemoteVideoMenu.tsx index fe707ad735..37c9c9ee15 100644 --- a/react/features/video-menu/components/native/RemoteVideoMenu.tsx +++ b/react/features/video-menu/components/native/RemoteVideoMenu.tsx @@ -1,3 +1,5 @@ +/* eslint-disable lines-around-comment*/ + import React, { PureComponent } from 'react'; import { Text, TextStyle, View, ViewStyle } from 'react-native'; import { Divider } from 'react-native-paper'; @@ -29,9 +31,9 @@ import MuteEveryoneElseButton from './MuteEveryoneElseButton'; import MuteVideoButton from './MuteVideoButton'; import PinButton from './PinButton'; import SendToBreakoutRoom from './SendToBreakoutRoom'; +import VolumeSlider from './VolumeSlider'; import styles from './styles'; -// import VolumeSlider from './VolumeSlider'; /** * Size of the rendered avatar in the menu. @@ -142,6 +144,11 @@ class RemoteVideoMenu extends PureComponent { styles: bottomSheetStyles.buttons }; + const connectionStatusButtonProps = { + ...buttonProps, + afterClick: undefined + }; + return ( { { !_disableGrantModerator && } { !_disablePrivateChat && } - + {_moderator && _rooms.length > 1 && <> {/* @ts-ignore */} @@ -172,7 +177,7 @@ class RemoteVideoMenu extends PureComponent { room = { room } { ...buttonProps } />))} } - {/* */} + ); } diff --git a/react/features/video-menu/components/native/VolumeSlider.tsx b/react/features/video-menu/components/native/VolumeSlider.tsx index 142b209d6b..4f78c78ac0 100644 --- a/react/features/video-menu/components/native/VolumeSlider.tsx +++ b/react/features/video-menu/components/native/VolumeSlider.tsx @@ -1,18 +1,26 @@ +/* eslint-disable lines-around-comment*/ + import Slider from '@react-native-community/slider'; import _ from 'lodash'; import React, { PureComponent } from 'react'; import { View, ViewStyle } from 'react-native'; -import { withTheme } from 'react-native-paper'; import { connect } from 'react-redux'; import { IReduxState } from '../../../app/types'; import Icon from '../../../base/icons/components/Icon'; import { IconVolumeUp } from '../../../base/icons/svg'; +import { MEDIA_TYPE } from '../../../base/media/constants'; +import { + getTrackByMediaTypeAndParticipant, + getTrackState +} from '../../../base/tracks/functions.native'; +import BaseTheme from '../../../base/ui/components/BaseTheme.native'; import { setVolume } from '../../../participants-pane/actions.native'; -import { VOLUME_SLIDER_SCALE } from '../../constants'; +import { NATIVE_VOLUME_SLIDER_SCALE } from '../../constants'; import styles from './styles'; + /** * The type of the React {@code Component} props of {@link VolumeSlider}. */ @@ -21,27 +29,27 @@ interface IProps { /** * Whether the participant enters the conference silent. */ - _startSilent: boolean; + _startSilent?: boolean; + + /** + * Remote audio track. + */ + _track?: any; /** * The volume level for the participant. */ - _volume: number; + _volume?: number; /** * The redux dispatch function. */ - dispatch: Function; + dispatch?: Function; /** * The ID of the participant. */ - participantID: string; - - /** - * Theme used for styles. - */ - theme: any; + participantID?: string; } /** @@ -62,6 +70,7 @@ interface IState { * @returns {React$Element} */ class VolumeSlider extends PureComponent { + _originalVolumeChange: Function; /** @@ -74,7 +83,7 @@ class VolumeSlider extends PureComponent { super(props); this.state = { - volumeLevel: props._volume || 0 + volumeLevel: props._volume || Math.ceil(NATIVE_VOLUME_SLIDER_SCALE / 2) }; this._originalVolumeChange = this._onVolumeChange; @@ -91,9 +100,8 @@ class VolumeSlider extends PureComponent { * @returns {ReactElement} */ render() { - const { _startSilent, theme } = this.props; + const { _startSilent } = this.props; const { volumeLevel } = this.state; - const { palette } = theme; const onVolumeChange = _startSilent ? undefined : this._onVolumeChange; return ( @@ -102,13 +110,13 @@ class VolumeSlider extends PureComponent { size = { 24 } src = { IconVolumeUp } /> @@ -123,10 +131,22 @@ class VolumeSlider extends PureComponent { * @private * @returns {void} */ - _onVolumeChange(volumeLevel: number) { - const { dispatch, participantID } = this.props; + _onVolumeChange(volumeLevel: any) { + const { _track, dispatch, participantID } = this.props; + const audioTrack = _track?.jitsiTrack.track; - dispatch(setVolume(participantID, volumeLevel)); + let newVolumeLevel; + + if (volumeLevel <= 10) { + newVolumeLevel = volumeLevel / 10; + } else { + newVolumeLevel = volumeLevel - 9; + } + + audioTrack?._setVolume(newVolumeLevel); + + // @ts-ignore + dispatch(setVolume(participantID, newVolumeLevel)); } } @@ -138,16 +158,18 @@ class VolumeSlider extends PureComponent { * @param {Object} ownProps - The own props of the component. * @returns {IProps} */ -function mapStateToProps(state: IReduxState, ownProps: any) { +function mapStateToProps(state: IReduxState, ownProps: IProps) { const { participantID } = ownProps; - const { participantsVolume } = state['features/participants-pane']; + const { participantsVolume } = state['features/filmstrip']; const { startSilent } = state['features/base/config']; + const tracks = getTrackState(state); return { _startSilent: Boolean(startSilent), + _track: getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.AUDIO, participantID), _volume: participantID && participantsVolume[participantID] }; } -export default connect(mapStateToProps)(withTheme(VolumeSlider)); - +// @ts-ignore +export default connect(mapStateToProps)(VolumeSlider); diff --git a/react/features/video-menu/constants.ts b/react/features/video-menu/constants.ts index 523a47bfd2..a293bd3622 100644 --- a/react/features/video-menu/constants.ts +++ b/react/features/video-menu/constants.ts @@ -1,3 +1,11 @@ +/** + * Used to set maximumValue for native volume slider. + * Slider double-precision floating-point number indicating the volume, + * from 0 mute to 1 max, which converts to 0 mute to 19 max in our case. + * 0 as muted, 10 as standard and 19 as max remote participant volume level. + */ +export const NATIVE_VOLUME_SLIDER_SCALE = 19; + /** * Used to modify initialValue, which is expected to be a decimal value between * 0 and 1, and converts it to a number representable by an input slider, which