mirror of https://github.com/jitsi/jitsi-meet
parent
acb91990bf
commit
70be08212d
@ -0,0 +1,94 @@ |
||||
import { IReduxState } from '../../app/types'; |
||||
import { AUDIO_MUTE_BUTTON_ENABLED } from '../../base/flags/constants'; |
||||
import { getFeatureFlag } from '../../base/flags/functions'; |
||||
import { MEDIA_TYPE } from '../../base/media/constants'; |
||||
import { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton'; |
||||
import BaseAudioMuteButton from '../../base/toolbox/components/BaseAudioMuteButton'; |
||||
import { isLocalTrackMuted } from '../../base/tracks/functions'; |
||||
import { muteLocal } from '../../video-menu/actions'; |
||||
import { isAudioMuteButtonDisabled } from '../functions'; |
||||
|
||||
|
||||
/** |
||||
* The type of the React {@code Component} props of {@link AbstractAudioMuteButton}. |
||||
*/ |
||||
export interface IProps extends AbstractButtonProps { |
||||
|
||||
|
||||
/** |
||||
* Whether audio is currently muted or not. |
||||
*/ |
||||
_audioMuted: boolean; |
||||
|
||||
/** |
||||
* Whether the button is disabled. |
||||
*/ |
||||
_disabled: boolean; |
||||
} |
||||
|
||||
/** |
||||
* Component that renders a toolbar button for toggling audio mute. |
||||
* |
||||
* @augments BaseAudioMuteButton |
||||
*/ |
||||
export default class AbstractAudioMuteButton<P extends IProps> extends BaseAudioMuteButton<P> { |
||||
accessibilityLabel = 'toolbar.accessibilityLabel.mute'; |
||||
toggledAccessibilityLabel = 'toolbar.accessibilityLabel.unmute'; |
||||
label = 'toolbar.mute'; |
||||
tooltip = 'toolbar.mute'; |
||||
toggledTooltip = 'toolbar.unmute'; |
||||
|
||||
/** |
||||
* Indicates if audio is currently muted or not. |
||||
* |
||||
* @override |
||||
* @protected |
||||
* @returns {boolean} |
||||
*/ |
||||
_isAudioMuted() { |
||||
return this.props._audioMuted; |
||||
} |
||||
|
||||
/** |
||||
* Changes the muted state. |
||||
* |
||||
* @param {boolean} audioMuted - Whether audio should be muted or not. |
||||
* @protected |
||||
* @returns {void} |
||||
*/ |
||||
_setAudioMuted(audioMuted: boolean) { |
||||
this.props.dispatch(muteLocal(audioMuted, MEDIA_TYPE.AUDIO)); |
||||
} |
||||
|
||||
/** |
||||
* Return a boolean value indicating if this button is disabled or not. |
||||
* |
||||
* @returns {boolean} |
||||
*/ |
||||
_isDisabled() { |
||||
return this.props._disabled; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Maps (parts of) the redux state to the associated props for the |
||||
* {@code AbstractAudioMuteButton} component. |
||||
* |
||||
* @param {Object} state - The Redux state. |
||||
* @private |
||||
* @returns {{ |
||||
* _audioMuted: boolean, |
||||
* _disabled: boolean |
||||
* }} |
||||
*/ |
||||
export function mapStateToProps(state: IReduxState) { |
||||
const _audioMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.AUDIO); |
||||
const _disabled = isAudioMuteButtonDisabled(state); |
||||
const enabledFlag = getFeatureFlag(state, AUDIO_MUTE_BUTTON_ENABLED, true); |
||||
|
||||
return { |
||||
_audioMuted, |
||||
_disabled, |
||||
visible: enabledFlag |
||||
}; |
||||
} |
@ -0,0 +1,93 @@ |
||||
import { IReduxState } from '../../app/types'; |
||||
import { VIDEO_MUTE_BUTTON_ENABLED } from '../../base/flags/constants'; |
||||
import { getFeatureFlag } from '../../base/flags/functions'; |
||||
import { MEDIA_TYPE } from '../../base/media/constants'; |
||||
import { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton'; |
||||
import BaseVideoMuteButton from '../../base/toolbox/components/BaseVideoMuteButton'; |
||||
import { isLocalTrackMuted } from '../../base/tracks/functions'; |
||||
import { handleToggleVideoMuted } from '../actions.any'; |
||||
import { isVideoMuteButtonDisabled } from '../functions'; |
||||
|
||||
/** |
||||
* The type of the React {@code Component} props of {@link AbstractVideoMuteButton}. |
||||
*/ |
||||
export interface IProps extends AbstractButtonProps { |
||||
|
||||
/** |
||||
* Whether video button is disabled or not. |
||||
*/ |
||||
_videoDisabled: boolean; |
||||
|
||||
/** |
||||
* Whether video is currently muted or not. |
||||
*/ |
||||
_videoMuted: boolean; |
||||
} |
||||
|
||||
/** |
||||
* Component that renders a toolbar button for toggling video mute. |
||||
* |
||||
* @augments BaseVideoMuteButton |
||||
*/ |
||||
export default class AbstractVideoMuteButton<P extends IProps> extends BaseVideoMuteButton<P> { |
||||
accessibilityLabel = 'toolbar.accessibilityLabel.videomute'; |
||||
toggledAccessibilityLabel = 'toolbar.accessibilityLabel.videounmute'; |
||||
label = 'toolbar.videomute'; |
||||
tooltip = 'toolbar.videomute'; |
||||
toggledTooltip = 'toolbar.videounmute'; |
||||
|
||||
/** |
||||
* Indicates if video is currently disabled or not. |
||||
* |
||||
* @override |
||||
* @protected |
||||
* @returns {boolean} |
||||
*/ |
||||
_isDisabled() { |
||||
return this.props._videoDisabled; |
||||
} |
||||
|
||||
/** |
||||
* Indicates if video is currently muted or not. |
||||
* |
||||
* @override |
||||
* @protected |
||||
* @returns {boolean} |
||||
*/ |
||||
_isVideoMuted() { |
||||
return this.props._videoMuted; |
||||
} |
||||
|
||||
/** |
||||
* Changes the muted state. |
||||
* |
||||
* @override |
||||
* @param {boolean} videoMuted - Whether video should be muted or not. |
||||
* @protected |
||||
* @returns {void} |
||||
*/ |
||||
_setVideoMuted(videoMuted: boolean) { |
||||
this.props.dispatch(handleToggleVideoMuted(videoMuted, true, true)); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Maps (parts of) the redux state to the associated props for the |
||||
* {@code VideoMuteButton} component. |
||||
* |
||||
* @param {Object} state - The Redux state. |
||||
* @private |
||||
* @returns {{ |
||||
* _videoMuted: boolean |
||||
* }} |
||||
*/ |
||||
export function mapStateToProps(state: IReduxState) { |
||||
const tracks = state['features/base/tracks']; |
||||
const enabledFlag = getFeatureFlag(state, VIDEO_MUTE_BUTTON_ENABLED, true); |
||||
|
||||
return { |
||||
_videoDisabled: isVideoMuteButtonDisabled(state), |
||||
_videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO), |
||||
visible: enabledFlag |
||||
}; |
||||
} |
@ -0,0 +1,6 @@ |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import { translate } from '../../../base/i18n/functions'; |
||||
import AbstractAudioMuteButton, { IProps, mapStateToProps } from '../AbstractAudioMuteButton'; |
||||
|
||||
export default translate(connect(mapStateToProps)(AbstractAudioMuteButton<IProps>)); |
@ -0,0 +1,7 @@ |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import { translate } from '../../../base/i18n/functions'; |
||||
import AbstractVideoMuteButton, { IProps, mapStateToProps } from '../AbstractVideoMuteButton'; |
||||
|
||||
|
||||
export default translate(connect(mapStateToProps)(AbstractVideoMuteButton<IProps>)); |
Loading…
Reference in new issue