Skip to content

Commit

Permalink
fix(FEC-7182): update UI accorindg to mute status change (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenMe authored and Dan Ziv committed Sep 25, 2017
1 parent 014272a commit a09ff7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/components/engine-connector/engine-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class EngineConnector extends BaseComponent {
this.props.updateVolume(this.player.volume);
});

this.player.addEventListener(this.player.Event.MUTE_CHANGE, () => {
this.props.updateMuted(this.player.muted);
});

this.player.addEventListener(this.player.Event.PLAY, () => {
this.props.updateIsPlaying(true);

Expand Down
12 changes: 7 additions & 5 deletions src/components/volume/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class VolumeControl extends BaseComponent {
this.player.addEventListener(this.player.Event.VOLUME_CHANGE, () => {
this.props.updateVolume(this.player.volume);
});

this.player.addEventListener(this.player.Event.MUTE_CHANGE, () => {
this.props.updateMuted(this.player.muted);
});
}

/**
Expand All @@ -66,7 +70,7 @@ class VolumeControl extends BaseComponent {
* @returns {string} - volume progress bar new height based on volume
* @memberof VolumeControl
*/
getVolumeProgessHeight(): string {
getVolumeProgressHeight(): string {
return this.props.muted ? '0%' : Math.round(this.props.volume * 100) + '%';
}

Expand Down Expand Up @@ -109,15 +113,14 @@ class VolumeControl extends BaseComponent {
}

/**
* on colume control button click, toggle mute in player and store state
* on volume control button click, toggle mute in player and store state
*
* @method onVolumeControlButtonClick
* @returns {void}
* @memberof VolumeControl
*/
onVolumeControlButtonClick(): void {
this.logger.debug(`Toggle mute. ${this.player.muted} => ${!this.player.muted}`);
this.props.updateMuted(!this.props.muted);
this.player.muted = !this.player.muted;
}

Expand All @@ -140,7 +143,6 @@ class VolumeControl extends BaseComponent {
this.player.volume = volume;
if (this.props.muted) {
this.player.muted = false;
this.props.updateMuted(false);
}
}

Expand Down Expand Up @@ -189,7 +191,7 @@ class VolumeControl extends BaseComponent {
onMouseUp={e => this.onVolumeProgressBarMouseUp(e)}
onMouseMove={e => this.onVolumeProgressBarMouseMove(e)}
>
<div className='progress' style={{height: this.getVolumeProgessHeight()}} />
<div className='progress' style={{height: this.getVolumeProgressHeight()}} />
</div>
</div>
</div>
Expand Down

0 comments on commit a09ff7b

Please sign in to comment.