fix(Thumbnail): volume & audioLevel default values

This commit is contained in:
Hristo Terezov 2021-01-07 15:05:29 -06:00
parent 9bae7099dd
commit db48dc3ed3
3 changed files with 8 additions and 5 deletions

View File

@ -39,8 +39,11 @@ class AudioLevelIndicator extends Component<Props> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const { audioLevel: passedAudioLevel } = this.props;
// First make sure we are sensitive enough. // First make sure we are sensitive enough.
const audioLevel = Math.min(this.props.audioLevel * 1.2, 1); const audioLevel = typeof passedAudioLevel === 'number' && !isNaN(passedAudioLevel)
? Math.min(passedAudioLevel * 1.2, 1) : 0;
// Let's now stretch the audio level over the number of dots we have. // Let's now stretch the audio level over the number of dots we have.
const stretchedAudioLevel = AUDIO_LEVEL_DOTS * audioLevel; const stretchedAudioLevel = AUDIO_LEVEL_DOTS * audioLevel;

View File

@ -401,7 +401,7 @@ class Thumbnail extends Component<Props, State> {
_videoTrack _videoTrack
} = this.props; } = this.props;
const { id } = _participant || {}; const { id } = _participant || {};
const { audioLevel = 0 } = this.state; const { audioLevel } = this.state;
return ( return (
@ -447,7 +447,7 @@ class Thumbnail extends Component<Props, State> {
_startSilent _startSilent
} = this.props; } = this.props;
const { id } = _participant; const { id } = _participant;
const { audioLevel = 0, volume = 1 } = this.state; const { audioLevel, volume } = this.state;
// hide volume when in silent mode // hide volume when in silent mode
const onVolumeChange = _startSilent ? undefined : this._onVolumeChange; const onVolumeChange = _startSilent ? undefined : this._onVolumeChange;

View File

@ -75,7 +75,7 @@ type Props = {
* A value between 0 and 1 indicating the volume of the participant's * A value between 0 and 1 indicating the volume of the participant's
* audio element. * audio element.
*/ */
initialVolumeValue: number, initialVolumeValue: ?number,
/** /**
* Callback to invoke when changing the level of the participant's * Callback to invoke when changing the level of the participant's
@ -210,7 +210,7 @@ class RemoteVideoMenuTriggerButton extends Component<Props> {
participantID = { participantID } /> participantID = { participantID } />
); );
if (onVolumeChange) { if (onVolumeChange && initialVolumeValue && !isNaN(initialVolumeValue)) {
buttons.push( buttons.push(
<VolumeSlider <VolumeSlider
initialValue = { initialVolumeValue } initialValue = { initialVolumeValue }