2023-03-23 13:24:57 +02:00
|
|
|
import { IconMic, IconMicSlash } from '../../icons/svg';
|
2018-03-06 16:28:19 -08:00
|
|
|
|
2023-03-23 13:24:57 +02:00
|
|
|
import AbstractButton, { IProps } from './AbstractButton';
|
2018-03-06 16:28:19 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An abstract implementation of a button for toggling audio mute.
|
|
|
|
|
*/
|
2023-06-09 15:02:00 -05:00
|
|
|
export default class BaseAudioMuteButton<P extends IProps, S=any>
|
2018-05-10 18:01:55 -05:00
|
|
|
extends AbstractButton<P, S> {
|
|
|
|
|
|
2025-03-12 10:19:11 -05:00
|
|
|
override icon = IconMic;
|
|
|
|
|
override toggledIcon = IconMicSlash;
|
2018-04-13 15:03:12 +02:00
|
|
|
|
2018-03-06 16:28:19 -08:00
|
|
|
/**
|
2018-04-13 15:03:12 +02:00
|
|
|
* Handles clicking / pressing the button, and toggles the audio mute state
|
|
|
|
|
* accordingly.
|
2018-03-06 16:28:19 -08:00
|
|
|
*
|
2018-04-13 15:03:12 +02:00
|
|
|
* @override
|
2018-05-10 21:10:26 -05:00
|
|
|
* @protected
|
2018-04-13 15:03:12 +02:00
|
|
|
* @returns {void}
|
2018-03-06 16:28:19 -08:00
|
|
|
*/
|
2025-03-12 10:19:11 -05:00
|
|
|
override _handleClick() {
|
2018-04-13 15:03:12 +02:00
|
|
|
this._setAudioMuted(!this._isAudioMuted());
|
|
|
|
|
}
|
2018-03-06 16:28:19 -08:00
|
|
|
|
|
|
|
|
/**
|
2018-04-13 15:03:12 +02:00
|
|
|
* Helper function to be implemented by subclasses, which must return a
|
|
|
|
|
* boolean value indicating if audio is muted or not.
|
2018-03-06 16:28:19 -08:00
|
|
|
*
|
2018-05-10 21:10:26 -05:00
|
|
|
* @protected
|
2018-04-13 15:03:12 +02:00
|
|
|
* @returns {boolean}
|
2018-03-06 16:28:19 -08:00
|
|
|
*/
|
2018-04-13 15:03:12 +02:00
|
|
|
_isAudioMuted() {
|
|
|
|
|
// To be implemented by subclass.
|
2023-03-23 13:24:57 +02:00
|
|
|
return false;
|
2018-03-06 16:28:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-13 15:03:12 +02:00
|
|
|
* Indicates whether this button is in toggled state or not.
|
2018-03-06 16:28:19 -08:00
|
|
|
*
|
2018-04-13 15:03:12 +02:00
|
|
|
* @override
|
2018-05-10 21:10:26 -05:00
|
|
|
* @protected
|
2018-04-13 15:03:12 +02:00
|
|
|
* @returns {boolean}
|
2018-03-06 16:28:19 -08:00
|
|
|
*/
|
2025-03-12 10:19:11 -05:00
|
|
|
override _isToggled() {
|
2018-04-13 15:03:12 +02:00
|
|
|
return this._isAudioMuted();
|
2018-03-06 16:28:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-13 15:03:12 +02:00
|
|
|
* Helper function to perform the actual setting of the audio mute / unmute
|
|
|
|
|
* action.
|
2018-03-06 16:28:19 -08:00
|
|
|
*
|
2023-03-23 13:24:57 +02:00
|
|
|
* @param {boolean} _audioMuted - Whether audio should be muted or not.
|
2018-05-10 21:10:26 -05:00
|
|
|
* @protected
|
2018-03-06 16:28:19 -08:00
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
2023-03-23 13:24:57 +02:00
|
|
|
_setAudioMuted(_audioMuted: boolean) {
|
2018-04-13 15:03:12 +02:00
|
|
|
// To be implemented by subclass.
|
2018-03-06 16:28:19 -08:00
|
|
|
}
|
|
|
|
|
}
|