2018-03-07 00:28:19 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-04-13 13:03:12 +00:00
|
|
|
import AbstractButton from './AbstractButton';
|
|
|
|
import type { Props } from './AbstractButton';
|
2018-03-07 00:28:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstract implementation of a button for toggling audio mute.
|
|
|
|
*/
|
2018-05-10 23:01:55 +00:00
|
|
|
export default class AbstractAudioMuteButton<P: Props, S: *>
|
|
|
|
extends AbstractButton<P, S> {
|
|
|
|
|
2018-04-13 13:03:12 +00:00
|
|
|
iconName = 'icon-microphone';
|
|
|
|
toggledIconName = 'icon-mic-disabled toggled';
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
/**
|
2018-04-13 13:03:12 +00:00
|
|
|
* Handles clicking / pressing the button, and toggles the audio mute state
|
|
|
|
* accordingly.
|
2018-03-07 00:28:19 +00:00
|
|
|
*
|
2018-04-13 13:03:12 +00:00
|
|
|
* @override
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-04-13 13:03:12 +00:00
|
|
|
* @returns {void}
|
2018-03-07 00:28:19 +00:00
|
|
|
*/
|
2018-04-13 13:03:12 +00:00
|
|
|
_handleClick() {
|
|
|
|
this._setAudioMuted(!this._isAudioMuted());
|
|
|
|
}
|
2018-03-07 00:28:19 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-13 13:03:12 +00:00
|
|
|
* Helper function to be implemented by subclasses, which must return a
|
|
|
|
* boolean value indicating if audio is muted or not.
|
2018-03-07 00:28:19 +00:00
|
|
|
*
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-04-13 13:03:12 +00:00
|
|
|
* @returns {boolean}
|
2018-03-07 00:28:19 +00:00
|
|
|
*/
|
2018-04-13 13:03:12 +00:00
|
|
|
_isAudioMuted() {
|
|
|
|
// To be implemented by subclass.
|
2018-03-07 00:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-13 13:03:12 +00:00
|
|
|
* Indicates whether this button is in toggled state or not.
|
2018-03-07 00:28:19 +00:00
|
|
|
*
|
2018-04-13 13:03:12 +00:00
|
|
|
* @override
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-04-13 13:03:12 +00:00
|
|
|
* @returns {boolean}
|
2018-03-07 00:28:19 +00:00
|
|
|
*/
|
2018-04-13 13:03:12 +00:00
|
|
|
_isToggled() {
|
|
|
|
return this._isAudioMuted();
|
2018-03-07 00:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-13 13:03:12 +00:00
|
|
|
* Helper function to perform the actual setting of the audio mute / unmute
|
|
|
|
* action.
|
2018-03-07 00:28:19 +00:00
|
|
|
*
|
2018-04-13 13:03:12 +00:00
|
|
|
* @param {boolean} audioMuted - Whether video should be muted or not.
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-03-07 00:28:19 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-04-13 13:03:12 +00:00
|
|
|
_setAudioMuted(audioMuted: boolean) { // eslint-disable-line no-unused-vars
|
|
|
|
// To be implemented by subclass.
|
2018-03-07 00:28:19 +00:00
|
|
|
}
|
|
|
|
}
|