2022-03-25 03:05:20 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import Service from '/imports/ui/components/audio/captions/service';
|
2022-06-30 01:18:15 +08:00
|
|
|
import Styled from './styles';
|
2022-03-25 03:05:20 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
start: {
|
|
|
|
id: 'app.audio.captions.button.start',
|
|
|
|
description: 'Start audio captions',
|
|
|
|
},
|
|
|
|
stop: {
|
|
|
|
id: 'app.audio.captions.button.stop',
|
|
|
|
description: 'Stop audio captions',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const CaptionsButton = ({
|
|
|
|
intl,
|
|
|
|
active,
|
|
|
|
enabled,
|
|
|
|
}) => {
|
|
|
|
const onClick = () => Service.setAudioCaptions(!active);
|
|
|
|
|
|
|
|
if (!enabled) return null;
|
|
|
|
|
|
|
|
return (
|
2022-06-30 01:18:15 +08:00
|
|
|
<Styled.ClosedCaptionToggleButton
|
2022-04-14 21:59:54 +08:00
|
|
|
icon={active ? 'closed_caption' : 'closed_caption_stop'}
|
2022-03-25 03:05:20 +08:00
|
|
|
label={intl.formatMessage(active ? intlMessages.stop : intlMessages.start)}
|
|
|
|
color={active ? 'primary' : 'default'}
|
|
|
|
ghost={!active}
|
|
|
|
hideLabel
|
|
|
|
circle
|
|
|
|
size="lg"
|
|
|
|
onClick={onClick}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
CaptionsButton.propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
active: PropTypes.bool.isRequired,
|
|
|
|
enabled: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default injectIntl(CaptionsButton);
|